mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 11:33:04 +00:00
Cleanup access-control components
- Use the same methods to retrieve the access-control urls - Fix EPersonDataService.startEditingNewEPerson returning the incorrect link
This commit is contained in:
@@ -11,12 +11,12 @@ export function getEPersonEditRoute(id: string): string {
|
||||
return new URLCombiner(getEPersonsRoute(), id).toString();
|
||||
}
|
||||
|
||||
export const GROUP_EDIT_PATH = 'groups';
|
||||
export const GROUP_PATH = 'groups';
|
||||
|
||||
export function getGroupsRoute() {
|
||||
return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH).toString();
|
||||
return new URLCombiner(getAccessControlModuleRoute(), GROUP_PATH).toString();
|
||||
}
|
||||
|
||||
export function getGroupEditRoute(id: string) {
|
||||
return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH, id).toString();
|
||||
return new URLCombiner(getGroupsRoute(), id).toString();
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ 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 { EPERSON_PATH, GROUP_EDIT_PATH } from './access-control-routing-paths';
|
||||
import { EPERSON_PATH, GROUP_PATH } from './access-control-routing-paths';
|
||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
import { GroupPageGuard } from './group-registry/group-page.guard';
|
||||
import {
|
||||
@@ -48,7 +48,7 @@ import { EPersonResolver } from './epeople-registry/eperson-resolver.service';
|
||||
canActivate: [SiteAdministratorGuard],
|
||||
},
|
||||
{
|
||||
path: GROUP_EDIT_PATH,
|
||||
path: GROUP_PATH,
|
||||
component: GroupsRegistryComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver
|
||||
@@ -57,7 +57,7 @@ import { EPersonResolver } from './epeople-registry/eperson-resolver.service';
|
||||
canActivate: [GroupAdministratorGuard]
|
||||
},
|
||||
{
|
||||
path: `${GROUP_EDIT_PATH}/newGroup`,
|
||||
path: `${GROUP_PATH}/create`,
|
||||
component: GroupFormComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver
|
||||
@@ -66,7 +66,7 @@ import { EPersonResolver } from './epeople-registry/eperson-resolver.service';
|
||||
canActivate: [GroupAdministratorGuard]
|
||||
},
|
||||
{
|
||||
path: `${GROUP_EDIT_PATH}/:groupId`,
|
||||
path: `${GROUP_PATH}/:groupId`,
|
||||
component: GroupFormComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver
|
||||
|
@@ -215,7 +215,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
||||
if (restResponse.hasSucceeded) {
|
||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: this.dsoNameService.getName(ePerson)}));
|
||||
} else {
|
||||
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + ePerson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
|
||||
this.notificationsService.error(`Error occurred when trying to delete EPerson with id: ${ePerson.id} with code: ${restResponse.statusCode} and message: ${restResponse.errorMessage}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<div class="group-form row">
|
||||
<div class="col-12">
|
||||
|
||||
<div *ngIf="groupDataService.getActiveGroup() | async; then editheader; else createHeader"></div>
|
||||
<div *ngIf="groupDataService.getActiveGroup() | async; then editHeader; else createHeader"></div>
|
||||
|
||||
<ng-template #createHeader>
|
||||
<h2 class="border-bottom pb-2">{{messagePrefix + '.head.create' | translate}}</h2>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #editheader>
|
||||
<ng-template #editHeader>
|
||||
<h2 class="border-bottom pb-2">
|
||||
<span
|
||||
*dsContextHelp="{
|
||||
|
@@ -10,7 +10,6 @@ import {
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import {
|
||||
ObservedValueOf,
|
||||
combineLatest as observableCombineLatest,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
@@ -48,6 +47,7 @@ import { Operation } from 'fast-json-patch';
|
||||
import { ValidateGroupExists } from './validators/group-exists.validator';
|
||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { getGroupEditRoute, getGroupsRoute } from '../../access-control-routing-paths';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-group-form',
|
||||
@@ -165,19 +165,19 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
this.canEdit$ = this.groupDataService.getActiveGroup().pipe(
|
||||
hasValueOperator(),
|
||||
switchMap((group: Group) => {
|
||||
return observableCombineLatest(
|
||||
return observableCombineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.CanDelete, isNotEmpty(group) ? group.self : undefined),
|
||||
this.hasLinkedDSO(group),
|
||||
(isAuthorized: ObservedValueOf<Observable<boolean>>, hasLinkedDSO: ObservedValueOf<Observable<boolean>>) => {
|
||||
return isAuthorized && !hasLinkedDSO;
|
||||
});
|
||||
})
|
||||
]).pipe(
|
||||
map(([isAuthorized, hasLinkedDSO]: [boolean, boolean]) => isAuthorized && !hasLinkedDSO),
|
||||
);
|
||||
observableCombineLatest(
|
||||
}),
|
||||
);
|
||||
observableCombineLatest([
|
||||
this.translateService.get(`${this.messagePrefix}.groupName`),
|
||||
this.translateService.get(`${this.messagePrefix}.groupCommunity`),
|
||||
this.translateService.get(`${this.messagePrefix}.groupDescription`)
|
||||
).subscribe(([groupName, groupCommunity, groupDescription]) => {
|
||||
]).subscribe(([groupName, groupCommunity, groupDescription]) => {
|
||||
this.groupName = new DynamicInputModel({
|
||||
id: 'groupName',
|
||||
label: groupName,
|
||||
@@ -215,12 +215,12 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.subs.push(
|
||||
observableCombineLatest(
|
||||
observableCombineLatest([
|
||||
this.groupDataService.getActiveGroup(),
|
||||
this.canEdit$,
|
||||
this.groupDataService.getActiveGroup()
|
||||
.pipe(filter((activeGroup) => hasValue(activeGroup)),switchMap((activeGroup) => this.getLinkedDSO(activeGroup).pipe(getFirstSucceededRemoteDataPayload())))
|
||||
).subscribe(([activeGroup, canEdit, linkedObject]) => {
|
||||
]).subscribe(([activeGroup, canEdit, linkedObject]) => {
|
||||
|
||||
if (activeGroup != null) {
|
||||
|
||||
@@ -263,7 +263,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
onCancel() {
|
||||
this.groupDataService.cancelEditGroup();
|
||||
this.cancelForm.emit();
|
||||
this.router.navigate([this.groupDataService.getGroupRegistryRouterLink()]);
|
||||
void this.router.navigate([getGroupsRoute()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +310,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
const groupSelfLink = rd.payload._links.self.href;
|
||||
this.setActiveGroupWithLink(groupSelfLink);
|
||||
this.groupDataService.clearGroupsRequests();
|
||||
this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLinkWithID(rd.payload.uuid));
|
||||
void this.router.navigateByUrl(getGroupEditRoute(rd.payload.uuid));
|
||||
}
|
||||
} else {
|
||||
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.created.failure', { name: groupToCreate.name }));
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<h2 id="header" class="pb-2">{{messagePrefix + 'head' | translate}}</h2>
|
||||
<div>
|
||||
<button class="mr-auto btn btn-success"
|
||||
[routerLink]="['newGroup']">
|
||||
[routerLink]="'create'">
|
||||
<i class="fas fa-plus"></i>
|
||||
<span class="d-none d-sm-inline ml-1">{{messagePrefix + 'button.add' | translate}}</span>
|
||||
</button>
|
||||
|
@@ -34,6 +34,7 @@ import { PatchData, PatchDataImpl } from '../data/base/patch-data';
|
||||
import { DeleteData, DeleteDataImpl } from '../data/base/delete-data';
|
||||
import { RestRequestMethod } from '../data/rest-request-method';
|
||||
import { dataService } from '../data/base/data-service.decorator';
|
||||
import { getEPersonEditRoute, getEPersonsRoute } from '../../access-control/access-control-routing-paths';
|
||||
|
||||
const ePeopleRegistryStateSelector = (state: AppState) => state.epeopleRegistry;
|
||||
const editEPersonSelector = createSelector(ePeopleRegistryStateSelector, (ePeopleRegistryState: EPeopleRegistryState) => ePeopleRegistryState.editEPerson);
|
||||
@@ -281,15 +282,14 @@ export class EPersonDataService extends IdentifiableDataService<EPerson> impleme
|
||||
this.editEPerson(ePerson);
|
||||
}
|
||||
});
|
||||
return '/access-control/epeople';
|
||||
return getEPersonEditRoute(ePerson.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get EPeople admin page
|
||||
* @param ePerson New EPerson to edit
|
||||
*/
|
||||
public getEPeoplePageRouterLink(): string {
|
||||
return '/access-control/epeople';
|
||||
return getEPersonsRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -40,6 +40,7 @@ import { DeleteData, DeleteDataImpl } from '../data/base/delete-data';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { RestRequestMethod } from '../data/rest-request-method';
|
||||
import { dataService } from '../data/base/data-service.decorator';
|
||||
import { getGroupEditRoute } from '../../access-control/access-control-routing-paths';
|
||||
|
||||
const groupRegistryStateSelector = (state: AppState) => state.groupRegistry;
|
||||
const editGroupSelector = createSelector(groupRegistryStateSelector, (groupRegistryState: GroupRegistryState) => groupRegistryState.editGroup);
|
||||
@@ -264,15 +265,15 @@ export class GroupDataService extends IdentifiableDataService<Group> implements
|
||||
* @param group Group we want edit page for
|
||||
*/
|
||||
public getGroupEditPageRouterLink(group: Group): string {
|
||||
return this.getGroupEditPageRouterLinkWithID(group.id);
|
||||
return getGroupEditRoute(group.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Edit page of group
|
||||
* @param groupID Group ID we want edit page for
|
||||
*/
|
||||
public getGroupEditPageRouterLinkWithID(groupId: string): string {
|
||||
return '/access-control/groups/' + groupId;
|
||||
public getGroupEditPageRouterLinkWithID(groupID: string): string {
|
||||
return getGroupEditRoute(groupID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,8 +17,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Group } from '../../../core/eperson/models/group.model';
|
||||
import { ACCESS_CONTROL_MODULE_PATH } from '../../../app-routing-paths';
|
||||
import { GROUP_EDIT_PATH } from '../../../access-control/access-control-routing-paths';
|
||||
import { getGroupEditRoute } from '../../../access-control/access-control-routing-paths';
|
||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||
|
||||
export interface ResourcePolicyCheckboxEntry {
|
||||
@@ -97,7 +96,7 @@ export class ResourcePolicyEntryComponent implements OnInit {
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
map((group: Group) => group.id),
|
||||
).subscribe((groupUUID) => {
|
||||
this.router.navigate([ACCESS_CONTROL_MODULE_PATH, GROUP_EDIT_PATH, groupUUID]);
|
||||
void this.router.navigate([getGroupEditRoute(groupUUID)]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user