From 042e9a06e80ace5593f4dc43937139847712001b Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Mon, 9 Nov 2020 18:21:13 +0100 Subject: [PATCH] Added authorizations edit page for community --- .../community-authorizations.component.html | 3 + ...community-authorizations.component.spec.ts | 71 +++++++++++++++++++ .../community-authorizations.component.ts | 38 ++++++++++ .../edit-community-page.module.ts | 4 +- .../edit-community-page.routing.module.ts | 7 +- 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.html create mode 100644 src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.spec.ts create mode 100644 src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.ts diff --git a/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.html b/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.html new file mode 100644 index 0000000000..abf2f87141 --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.spec.ts b/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.spec.ts new file mode 100644 index 0000000000..d29aab630d --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-authorizations/community-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 { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils'; +import { CommunityAuthorizationsComponent } from './community-authorizations.component'; +import { Collection } from '../../../core/shared/collection.model'; + +describe('CommunityAuthorizationsComponent', () => { + let comp: CommunityAuthorizationsComponent; + let fixture: ComponentFixture>; + + const community = Object.assign(new Collection(), { + uuid: 'community', + id: 'community', + _links: { + self: { href: 'community-selflink' } + } + }); + + const communityRD = createSuccessfulRemoteDataObject(community); + + const routeStub = { + parent: { + data: observableOf({ + dso: communityRD + }) + } + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + CommonModule + ], + declarations: [CommunityAuthorizationsComponent], + providers: [ + { provide: ActivatedRoute, useValue: routeStub }, + ChangeDetectorRef, + CommunityAuthorizationsComponent, + ], + schemas: [NO_ERRORS_SCHEMA], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommunityAuthorizationsComponent); + 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: communityRD }); + expect(comp.dsoRD$).toBeObservable(expected); + done(); + }); +}); diff --git a/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.ts b/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.ts new file mode 100644 index 0000000000..17b29fd7e2 --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-authorizations/community-authorizations.component.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; +import { first, map } from 'rxjs/operators'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; + +@Component({ + selector: 'ds-community-authorizations', + templateUrl: './community-authorizations.component.html', +}) +/** + * Component that handles the community Authorizations + */ +export class CommunityAuthorizationsComponent 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 community + */ + ngOnInit(): void { + this.dsoRD$ = this.route.parent.data.pipe(first(), map((data) => data.dso)); + } +} diff --git a/src/app/+community-page/edit-community-page/edit-community-page.module.ts b/src/app/+community-page/edit-community-page/edit-community-page.module.ts index f9a1e11a14..9c4a97eb5e 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.module.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.module.ts @@ -7,6 +7,7 @@ import { EditCommunityPageComponent } from './edit-community-page.component'; import { CommunityCurateComponent } from './community-curate/community-curate.component'; import { CommunityMetadataComponent } from './community-metadata/community-metadata.component'; import { CommunityRolesComponent } from './community-roles/community-roles.component'; +import { CommunityAuthorizationsComponent } from './community-authorizations/community-authorizations.component'; /** * Module that contains all components related to the Edit Community page administrator functionality @@ -22,7 +23,8 @@ import { CommunityRolesComponent } from './community-roles/community-roles.compo EditCommunityPageComponent, CommunityCurateComponent, CommunityMetadataComponent, - CommunityRolesComponent + CommunityRolesComponent, + CommunityAuthorizationsComponent ] }) export class EditCommunityPageModule { diff --git a/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts b/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts index 3197e00829..9f34f4db04 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts @@ -1,4 +1,3 @@ -import { CommunityPageResolver } from '../community-page.resolver'; import { EditCommunityPageComponent } from './edit-community-page.component'; import { RouterModule } from '@angular/router'; import { NgModule } from '@angular/core'; @@ -6,6 +5,7 @@ import { CommunityMetadataComponent } from './community-metadata/community-metad import { CommunityRolesComponent } from './community-roles/community-roles.component'; import { CommunityCurateComponent } from './community-curate/community-curate.component'; import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver'; +import { CommunityAuthorizationsComponent } from './community-authorizations/community-authorizations.component'; /** * Routing module that handles the routing for the Edit Community page administrator functionality @@ -44,6 +44,11 @@ import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.r path: 'curate', component: CommunityCurateComponent, data: { title: 'community.edit.tabs.curate.title', showBreadcrumbs: true } + }, + { + path: 'authorizations', + component: CommunityAuthorizationsComponent, + data: { title: 'community.edit.tabs.authorizations.title', showBreadcrumbs: true } } ] }