-
Notifications
You must be signed in to change notification settings - Fork 530
Manage Subscriptions interface #2017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b775cd5
[CST-7757] Subscriptions porting (wip)
rezartatis f15ca85
[CST-7757] Subscriptions porting (wip)
3ab552e
[CST-7757] Subscriptions porting (wip)
a6cd39c
[CST-7757] Subscriptions porting (wip)
af0b7e7
Merge branch 'main' into CST-7757
atarix83 72a42b0
[CST-7757] Refactoring code
atarix83 88e191e
[CST-7757] Fix lint errors
atarix83 88eefc6
[CST-7757] fix tests
atarix83 27d5097
[CST-7757] Add subscribe button to all dso pages
atarix83 90a9238
[CST-7757] fix pagination
atarix83 710b116
[CST-7757] Rename type property to subscriptionType
atarix83 1cc03f4
Merge branch 'main' into CST-7757
atarix83 28351f2
[CST-7757] Fix merge with main
atarix83 b09de30
[CST-7757] renamed param
Micheleboychuk b1011ed
[CST-7757] Remove subscription button from item pages
a4d94b0
[CST-7757] Response parameters fixed; submit button disabled if frequ…
0f8d2d7
[CST-7757] D-W-M fixed
0dfb37d
[CST-7757] Show object name
cbfddc6
Merge branch 'main-gh4s' into CST-7757
eae7b0d
[CST-7757] Minor fixes
7a46e6d
[CST-7757] Labels renamed
6bfcc25
[CST-7757] subscriptions data service tests
c8e7ac3
[CST-7757] subscription modal tests
325d78d
[CST-7757] modal fixes
27f541e
[CST-7757] modal fixes
516b91f
[CST-7757] Hide delete info for new subscriptions and fix issue with …
d65c12a
Merge branch 'main-gh4s' into CST-7757
851fe78
[CST-7757] Missing label
078bdd2
[CST-7757] Fix delete message
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
.../shared/dso-page/dso-page-subscription-button/dso-page-subscription-button.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <button *ngIf="isAuthorized$ | async" data-test="subscription-button" | ||
| (click)="openSubscriptionModal()" | ||
| [ngbTooltip]="'subscriptions.tooltip' | translate" | ||
| [title]="'subscriptions.tooltip' | translate" | ||
| [attr.aria-label]="'subscriptions.tooltip' | translate" | ||
| class="subscription-button btn btn-dark btn-sm"> | ||
| <i class="fas fa-bell fa-fw"></i> | ||
| </button> |
Empty file.
83 changes: 83 additions & 0 deletions
83
...ared/dso-page/dso-page-subscription-button/dso-page-subscription-button.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { DsoPageSubscriptionButtonComponent } from './dso-page-subscription-button.component'; | ||
| import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; | ||
| import { of as observableOf } from 'rxjs'; | ||
| import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; | ||
| import { By } from '@angular/platform-browser'; | ||
| import { DebugElement } from '@angular/core'; | ||
| import { Item } from '../../../core/shared/item.model'; | ||
| import { ITEM } from '../../../core/shared/item.resource-type'; | ||
| import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; | ||
| import { TranslateLoaderMock } from '../../mocks/translate-loader.mock'; | ||
|
|
||
| describe('DsoPageSubscriptionButtonComponent', () => { | ||
| let component: DsoPageSubscriptionButtonComponent; | ||
| let fixture: ComponentFixture<DsoPageSubscriptionButtonComponent>; | ||
| let de: DebugElement; | ||
|
|
||
| const authorizationService = jasmine.createSpyObj('authorizationService', { | ||
| isAuthorized: jasmine.createSpy('isAuthorized') // observableOf(true) | ||
| }); | ||
|
|
||
| const mockItem = Object.assign(new Item(), { | ||
| id: 'fake-id', | ||
| uuid: 'fake-id', | ||
| handle: 'fake/handle', | ||
| lastModified: '2018', | ||
| type: ITEM, | ||
| _links: { | ||
| self: { | ||
| href: 'https://localhost:8000/items/fake-id' | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [ | ||
| NgbModalModule, | ||
| TranslateModule.forRoot({ | ||
| loader: { | ||
| provide: TranslateLoader, | ||
| useClass: TranslateLoaderMock | ||
| } | ||
| }) | ||
| ], | ||
| declarations: [ DsoPageSubscriptionButtonComponent ], | ||
| providers: [ | ||
| { provide: AuthorizationDataService, useValue: authorizationService }, | ||
| ] | ||
| }) | ||
| .compileComponents(); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| fixture = TestBed.createComponent(DsoPageSubscriptionButtonComponent); | ||
| component = fixture.componentInstance; | ||
| de = fixture.debugElement; | ||
| component.dso = mockItem; | ||
| }); | ||
|
|
||
| describe('when is authorized', () => { | ||
| beforeEach(() => { | ||
| authorizationService.isAuthorized.and.returnValue(observableOf(true)); | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should display subscription button', () => { | ||
| expect(de.query(By.css(' [data-test="subscription-button"]'))).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('when is not authorized', () => { | ||
| beforeEach(() => { | ||
| authorizationService.isAuthorized.and.returnValue(observableOf(false)); | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should not display subscription button', () => { | ||
| expect(de.query(By.css(' [data-test="subscription-button"]'))).toBeNull(); | ||
| }); | ||
| }); | ||
| }); |
57 changes: 57 additions & 0 deletions
57
...pp/shared/dso-page/dso-page-subscription-button/dso-page-subscription-button.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { Component, Input, OnInit } from '@angular/core'; | ||
|
|
||
| import { Observable, of } from 'rxjs'; | ||
| import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; | ||
|
|
||
| import { DSpaceObject } from '../../../core/shared/dspace-object.model'; | ||
| import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; | ||
| import { SubscriptionModalComponent } from '../../subscriptions/subscription-modal/subscription-modal.component'; | ||
| import { FeatureID } from '../../../core/data/feature-authorization/feature-id'; | ||
|
|
||
| @Component({ | ||
| selector: 'ds-dso-page-subscription-button', | ||
| templateUrl: './dso-page-subscription-button.component.html', | ||
| styleUrls: ['./dso-page-subscription-button.component.scss'] | ||
| }) | ||
| /** | ||
| * Display a button that opens the modal to manage subscriptions | ||
| */ | ||
| export class DsoPageSubscriptionButtonComponent implements OnInit { | ||
|
|
||
| /** | ||
| * Whether the current user is authorized to edit the DSpaceObject | ||
| */ | ||
| isAuthorized$: Observable<boolean> = of(false); | ||
|
|
||
| /** | ||
| * Reference to NgbModal | ||
| */ | ||
| public modalRef: NgbModalRef; | ||
|
|
||
| /** | ||
| * DSpaceObject that is being viewed | ||
| */ | ||
| @Input() dso: DSpaceObject; | ||
|
|
||
| constructor( | ||
| protected authorizationService: AuthorizationDataService, | ||
| private modalService: NgbModal, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * check if the current DSpaceObject can be subscribed by the user | ||
| */ | ||
| ngOnInit(): void { | ||
| this.isAuthorized$ = this.authorizationService.isAuthorized(FeatureID.CanSubscribe, this.dso.self); | ||
| } | ||
|
|
||
| /** | ||
| * Open the modal to subscribe to the related DSpaceObject | ||
| */ | ||
| public openSubscriptionModal() { | ||
| this.modalRef = this.modalService.open(SubscriptionModalComponent); | ||
| this.modalRef.componentInstance.dso = this.dso; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { Observable } from 'rxjs'; | ||
| import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; | ||
|
|
||
| import { link, typedObject } from '../../../core/cache/builders/build-decorators'; | ||
| import { DSpaceObject } from '../../../core/shared/dspace-object.model'; | ||
| import { HALLink } from '../../../core/shared/hal-link.model'; | ||
| import { SUBSCRIPTION } from './subscription.resource-type'; | ||
| import { EPerson } from '../../../core/eperson/models/eperson.model'; | ||
| import { RemoteData } from '../../../core/data/remote-data'; | ||
| import { EPERSON } from '../../../core/eperson/models/eperson.resource-type'; | ||
| import { DSPACE_OBJECT } from '../../../core/shared/dspace-object.resource-type'; | ||
|
|
||
| @typedObject | ||
| @inheritSerialization(DSpaceObject) | ||
| export class Subscription extends DSpaceObject { | ||
| static type = SUBSCRIPTION; | ||
|
|
||
| /** | ||
| * A string representing subscription type | ||
| */ | ||
| @autoserialize | ||
| public id: string; | ||
|
|
||
| /** | ||
| * A string representing subscription type | ||
| */ | ||
| @autoserialize | ||
| public subscriptionType: string; | ||
|
|
||
| /** | ||
| * An array of parameters for the subscription | ||
| */ | ||
| @autoserialize | ||
| public subscriptionParameterList: SubscriptionParameterList[]; | ||
|
|
||
| /** | ||
| * The {@link HALLink}s for this Subscription | ||
| */ | ||
| @deserialize | ||
| _links: { | ||
| self: HALLink; | ||
| eperson: HALLink; | ||
| resource: HALLink; | ||
| }; | ||
|
|
||
| /** | ||
| * The logo for this Community | ||
| * Will be undefined unless the logo {@link HALLink} has been resolved. | ||
| */ | ||
| @link(EPERSON) | ||
| eperson?: Observable<RemoteData<EPerson>>; | ||
|
|
||
| /** | ||
| * The logo for this Community | ||
| * Will be undefined unless the logo {@link HALLink} has been resolved. | ||
| */ | ||
| @link(DSPACE_OBJECT) | ||
| resource?: Observable<RemoteData<DSpaceObject>>; | ||
| /** | ||
| * The embedded ePerson & dSpaceObject for this Subscription | ||
| */ | ||
| /* @deserialize | ||
| _embedded: { | ||
| ePerson: EPerson; | ||
| dSpaceObject: DSpaceObject; | ||
| };*/ | ||
| } | ||
|
|
||
| export interface SubscriptionParameterList { | ||
| id: string; | ||
| name: string; | ||
| value: string; | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/app/shared/subscriptions/models/subscription.resource-type.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { ResourceType } from '../../../core/shared/resource-type'; | ||
|
|
||
| /** | ||
| * The resource type for Subscription | ||
| * | ||
| * Needs to be in a separate file to prevent circular | ||
| * dependencies in webpack. | ||
| */ | ||
|
|
||
| export const SUBSCRIPTION = new ResourceType('subscription'); |
46 changes: 46 additions & 0 deletions
46
src/app/shared/subscriptions/subscription-modal/subscription-modal.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <form *ngIf="subscriptionForm" [formGroup]="subscriptionForm" (ngSubmit)="submit()" data-test="subscription-form"> | ||
| <div class="modal-header"> | ||
| <h4 class="modal-title">{{'subscriptions.modal.title' | translate}}</h4> | ||
| <button type="button" class="close" aria-label="Close" (click)="activeModal.close()"> | ||
| <span aria-hidden="true">×</span> | ||
| </button> | ||
| </div> | ||
| <div class="modal-body"> | ||
| <p class="mb-3"><strong>{{dso.name}}</strong> | ||
| <span *ngIf="!!dso" class="float-right"><ds-type-badge *ngIf="!!dso" [object]="dso"></ds-type-badge></span> | ||
| </p> | ||
| <div> | ||
| <fieldset *ngFor="let subscriptionType of subscriptionForm?.controls | keyvalue" formGroupName="{{subscriptionType.key}}" class="form-group form-row"> | ||
| <legend class="col-md-4 col-form-label float-md-left pt-0"> | ||
| {{ 'subscriptions.modal.new-subscription-form.type.' + subscriptionType.key | translate }}: | ||
| </legend> | ||
| <div class="col-md-8"> | ||
| <input type="hidden" formControlName="subscriptionId" [value]="subscriptionType?.value?.controls['subscriptionId'].value" > | ||
| <div class="form-check" formGroupName="frequencies" *ngFor="let frequency of frequencyDefaultValues"> | ||
| <input type="checkbox" [id]="'checkbox-' + frequency" class="form-check-input" [formControlName]="frequency"/> | ||
| <label class="form-check-label" | ||
| [for]="'checkbox-' + frequency">{{ 'subscriptions.modal.new-subscription-form.frequency.' + frequency | translate }}</label> | ||
| </div> | ||
| </div> | ||
| <ds-alert *ngIf="!!submitted && subscriptionType?.value?.controls['frequencies'].errors?.required" [type]="'alert-danger'"> | ||
| {{ 'context-menu.actions.subscription.frequency.required' | translate }} | ||
| </ds-alert> | ||
| </fieldset> | ||
| </div> | ||
| <p class="text-muted" *ngIf="(showDeleteInfo$ | async)">{{'subscriptions.modal.delete-info' | translate}}</p> | ||
| </div> | ||
| <div class="modal-footer"> | ||
| <button type="button" class="btn btn-outline-secondary" | ||
| (click)="activeModal.close()"> | ||
| {{'subscriptions.modal.close' | translate}} | ||
| </button> | ||
| <button type="submit" class="btn btn-success" [disabled]="(processing$ | async) || !isValid"> | ||
| <span *ngIf="(processing$ | async)"> | ||
| <i class='fas fa-circle-notch fa-spin'></i> {{'subscriptions.modal.new-subscription-form.processing' | translate}} | ||
| </span> | ||
| <span *ngIf="!(processing$ | async)"> | ||
| {{'subscriptions.modal.new-subscription-form.submit' | translate}} | ||
| </span> | ||
| </button> | ||
| </div> | ||
| </form> |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.