From 3f883248d242dd5f4aa752699cce501911992762 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 23 Sep 2024 16:54:59 +0300 Subject: [PATCH] [develop]: Admin component: Add setAdminMenuItems method to replace duplicate code. --- src/app/admin/admin.component.ts | 42 +++++++++++++++----------------- src/app/openaireLibrary | 2 +- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts index bb0e9a0..297af61 100644 --- a/src/app/admin/admin.component.ts +++ b/src/app/admin/admin.component.ts @@ -20,9 +20,11 @@ import {Irish} from "../shared/irish"; [class.sidebar_main_active]="open && (hasSidebar || hasInternalSidebar || hasAdminMenu)" [class.sidebar_mini]="!open && (hasSidebar || hasInternalSidebar || hasAdminMenu)" [class.sidebar_hover]="hover"> - - +
@@ -69,19 +71,10 @@ export class AdminComponent extends SidebarBaseComponent implements OnInit { if (this.isAdmin && this.stakeholder.defaultId) { this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, "uk-visible@m", "/admin/" + this.stakeholder.alias + "/admin-tools")); } + this.backItem = null; if (this.hasAdminMenu) { - this.adminMenuItems = []; - this.backItem = null; - this.adminMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'})); - if (Session.isPortalAdministrator(this.user)) { - this.adminMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/admin-tools')); - } - if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)) { - this.adminMenuItems.push(new MenuItem("irishOptions", "Irish options", "", "/admin/irish/admin-tools/pages", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/irish/admin-tools')); - } - this.hasAdminMenu = this.hasAdminMenu && this.adminMenuItems.length > 1; + this.setAdminMenuItems(); } - this.backItem = new MenuItem("back", "Manage profiles", "", "/admin", false, [], null, {}, {name: 'west'}); this.loading = false; })); @@ -92,16 +85,7 @@ export class AdminComponent extends SidebarBaseComponent implements OnInit { this.hasSidebar = false; this.loading = false; if (this.hasAdminMenu) { - this.adminMenuItems = []; - this.backItem = null; - this.adminMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'})); - if (Session.isPortalAdministrator(this.user)) { - this.adminMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/admin-tools')); - } - if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)) { - this.adminMenuItems.push(new MenuItem("irishOptions", "Irish options", "", "/admin/irish/admin-tools/pages", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/irish/admin-tools')); - } - this.hasAdminMenu = this.hasAdminMenu && this.adminMenuItems.length > 1; + this.setAdminMenuItems(); } } })); @@ -125,6 +109,18 @@ export class AdminComponent extends SidebarBaseComponent implements OnInit { this.configurationService.initPortal(this.properties, this.properties.adminToolsCommunity); } + private setAdminMenuItems() { + this.adminMenuItems = []; + this.adminMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'})); + if (Session.isPortalAdministrator(this.user)) { + this.adminMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/admin-tools')); + } + if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)) { + this.adminMenuItems.push(new MenuItem("irishOptions", "Irish options", "", "/admin/irish/admin-tools/pages", false, [], [], {}, {name: 'settings'}, null, "uk-visible@m", '/admin/irish/admin-tools')); + } + this.hasAdminMenu = this.hasAdminMenu && this.adminMenuItems.length > 1; + } + public get isAdmin() { return Session.isPortalAdministrator(this.user) || Session.isCurator(this.stakeholder.type, this.user); } diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 8f668cd..c762858 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 8f668cd4ff51655caacdab42304c32cb2446fe64 +Subproject commit c7628584277d8a81274ef40a58e908df988a5e58