diff --git a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts index bfc36cea24..9d7b35eb68 100644 --- a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts +++ b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts @@ -79,6 +79,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { this.createSiteAdministratorMenuSections(); this.createExportMenuSections(); this.createImportMenuSections(); + this.createAccessControlMenuSections(); super.ngOnInit(); this.sidebarWidth = this.variableService.getVariable('sidebarItemsWidth'); this.authService.isAuthenticated() @@ -436,51 +437,6 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { createSiteAdministratorMenuSections() { this.authorizationService.isAuthorized(FeatureID.AdministratorOf).subscribe((authorized) => { const menuList = [ - /* Access Control */ - { - id: 'access_control', - active: false, - visible: authorized, - model: { - type: MenuItemType.TEXT, - text: 'menu.section.access_control' - } as TextMenuItemModel, - icon: 'key', - index: 4 - }, - { - id: 'access_control_people', - parentID: 'access_control', - active: false, - visible: authorized, - model: { - type: MenuItemType.LINK, - text: 'menu.section.access_control_people', - link: '/admin/access-control/epeople' - } as LinkMenuItemModel, - }, - { - id: 'access_control_groups', - parentID: 'access_control', - active: false, - visible: authorized, - model: { - type: MenuItemType.LINK, - text: 'menu.section.access_control_groups', - link: '/admin/access-control/groups' - } as LinkMenuItemModel, - }, - { - id: 'access_control_authorizations', - parentID: 'access_control', - active: false, - visible: authorized, - model: { - type: MenuItemType.LINK, - text: 'menu.section.access_control_authorizations', - link: '' - } as LinkMenuItemModel, - }, /* Admin Search */ { id: 'admin_search', @@ -564,6 +520,65 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { }); } + /** + * Create menu sections dependent on whether or not the current user can manage access control groups + */ + createAccessControlMenuSections() { + this.authorizationService.isAuthorized(FeatureID.CanManageGroups).subscribe((authorized) => { + const menuList = [ + /* Access Control */ + { + id: 'access_control', + active: false, + visible: authorized, + model: { + type: MenuItemType.TEXT, + text: 'menu.section.access_control' + } as TextMenuItemModel, + icon: 'key', + index: 4 + }, + { + id: 'access_control_people', + parentID: 'access_control', + active: false, + visible: authorized, + model: { + type: MenuItemType.LINK, + text: 'menu.section.access_control_people', + link: '/access-control/epeople' + } as LinkMenuItemModel, + }, + { + id: 'access_control_groups', + parentID: 'access_control', + active: false, + visible: authorized, + model: { + type: MenuItemType.LINK, + text: 'menu.section.access_control_groups', + link: '/access-control/groups' + } as LinkMenuItemModel, + }, + { + id: 'access_control_authorizations', + parentID: 'access_control', + active: false, + visible: authorized, + model: { + type: MenuItemType.LINK, + text: 'menu.section.access_control_authorizations', + link: '' + } as LinkMenuItemModel, + }, + ]; + + menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, { + shouldPersistOnRouteChange: true, + }))); + }) + } + /** * Method to change this.collapsed to false when the slide animation ends and is sliding open * @param event The animation event diff --git a/src/app/access-control/access-control-routing-paths.ts b/src/app/access-control/access-control-routing-paths.ts index 10ef09066d..d229d12bd2 100644 --- a/src/app/access-control/access-control-routing-paths.ts +++ b/src/app/access-control/access-control-routing-paths.ts @@ -1,11 +1,7 @@ import { URLCombiner } from '../core/url-combiner/url-combiner'; +import { getAccessControlModuleRoute } from '../app-routing-paths'; export const GROUP_EDIT_PATH = 'groups'; -export const ACCESS_CONTROL_MODULE_PATH = 'access-control'; - -export function getAccessControlModuleRoute() { - return `/${ACCESS_CONTROL_MODULE_PATH}`; -} export function getGroupEditRoute(id: string) { return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH, id).toString(); diff --git a/src/app/app-routing-paths.ts b/src/app/app-routing-paths.ts index 8db4ba5aa7..453b03dcfb 100644 --- a/src/app/app-routing-paths.ts +++ b/src/app/app-routing-paths.ts @@ -71,3 +71,9 @@ export const INFO_MODULE_PATH = 'info'; export function getInfoModulePath() { return `/${INFO_MODULE_PATH}`; } + +export const ACCESS_CONTROL_MODULE_PATH = 'access-control'; + +export function getAccessControlModuleRoute() { + return `/${ACCESS_CONTROL_MODULE_PATH}`; +} diff --git a/src/app/core/data/feature-authorization/feature-id.ts b/src/app/core/data/feature-authorization/feature-id.ts index 3c17f43cb1..0af2399b7c 100644 --- a/src/app/core/data/feature-authorization/feature-id.ts +++ b/src/app/core/data/feature-authorization/feature-id.ts @@ -9,4 +9,5 @@ export enum FeatureID { WithdrawItem = 'withdrawItem', ReinstateItem = 'reinstateItem', EPersonRegistration = 'epersonRegistration', + CanManageGroups = 'canManageGroups', } diff --git a/src/app/shared/resource-policies/resource-policies.component.ts b/src/app/shared/resource-policies/resource-policies.component.ts index a83492d79f..bc83314ee4 100644 --- a/src/app/shared/resource-policies/resource-policies.component.ts +++ b/src/app/shared/resource-policies/resource-policies.component.ts @@ -31,8 +31,8 @@ import { RequestService } from '../../core/data/request.service'; import { NotificationsService } from '../notifications/notifications.service'; import { dateToString, stringToNgbDateStruct } from '../date.util'; import { followLink } from '../utils/follow-link-config.model'; -import { ADMIN_MODULE_PATH } from '../../app-routing-paths'; -import { ACCESS_CONTROL_MODULE_PATH, GROUP_EDIT_PATH } from '../../access-control/access-control-routing-paths'; +import { ACCESS_CONTROL_MODULE_PATH, ADMIN_MODULE_PATH } from '../../app-routing-paths'; +import { GROUP_EDIT_PATH } from '../../access-control/access-control-routing-paths'; interface ResourcePolicyCheckboxEntry { id: string;