Files
dspace-angular/src/app/shared/menu/providers/processes.menu.ts
Yury Bondarenko 0291942613 Proof-of-concept: independent menu section providers
- Replace god-class resolvers with a service that populates the menus from lists of injectable providers
- Static menu sections are resolved at the root route ~ `resolveStatic`
- Route-dependent menu sections can be declared in the same structure, but are resolved on-demand ~ `resolveRoute`
- More and more easily customizable
  - Parts can be moved between menus, removed, replaced or extended individually
  - The dependencies of each provider are independent of each other
  - Order of providers determines the order of each menu → single source of truth for the order
2024-08-23 18:39:41 +02:00

51 lines
1.3 KiB
TypeScript

/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
import { Injectable } from '@angular/core';
import {
combineLatest,
map,
Observable,
} from 'rxjs';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
import { MenuItemType } from '../menu-item-type.model';
import {
AbstractMenuProvider,
PartialMenuSection,
} from '../menu-provider';
@Injectable()
export class ProcessesMenuProvider extends AbstractMenuProvider {
constructor(
protected authorizationService: AuthorizationDataService,
) {
super();
}
public getSections(): Observable<PartialMenuSection[]> {
return combineLatest([
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
]).pipe(
map(([isSiteAdmin]) => {
return [
{
visible: isSiteAdmin,
model: {
type: MenuItemType.LINK,
text: 'menu.section.processes',
link: '/processes',
},
icon: 'terminal',
},
] as PartialMenuSection[];
}),
);
}
}