From 29df9c609e9b5c4461d72ab1093f2d80dd4c5513 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Mon, 9 Nov 2020 18:21:37 +0100 Subject: [PATCH] Added authorizations edit page for collections --- .../collection-authorizations.component.html | 3 + ...ollection-authorizations.component.spec.ts | 71 +++++++++++++++++++ .../collection-authorizations.component.ts | 40 +++++++++++ .../edit-collection-page.module.ts | 4 +- .../edit-collection-page.routing.module.ts | 8 ++- 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.html create mode 100644 src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.spec.ts create mode 100644 src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.ts diff --git a/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.html b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.html new file mode 100644 index 0000000000..fa66186ece --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.spec.ts b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.spec.ts new file mode 100644 index 0000000000..6333bf5568 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.spec.ts @@ -0,0 +1,71 @@ +import { CommonModule } from '@angular/common'; +import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; + +import { cold } from 'jasmine-marbles'; +import { of as observableOf } from 'rxjs'; + +import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { CollectionAuthorizationsComponent } from './collection-authorizations.component'; +import { Collection } from '../../../core/shared/collection.model'; +import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils'; + +describe('CollectionAuthorizationsComponent', () => { + let comp: CollectionAuthorizationsComponent; + let fixture: ComponentFixture>; + + const collection = Object.assign(new Collection(), { + uuid: 'collection', + id: 'collection', + _links: { + self: { href: 'collection-selflink' } + } + }); + + const collectionRD = createSuccessfulRemoteDataObject(collection); + + const routeStub = { + parent: { + data: observableOf({ + dso: collectionRD + }) + } + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + CommonModule + ], + declarations: [CollectionAuthorizationsComponent], + providers: [ + { provide: ActivatedRoute, useValue: routeStub }, + ChangeDetectorRef, + CollectionAuthorizationsComponent, + ], + schemas: [NO_ERRORS_SCHEMA], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CollectionAuthorizationsComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + }); + + afterEach(() => { + comp = null; + fixture.destroy(); + }); + + it('should create', () => { + expect(comp).toBeTruthy(); + }); + + it('should init dso remote data properly', (done) => { + const expected = cold('(a|)', { a: collectionRD }); + expect(comp.dsoRD$).toBeObservable(expected); + done(); + }); +}); diff --git a/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.ts b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.ts new file mode 100644 index 0000000000..dd7f20729e --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-authorizations/collection-authorizations.component.ts @@ -0,0 +1,40 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { Observable } from 'rxjs'; +import { first, map } from 'rxjs/operators'; + +import { RemoteData } from '../../../core/data/remote-data'; +import { DSpaceObject } from '../../../core/shared/dspace-object.model'; + +@Component({ + selector: 'ds-collection-authorizations', + templateUrl: './collection-authorizations.component.html', +}) +/** + * Component that handles the Collection Authorizations + */ +export class CollectionAuthorizationsComponent implements OnInit { + + /** + * The initial DSO object + */ + public dsoRD$: Observable>; + + /** + * Initialize instance variables + * + * @param {ActivatedRoute} route + */ + constructor( + private route: ActivatedRoute + ) { + } + + /** + * Initialize the component, setting up the collection + */ + ngOnInit(): void { + this.dsoRD$ = this.route.parent.data.pipe(first(), map((data) => data.dso)); + } +} diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts index f442aae4d6..6ca0948512 100644 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts @@ -8,6 +8,7 @@ import { CollectionPageModule } from '../collection-page.module'; import { CollectionRolesComponent } from './collection-roles/collection-roles.component'; import { CollectionCurateComponent } from './collection-curate/collection-curate.component'; import { CollectionSourceComponent } from './collection-source/collection-source.component'; +import { CollectionAuthorizationsComponent } from './collection-authorizations/collection-authorizations.component'; /** * Module that contains all components related to the Edit Collection page administrator functionality @@ -24,7 +25,8 @@ import { CollectionSourceComponent } from './collection-source/collection-source CollectionMetadataComponent, CollectionRolesComponent, CollectionCurateComponent, - CollectionSourceComponent + CollectionSourceComponent, + CollectionAuthorizationsComponent ] }) export class EditCollectionPageModule { diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts index 0569de9cd9..30172090a6 100644 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts @@ -5,6 +5,7 @@ import { CollectionMetadataComponent } from './collection-metadata/collection-me import { CollectionRolesComponent } from './collection-roles/collection-roles.component'; import { CollectionSourceComponent } from './collection-source/collection-source.component'; import { CollectionCurateComponent } from './collection-curate/collection-curate.component'; +import { CollectionAuthorizationsComponent } from './collection-authorizations/collection-authorizations.component'; import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver'; /** @@ -49,7 +50,12 @@ import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.r path: 'curate', component: CollectionCurateComponent, data: { title: 'collection.edit.tabs.curate.title', showBreadcrumbs: true } - } + }, + { + path: 'authorizations', + component: CollectionAuthorizationsComponent, + data: { title: 'collection.edit.tabs.authorizations.title', showBreadcrumbs: true } + }, ] } ])