@@ -11,8 +11,10 @@ import { Component, computed, inject, output } from '@angular/core';
1111import { toSignal } from '@angular/core/rxjs-interop' ;
1212import { ActivatedRoute , NavigationEnd , Router , RouterLink , RouterLinkActive } from '@angular/router' ;
1313
14- import { PROJECT_MENU_ITEMS , REGISTRATION_MENU_ITEMS } from '@core/constants' ;
14+ import { MODERATION_MENU_ITEM , PROJECT_MENU_ITEMS , REGISTRATION_MENU_ITEMS } from '@core/constants' ;
1515import { NavigationService } from '@core/services' ;
16+ import { ProviderSelectors } from '@osf/core/store/provider' ;
17+ import { UserSelectors } from '@osf/core/store/user' ;
1618import { AuthSelectors } from '@osf/features/auth/store' ;
1719import { IconComponent } from '@osf/shared/components' ;
1820
@@ -32,7 +34,30 @@ export class NavMenuComponent {
3234 private readonly isAuthenticated = select ( AuthSelectors . isAuthenticated ) ;
3335
3436 protected readonly myProjectMenuItems = PROJECT_MENU_ITEMS ;
35- protected readonly registrationMenuItems = REGISTRATION_MENU_ITEMS ;
37+ protected readonly registrationMenuItems = computed ( ( ) => {
38+ const menu = [ ...REGISTRATION_MENU_ITEMS ] ;
39+ if ( this . isUserModerator ( ) ) {
40+ const menuItems = menu [ 0 ] . items ?? [ ] ;
41+ if ( ! menuItems . some ( ( item ) => item . label === MODERATION_MENU_ITEM . label ) ) {
42+ menuItems . push ( MODERATION_MENU_ITEM ) ;
43+ }
44+ }
45+ const withRouterLinks = menu . map ( ( section ) => ( {
46+ ...section ,
47+ items : section . items ?. map ( ( item ) => {
48+ const isModerationPage = item . state && item . state [ 'isModeration' ] ;
49+ const routeId = isModerationPage ? this . provider ( ) ?. id : this . currentResourceId ( ) ;
50+ return {
51+ ...item ,
52+ routerLink : item . routerLink ? [ '/registries' , routeId , item . routerLink ] : null ,
53+ queryParams : isModerationPage ? { resourceId : this . currentResourceId ( ) } : { } ,
54+ } ;
55+ } ) ,
56+ } ) ) ;
57+ return withRouterLinks ;
58+ } ) ;
59+ protected readonly isUserModerator = select ( UserSelectors . isCurrentUserModerator ) ;
60+ protected readonly provider = select ( ProviderSelectors . getCurrentProvider ) ;
3661
3762 protected readonly mainMenuItems = computed ( ( ) => {
3863 const isAuthenticated = this . isAuthenticated ( ) ;
@@ -69,14 +94,12 @@ export class NavMenuComponent {
6994
7095 private getRouteInfo ( ) {
7196 const urlSegments = this . router . url . split ( '/' ) . filter ( ( segment ) => segment ) ;
72-
73- const resourceId = this . route . firstChild ?. snapshot . params [ 'id' ] || null ;
97+ const resourceFromQueryParams = this . route . snapshot . queryParams [ 'resourceId' ] ;
98+ const resourceId = this . route . firstChild ?. snapshot . params [ 'id' ] || resourceFromQueryParams ;
7499 const section = this . route . firstChild ?. firstChild ?. snapshot . url [ 0 ] ?. path || 'overview' ;
75-
76100 const isCollectionsWithId = urlSegments [ 0 ] === 'collections' && urlSegments [ 1 ] && urlSegments [ 1 ] !== '' ;
77101 const isRegistryRoute = urlSegments [ 0 ] === 'registries' && ! ! urlSegments [ 2 ] ;
78102 const isRegistryRouteDetails = urlSegments [ 0 ] === 'registries' && urlSegments [ 2 ] === 'overview' ;
79-
80103 return {
81104 resourceId,
82105 section,
0 commit comments