Skip to content
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

Edit collection - assign roles groups #643

Merged
merged 5 commits into from Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions resources/i18n/en.json5
Expand Up @@ -763,6 +763,60 @@



"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 accept or reject incoming submissions. However, they are not able to edit the submission's metadata.",
tdonohue marked this conversation as resolved.
Show resolved Hide resolved


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

"comcol-role.edit.finaleditor.description": "Final editors are able to edit the metadata of incoming submissions, and then accept or reject them.",
tdonohue marked this conversation as resolved.
Show resolved Hide resolved


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

"comcol-role.edit.reviewer.description": "Reviewers are able to edit the metadata of incoming submissions, but will not be able to reject them.",
tdonohue marked this conversation as resolved.
Show resolved Hide resolved



"community.form.abstract": "Short Description",

"community.form.description": "Introductory text (HTML)",
Expand Down
Expand Up @@ -3,19 +3,27 @@ import { RouterModule } from '@angular/router';
import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.component';
import { GroupFormComponent } from './group-registry/group-form/group-form.component';
import { GroupsRegistryComponent } from './group-registry/groups-registry.component';
import { URLCombiner } from '../../core/url-combiner/url-combiner';
import { getAccessControlModulePath } from '../admin-routing.module';

const GROUP_EDIT_PATH = 'groups';

export function getGroupEditPath(id: string) {
return new URLCombiner(getAccessControlModulePath(), GROUP_EDIT_PATH, id).toString();
}

@NgModule({
imports: [
RouterModule.forChild([
{ path: 'epeople', component: EPeopleRegistryComponent, data: { title: 'admin.access-control.epeople.title' } },
{ path: 'groups', component: GroupsRegistryComponent, data: { title: 'admin.access-control.groups.title' } },
{ path: GROUP_EDIT_PATH, component: GroupsRegistryComponent, data: { title: 'admin.access-control.groups.title' } },
{
path: 'groups/:groupId',
path: `${GROUP_EDIT_PATH}/:groupId`,
component: GroupFormComponent,
data: {title: 'admin.registries.schema.title'}
},
{
path: 'groups/newGroup',
path: `${GROUP_EDIT_PATH}/newGroup`,
component: GroupFormComponent,
data: {title: 'admin.registries.schema.title'}
},
Expand Down
4 changes: 4 additions & 0 deletions src/app/+admin/admin-routing.module.ts
Expand Up @@ -12,6 +12,10 @@ export function getRegistriesModulePath() {
return new URLCombiner(getAdminModulePath(), REGISTRIES_MODULE_PATH).toString();
}

export function getAccessControlModulePath() {
return new URLCombiner(getAdminModulePath(), ACCESS_CONTROL_MODULE_PATH).toString();
}

@NgModule({
imports: [
RouterModule.forChild([
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),
);
}
}
@@ -0,0 +1,6 @@
<ds-comcol-role
*ngFor="let comcolRole of getComcolRoles()"
[dso]="community$ | async"
[comcolRole]="comcolRole"
>
</ds-comcol-role>
@@ -0,0 +1,89 @@
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 { 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', () => {

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

beforeEach(() => {

const route = {
parent: {
data: observableOf({
dso: new RemoteData(
false,
false,
true,
undefined,
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();

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

fixture.detectChanges();
});

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