Skip to content

Commit

Permalink
Merge pull request #643 from atmire/Edit-Collection---Assign-Roles-Gr…
Browse files Browse the repository at this point in the history
…oups

Edit collection - assign roles groups
  • Loading branch information
tdonohue committed Apr 16, 2020
2 parents 2fdb5a4 + b7b7e7a commit c64760b
Show file tree
Hide file tree
Showing 12 changed files with 511 additions and 133 deletions.
54 changes: 51 additions & 3 deletions resources/i18n/en.json5
Expand Up @@ -761,11 +761,59 @@

"community.edit.tabs.roles.title": "Community Edit - Roles",

"community.edit.tabs.roles.none": "None",

"community.edit.tabs.roles.admin.name": "Administrators",

"community.edit.tabs.roles.admin.description": "Community administrators can create sub-communities or collections, and manage or assign management for those sub-communities or collections. In addition, they decide who can submit items to any sub-collections, edit item metadata (after submission), and add (map) existing items from other collections (subject to authorization).",
"comcol-role.edit.no-group": "None",

"comcol-role.edit.create": "Create",

"comcol-role.edit.restrict": "Restrict",

"comcol-role.edit.delete": "Delete",


"comcol-role.edit.community-admin.name": "Administrators",

"comcol-role.edit.collection-admin.name": "Administrators",


"comcol-role.edit.community-admin.description": "Community administrators can create sub-communities or collections, and manage or assign management for those sub-communities or collections. In addition, they decide who can submit items to any sub-collections, edit item metadata (after submission), and add (map) existing items from other collections (subject to authorization).",

"comcol-role.edit.collection-admin.description": "Collection administrators decide who can submit items to the collection, edit item metadata (after submission), and add (map) existing items from other collections to this collection (subject to authorization for that collection).",


"comcol-role.edit.submitters.name": "Submitters",

"comcol-role.edit.submitters.description": "The E-People and Groups that have permission to submit new items to this collection.",


"comcol-role.edit.item_read.name": "Default item read access",

"comcol-role.edit.item_read.description": "E-People and Groups that can read new items submitted to this collection. Changes to this role are not retroactive. Existing items in the system will still be viewable by those who had read access at the time of their addition.",

"comcol-role.edit.item_read.anonymous-group": "Default read for incoming items is currently set to Anonymous.",


"comcol-role.edit.bitstream_read.name": "Default bitstream read access",

"comcol-role.edit.bitstream_read.description": "Community administrators can create sub-communities or collections, and manage or assign management for those sub-communities or collections. In addition, they decide who can submit items to any sub-collections, edit item metadata (after submission), and add (map) existing items from other collections (subject to authorization).",

"comcol-role.edit.bitstream_read.anonymous-group": "Default read for incoming bitstreams is currently set to Anonymous.",


"comcol-role.edit.editor.name": "Editors",

"comcol-role.edit.editor.description": "Editors are able to edit the metadata of incoming submissions, and then accept or reject them.",


"comcol-role.edit.finaleditor.name": "Final editors",

"comcol-role.edit.finaleditor.description": "Final editors are able to edit the metadata of incoming submissions, but will not be able to reject them.",


"comcol-role.edit.reviewer.name": "Reviewers",

"comcol-role.edit.reviewer.description": "Reviewers are able to accept or reject incoming submissions. However, they are not able to edit the submission's metadata.",



Expand Down
@@ -0,0 +1,6 @@
<ds-comcol-role
*ngFor="let comcolRole of getComcolRoles() | async"
[dso]="collection$ | async"
[comcolRole]="comcolRole"
>
</ds-comcol-role>
@@ -0,0 +1,121 @@
import { ComponentFixture, TestBed} from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router';
import { of as observableOf } from 'rxjs/internal/observable/of';
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { RemoteData } from '../../../core/data/remote-data';
import { CollectionRolesComponent } from './collection-roles.component';
import { Collection } from '../../../core/shared/collection.model';
import { SharedModule } from '../../../shared/shared.module';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { RequestService } from '../../../core/data/request.service';
import { RouterTestingModule } from '@angular/router/testing';

describe('CollectionRolesComponent', () => {

let fixture: ComponentFixture<CollectionRolesComponent>;
let comp: CollectionRolesComponent;
let de: DebugElement;

beforeEach(() => {

const route = {
parent: {
data: observableOf({
dso: new RemoteData(
false,
false,
true,
undefined,
Object.assign(new Collection(), {
_links: {
'irrelevant': {
href: 'irrelevant link',
},
'adminGroup': {
href: 'adminGroup link',
},
'submittersGroup': {
href: 'submittersGroup link',
},
'itemReadGroup': {
href: 'itemReadGroup link',
},
'bitstreamReadGroup': {
href: 'bitstreamReadGroup link',
},
'workflowGroups/test': {
href: 'test workflow group link',
},
},
}),
),
})
}
};

const requestService = {
hasByHrefObservable: () => observableOf(true),
};

const groupDataService = {
findByHref: () => observableOf(new RemoteData(
false,
false,
true,
undefined,
{},
200,
)),
};

TestBed.configureTestingModule({
imports: [
SharedModule,
RouterTestingModule.withRoutes([]),
TranslateModule.forRoot(),
],
declarations: [
CollectionRolesComponent,
],
providers: [
{ provide: ActivatedRoute, useValue: route },
{ provide: RequestService, useValue: requestService },
{ provide: GroupDataService, useValue: groupDataService },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();

fixture = TestBed.createComponent(CollectionRolesComponent);
comp = fixture.componentInstance;
de = fixture.debugElement;

fixture.detectChanges();
});

it('should display a collection admin role component', () => {
expect(de.query(By.css('ds-comcol-role .collection-admin')))
.toBeTruthy();
});

it('should display a submitters role component', () => {
expect(de.query(By.css('ds-comcol-role .submitters')))
.toBeTruthy();
});

it('should display a default item read role component', () => {
expect(de.query(By.css('ds-comcol-role .item_read')))
.toBeTruthy();
});

it('should display a default bitstream read role component', () => {
expect(de.query(By.css('ds-comcol-role .bitstream_read')))
.toBeTruthy();
});

it('should display a test workflow role component', () => {
expect(de.query(By.css('ds-comcol-role .test')))
.toBeTruthy();
});
});
@@ -1,4 +1,11 @@
import { Component } from '@angular/core';
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 { Collection } from '../../../core/shared/collection.model';
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
import { ComcolRole } from '../../../shared/comcol-forms/edit-comcol-page/comcol-role/comcol-role';

/**
* Component for managing a collection's roles
Expand All @@ -7,6 +14,48 @@ import { Component } from '@angular/core';
selector: 'ds-collection-roles',
templateUrl: './collection-roles.component.html',
})
export class CollectionRolesComponent {
/* TODO: Implement Collection Edit - Roles */
export class CollectionRolesComponent implements OnInit {

dsoRD$: Observable<RemoteData<Collection>>;

/**
* The collection to manage, as an observable.
*/
get collection$(): Observable<Collection> {
return this.dsoRD$.pipe(
getSucceededRemoteData(),
getRemoteDataPayload(),
)
}

/**
* The different roles for the collection, as an observable.
*/
getComcolRoles(): Observable<ComcolRole[]> {
return this.collection$.pipe(
map((collection) =>
[
ComcolRole.COLLECTION_ADMIN,
ComcolRole.SUBMITTERS,
ComcolRole.ITEM_READ,
ComcolRole.BITSTREAM_READ,
...Object.keys(collection._links)
.filter((link) => link.startsWith('workflowGroups/'))
.map((link) => new ComcolRole(link.substr('workflowGroups/'.length), link)),
]
),
);
}

constructor(
protected route: ActivatedRoute,
) {
}

ngOnInit(): void {
this.dsoRD$ = this.route.parent.data.pipe(
first(),
map((data) => data.dso),
);
}
}
Expand Up @@ -2,6 +2,5 @@
*ngFor="let comcolRole of getComcolRoles()"
[dso]="community$ | async"
[comcolRole]="comcolRole"
class="card {{comcolRole.name}}"
>
</ds-comcol-role>
Expand Up @@ -7,6 +7,10 @@ import { CommunityRolesComponent } from './community-roles.component';
import { Community } from '../../../core/shared/community.model';
import { By } from '@angular/platform-browser';
import { RemoteData } from '../../../core/data/remote-data';
import { RequestService } from '../../../core/data/request.service';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { SharedModule } from '../../../shared/shared.module';
import { RouterTestingModule } from '@angular/router/testing';

describe('CommunityRolesComponent', () => {

Expand All @@ -24,21 +28,49 @@ describe('CommunityRolesComponent', () => {
false,
true,
undefined,
new Community(),
)
Object.assign(new Community(), {
_links: {
irrelevant: {
href: 'irrelevant link',
},
adminGroup: {
href: 'adminGroup link',
},
},
}),
),
})
}
};

const requestService = {
hasByHrefObservable: () => observableOf(true),
};

const groupDataService = {
findByHref: () => observableOf(new RemoteData(
false,
false,
true,
undefined,
{},
200,
)),
};

TestBed.configureTestingModule({
imports: [
SharedModule,
RouterTestingModule.withRoutes([]),
TranslateModule.forRoot(),
],
declarations: [
CommunityRolesComponent,
],
providers: [
{ provide: ActivatedRoute, useValue: route },
{ provide: RequestService, useValue: requestService },
{ provide: GroupDataService, useValue: groupDataService },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
Expand All @@ -51,6 +83,7 @@ describe('CommunityRolesComponent', () => {
});

it('should display a community admin role component', () => {
expect(de.query(By.css('ds-comcol-role.admin'))).toBeDefined();
expect(de.query(By.css('ds-comcol-role .community-admin')))
.toBeTruthy();
});
});
Expand Up @@ -33,7 +33,7 @@ export class CommunityRolesComponent implements OnInit {
*/
getComcolRoles(): ComcolRole[] {
return [
ComcolRole.ADMIN,
ComcolRole.COMMUNITY_ADMIN,
];
}

Expand Down

0 comments on commit c64760b

Please sign in to comment.