mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Continue the menu refactor and cleanup
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
[ngClass]="{ disabled: isDisabled }"
|
||||
[attr.aria-disabled]="isDisabled"
|
||||
[attr.aria-labelledby]="'sidebarName-' + section.id"
|
||||
[title]="('menu.section.icon.' + section.id) | translate"
|
||||
[title]="itemModel.text | translate"
|
||||
[routerLink]="itemModel.link"
|
||||
(keyup.space)="navigate($event)"
|
||||
(keyup.enter)="navigate($event)"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
role="button" tabindex="0"
|
||||
[attr.aria-labelledby]="'sidebarName-' + section.id"
|
||||
[attr.aria-expanded]="expanded | async"
|
||||
[title]="('menu.section.icon.' + section.id) | translate"
|
||||
[title]="itemModel.text | translate"
|
||||
[class.disabled]="section.model?.disabled"
|
||||
(click)="toggleSection($event)"
|
||||
(keyup.space)="toggleSection($event)"
|
||||
|
@@ -32,12 +32,10 @@ import { ReloadGuard } from './core/reload/reload.guard';
|
||||
import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
||||
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
||||
import { ENTITY_MODULE_PATH, ITEM_MODULE_PATH } from './item-page/item-page-routing-paths';
|
||||
import { MenuResolver } from './menu.resolver';
|
||||
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
|
||||
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
|
||||
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
|
||||
import { PROCESS_MODULE_PATH } from './process-page/process-page-routing.paths';
|
||||
import { MenuProviderService } from './shared/menu/menu-provider.service';
|
||||
// import { resolveStaticMenus } from './shared/menu/menu.resolver';
|
||||
|
||||
@NgModule({
|
||||
|
@@ -30,8 +30,7 @@ import { WorkflowMenuProvider } from './shared/menu/providers/workflow.menu';
|
||||
import { COMMUNITY_MODULE_PATH } from './community-page/community-page-routing-paths';
|
||||
import { COLLECTION_MODULE_PATH } from './collection-page/collection-page-routing-paths';
|
||||
import { ENTITY_MODULE_PATH, ITEM_MODULE_PATH } from './item-page/item-page-routing-paths';
|
||||
import { HOME_PAGE_PATH } from './app-routing-paths';
|
||||
import { DsoOptionMenu } from './shared/menu/providers/dso-option-menu.service';
|
||||
import { DsoOptionMenu } from './shared/menu/providers/dso-option.menu';
|
||||
|
||||
export const MENUS = buildMenuStructure({
|
||||
[MenuID.PUBLIC]: [
|
||||
@@ -55,12 +54,11 @@ export const MENUS = buildMenuStructure({
|
||||
],
|
||||
[MenuID.DSO_EDIT]: [
|
||||
DsoOptionMenu.withSubs([
|
||||
SubscribeMenuProvider.onRoute(COMMUNITY_MODULE_PATH, COLLECTION_MODULE_PATH),
|
||||
DSpaceObjectEditMenuProvider.onRoute(COMMUNITY_MODULE_PATH, COLLECTION_MODULE_PATH, ITEM_MODULE_PATH, ENTITY_MODULE_PATH),
|
||||
VersioningMenuProvider.onRoute(ITEM_MODULE_PATH, ENTITY_MODULE_PATH),
|
||||
OrcidMenuProvider.onRoute(ITEM_MODULE_PATH, ENTITY_MODULE_PATH),
|
||||
ClaimMenuProvider.onRoute(ITEM_MODULE_PATH, ENTITY_MODULE_PATH),
|
||||
// SubscribeMenuProvider,
|
||||
ClaimMenuProvider.onRoute(ITEM_MODULE_PATH, ENTITY_MODULE_PATH, COLLECTION_MODULE_PATH),
|
||||
]),
|
||||
SubscribeMenuProvider.onRoute(COMMUNITY_MODULE_PATH, COLLECTION_MODULE_PATH),
|
||||
],
|
||||
});
|
||||
|
@@ -5,9 +5,6 @@ import { CollectionBreadcrumbResolver } from '../core/breadcrumbs/collection-bre
|
||||
import { DSOBreadcrumbsService } from '../core/breadcrumbs/dso-breadcrumbs.service';
|
||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
import { LinkService } from '../core/cache/builders/link.service';
|
||||
import { SubscribeMenuProvider } from '../shared/menu/providers/comcol-subscribe.menu';
|
||||
import { DSpaceObjectEditMenuProvider } from '../shared/menu/providers/dso-edit.menu';
|
||||
import { StatisticsMenuProvider } from '../shared/menu/providers/statistics.menu';
|
||||
import { CollectionPageAdministratorGuard } from './collection-page-administrator.guard';
|
||||
import {
|
||||
COLLECTION_CREATE_PATH,
|
||||
|
@@ -21,11 +21,10 @@ import { MetadataService } from './core/metadata/metadata.service';
|
||||
import { BreadcrumbsService } from './breadcrumbs/breadcrumbs.service';
|
||||
import { ThemeService } from './shared/theme-support/theme.service';
|
||||
import { isAuthenticationBlocking } from './core/auth/selectors';
|
||||
import { distinctUntilChanged, find, switchMap } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, find } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MenuService } from './shared/menu/menu.service';
|
||||
import { MenuProviderService } from './shared/menu/menu-provider.service';
|
||||
import { MenuID } from './shared/menu/menu-id.model';
|
||||
|
||||
/**
|
||||
* Performs the initialization of the app.
|
||||
@@ -190,18 +189,9 @@ export abstract class InitService {
|
||||
this.metadata.listenForRouteChange();
|
||||
this.breadcrumbsService.listenForRouteChanges();
|
||||
this.themeService.listenForRouteChanges();
|
||||
// this.menuService.listenForRouteChanges();
|
||||
this.menuProviderService.listenForRouteChanges();
|
||||
}
|
||||
|
||||
protected initPersistentMenus(): void {
|
||||
this.menuProviderService.resolvePersistentMenus().subscribe((done) => {
|
||||
Object.values(MenuID).forEach((menuID) => {
|
||||
this.menuService.buildRouteMenuSections(menuID);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits once authentication is ready (no longer blocking)
|
||||
* @protected
|
||||
|
@@ -5,20 +5,13 @@ import { AuthenticatedGuard } from '../core/auth/authenticated.guard';
|
||||
import { DSOBreadcrumbsService } from '../core/breadcrumbs/dso-breadcrumbs.service';
|
||||
import { ItemBreadcrumbResolver } from '../core/breadcrumbs/item-breadcrumb.resolver';
|
||||
import { LinkService } from '../core/cache/builders/link.service';
|
||||
import { DSpaceObjectEditMenuProvider } from '../shared/menu/providers/dso-edit.menu';
|
||||
import { ClaimMenuProvider } from '../shared/menu/providers/item-claim.menu';
|
||||
import { OrcidMenuProvider } from '../shared/menu/providers/item-orcid.menu';
|
||||
import { VersioningMenuProvider } from '../shared/menu/providers/item-versioning.menu';
|
||||
import { StatisticsMenuProvider } from '../shared/menu/providers/statistics.menu';
|
||||
import { BitstreamRequestACopyPageComponent } from './bitstreams/request-a-copy/bitstream-request-a-copy-page.component';
|
||||
import {
|
||||
BitstreamRequestACopyPageComponent
|
||||
} from './bitstreams/request-a-copy/bitstream-request-a-copy-page.component';
|
||||
import { UploadBitstreamComponent } from './bitstreams/upload/upload-bitstream.component';
|
||||
import { ThemedFullItemPageComponent } from './full/themed-full-item-page.component';
|
||||
import { ItemPageAdministratorGuard } from './item-page-administrator.guard';
|
||||
import {
|
||||
ITEM_EDIT_PATH,
|
||||
ORCID_PATH,
|
||||
UPLOAD_BITSTREAM_PATH,
|
||||
} from './item-page-routing-paths';
|
||||
import { ITEM_EDIT_PATH, ORCID_PATH, UPLOAD_BITSTREAM_PATH, } from './item-page-routing-paths';
|
||||
import { ItemPageResolver } from './item-page.resolver';
|
||||
import { OrcidPageComponent } from './orcid-page/orcid-page.component';
|
||||
import { OrcidPageGuard } from './orcid-page/orcid-page.guard';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<div *ngIf="hasSubSections$ | async">
|
||||
<ng-container *ngIf="hasSubSections$ | async">
|
||||
<div class="nav-item dropdown expandable-navbar-section text-md-center"
|
||||
*ngVar="(active | async) as isActive"
|
||||
(keyup.enter)="isActive ? deactivateSection($event) : activateSection($event)"
|
||||
@@ -21,4 +21,4 @@
|
||||
</ng-container>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
@@ -65,6 +65,6 @@ export class DsoEditMenuExpandableSectionComponent extends AbstractMenuSectionCo
|
||||
this.hasSubSections$ = this.subSections$.pipe(
|
||||
map((subSections) => isNotEmpty(subSections))
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -127,17 +127,17 @@ describe('DsoEditMenuSectionComponent', () => {
|
||||
stopPropagation: jasmine.createSpy('stopPropagation'),
|
||||
});
|
||||
it('should call the item model function when not disabled', () => {
|
||||
spyOn(component.section.model as OnClickMenuItemModel, 'function');
|
||||
spyOn((component as any).section.model as OnClickMenuItemModel, 'function');
|
||||
component.activate(mockEvent);
|
||||
|
||||
expect((component.section.model as OnClickMenuItemModel).function).toHaveBeenCalled();
|
||||
expect(((component as any).section.model as OnClickMenuItemModel).function).toHaveBeenCalled();
|
||||
});
|
||||
it('should call not the item model function when disabled', () => {
|
||||
spyOn(component.section.model as OnClickMenuItemModel, 'function');
|
||||
spyOn((component as any).section.model as OnClickMenuItemModel, 'function');
|
||||
component.itemModel.disabled = true;
|
||||
component.activate(mockEvent);
|
||||
|
||||
expect((component.section.model as OnClickMenuItemModel).function).not.toHaveBeenCalled();
|
||||
expect(((component as any).section.model as OnClickMenuItemModel).function).not.toHaveBeenCalled();
|
||||
component.itemModel.disabled = false;
|
||||
});
|
||||
});
|
||||
|
@@ -16,6 +16,7 @@ import { getMockThemeService } from '../../mocks/theme-service.mock';
|
||||
|
||||
|
||||
import { DsoPageModule } from '../dso-page.module';
|
||||
import { TextMenuItemModel } from '../../menu/menu-item/models/text.model';
|
||||
|
||||
describe('DsoEditMenuComponent', () => {
|
||||
let comp: DsoEditMenuComponent;
|
||||
@@ -32,9 +33,10 @@ describe('DsoEditMenuComponent', () => {
|
||||
active: false,
|
||||
visible: true,
|
||||
model: {
|
||||
text: 'section-text',
|
||||
type: null,
|
||||
disabled: false,
|
||||
} as MenuItemModel,
|
||||
} as TextMenuItemModel,
|
||||
icon: 'pencil-alt',
|
||||
index: 1
|
||||
};
|
||||
|
@@ -66,12 +66,8 @@ export class MenuProviderService {
|
||||
}
|
||||
|
||||
|
||||
public resolvePersistentMenus(
|
||||
// route: ActivatedRouteSnapshot,
|
||||
// state: RouterStateSnapshot
|
||||
): Observable<boolean> {
|
||||
|
||||
return combineLatest([
|
||||
public initPersistentMenus() {
|
||||
combineLatest([
|
||||
...this.providers
|
||||
.map((provider) => {
|
||||
return provider;
|
||||
@@ -98,63 +94,69 @@ export class MenuProviderService {
|
||||
return [waitForMenus];
|
||||
}),
|
||||
map(done => done.every(Boolean)),
|
||||
);
|
||||
).subscribe((done) => {
|
||||
Object.values(MenuID).forEach((menuID) => {
|
||||
this.menuService.buildRouteMenuSections(menuID);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public resolveRouteMenus(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean> {
|
||||
return combineLatest([
|
||||
const currentNonPersistentMenuSections$ = combineLatest([
|
||||
...Object.values(MenuID).map((menuID) => {
|
||||
return this.menuService.getNonPersistentMenuSections(menuID).pipe(
|
||||
take(1),
|
||||
map((sections) => {
|
||||
return {menuId: menuID, sections: sections};
|
||||
}));
|
||||
})])
|
||||
.pipe(
|
||||
switchMap((menuSectionsPerMenu) => {
|
||||
this.removeNonPersistentSections(menuSectionsPerMenu);
|
||||
return combineLatest([
|
||||
...this.providers
|
||||
.filter(provider => {
|
||||
let shouldUpdate = false;
|
||||
if (!provider.shouldPersistOnRouteChange && isNotEmpty(provider.activePaths)) {
|
||||
provider.activePaths.forEach((path) => {
|
||||
if (state.url.includes(path)) {
|
||||
shouldUpdate = true;
|
||||
}
|
||||
});
|
||||
} else if (!provider.shouldPersistOnRouteChange) {
|
||||
shouldUpdate = true;
|
||||
}
|
||||
return shouldUpdate;
|
||||
})
|
||||
.map(provider => provider.getSections(route, state)
|
||||
.pipe(
|
||||
map((sections) => {
|
||||
return {provider: provider, sections: sections};
|
||||
}),
|
||||
)
|
||||
)
|
||||
]);
|
||||
}),
|
||||
switchMap((providerWithSections: { provider: AbstractMenuProvider, sections: PartialMenuSection[] }[]) => {
|
||||
const waitForMenus = providerWithSections.map((providerWithSection: {
|
||||
provider: AbstractMenuProvider,
|
||||
sections: PartialMenuSection[]
|
||||
}, sectionIndex) => {
|
||||
providerWithSection.sections.forEach((section) => {
|
||||
this.addSection(providerWithSection, section);
|
||||
})]);
|
||||
|
||||
const routeDependentMenuSections$ = combineLatest([
|
||||
...this.providers
|
||||
.filter(provider => {
|
||||
let shouldUpdate = false;
|
||||
if (!provider.shouldPersistOnRouteChange && isNotEmpty(provider.activePaths)) {
|
||||
provider.activePaths.forEach((path) => {
|
||||
if (state.url.includes(path)) {
|
||||
shouldUpdate = true;
|
||||
}
|
||||
});
|
||||
return this.waitForMenu$(providerWithSection.provider.menuID);
|
||||
} else if (!provider.shouldPersistOnRouteChange) {
|
||||
shouldUpdate = true;
|
||||
}
|
||||
return shouldUpdate;
|
||||
})
|
||||
.map(provider => provider.getSections(route, state)
|
||||
.pipe(
|
||||
map((sections) => {
|
||||
return {provider: provider, sections: sections};
|
||||
}),
|
||||
)
|
||||
)
|
||||
]);
|
||||
|
||||
return combineLatest([
|
||||
currentNonPersistentMenuSections$,
|
||||
routeDependentMenuSections$
|
||||
]).pipe(
|
||||
switchMap(([currentMenusWithSections, providerWithSections]) => {
|
||||
this.removeNonPersistentSections(currentMenusWithSections);
|
||||
const waitForMenus = providerWithSections.map((providerWithSection: {
|
||||
provider: AbstractMenuProvider,
|
||||
sections: PartialMenuSection[]
|
||||
}) => {
|
||||
providerWithSection.sections.forEach((section) => {
|
||||
this.addSection(providerWithSection, section);
|
||||
});
|
||||
return [waitForMenus];
|
||||
}),
|
||||
map(done => done.every(Boolean)),
|
||||
);
|
||||
// }
|
||||
return this.waitForMenu$(providerWithSection.provider.menuID);
|
||||
});
|
||||
return [waitForMenus];
|
||||
}),
|
||||
map(done => done.every(Boolean)),
|
||||
);
|
||||
}
|
||||
|
||||
private addSection(providerWithSection: {
|
||||
@@ -167,7 +169,7 @@ export class MenuProviderService {
|
||||
parentID: section.parentID ?? providerWithSection.provider.parentID,
|
||||
index: section.index ?? providerWithSection.provider.index,
|
||||
shouldPersistOnRouteChange: section.shouldPersistOnRouteChange ?? providerWithSection.provider.shouldPersistOnRouteChange,
|
||||
isExpandable: section.isExpandable ?? providerWithSection.provider.isExpandable,
|
||||
alwaysRenderExpandable: section.alwaysRenderExpandable ?? providerWithSection.provider.alwaysRenderExpandable,
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -5,28 +5,15 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import { Omit } from '@material-ui/core';
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import flatten from 'lodash/flatten';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { MenuID } from './menu-id.model';
|
||||
import { MenuItemModels, MenuSection } from './menu-section.model';
|
||||
import { APP_INITIALIZER, Provider, Type } from '@angular/core';
|
||||
import { APP_CONFIG } from '../../../config/app-config.interface';
|
||||
import { TransferState } from '@angular/platform-browser';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { HOME_PAGE_PATH } from '../../app-routing-paths';
|
||||
import { MENU_PROVIDER } from './menu.structure';
|
||||
import { MenuItemModels } from './menu-section.model';
|
||||
import { Type } from '@angular/core';
|
||||
|
||||
// export type PartialMenuSection = Omit<MenuSection, 'id' | 'active'>;
|
||||
export interface PartialMenuSection {
|
||||
id?: string;
|
||||
visible: boolean;
|
||||
@@ -36,11 +23,10 @@ export interface PartialMenuSection {
|
||||
active?: boolean;
|
||||
shouldPersistOnRouteChange?: boolean;
|
||||
icon?: string;
|
||||
isExpandable?: boolean;
|
||||
alwaysRenderExpandable?: boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface MenuProvider {
|
||||
shouldPersistOnRouteChange?: boolean,
|
||||
menuID?: MenuID;
|
||||
@@ -49,35 +35,37 @@ export interface MenuProvider {
|
||||
getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
|
||||
}
|
||||
|
||||
export class MenuProviderTypeWithPaths {
|
||||
export class MenuProviderTypeWithOptions {
|
||||
providerType: Type<MenuProvider>;
|
||||
paths: string[];
|
||||
}
|
||||
paths?: string[];
|
||||
childProviderTypes?: (Type<MenuProvider> | MenuProviderTypeWithOptions)[];
|
||||
|
||||
export class MenuProviderTypeWithSubs {
|
||||
providerType: Type<MenuProvider>;
|
||||
childProviderTypes: (Type<MenuProvider> | MenuProviderTypeWithPaths)[];
|
||||
}
|
||||
|
||||
export abstract class AbstractMenuProvider implements MenuProvider {
|
||||
shouldPersistOnRouteChange = true;
|
||||
|
||||
/**
|
||||
* ID of the menu this provider is part of
|
||||
* If not set up, this will be set based on the provider class name
|
||||
*/
|
||||
menuID?: MenuID;
|
||||
|
||||
/**
|
||||
* Whether the sections of this menu should be set on the
|
||||
*/
|
||||
shouldPersistOnRouteChange = true;
|
||||
menuProviderId?: string;
|
||||
index?: number;
|
||||
activePaths?: string[];
|
||||
parentID?: string;
|
||||
isExpandable = false;
|
||||
|
||||
/**
|
||||
* Whether the menu section or top section of this provider will always be rendered as expandable and hidden when no children are present
|
||||
*/
|
||||
alwaysRenderExpandable? = false;
|
||||
|
||||
|
||||
abstract getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
|
||||
|
||||
protected concat(...sections$: Observable<PartialMenuSection[]>[]): Observable<PartialMenuSection[]> {
|
||||
return combineLatest(sections$).pipe(
|
||||
map(sections => flatten(sections)),
|
||||
);
|
||||
}
|
||||
|
||||
public static onRoute(...paths: string[]) {
|
||||
public static onRoute(...paths: string[]): MenuProviderTypeWithOptions {
|
||||
if (!AbstractMenuProvider.isPrototypeOf(this)) {
|
||||
throw new Error(
|
||||
'onRoute should only be called from concrete subclasses of AbstractMenuProvider'
|
||||
@@ -87,6 +75,29 @@ export abstract class AbstractMenuProvider implements MenuProvider {
|
||||
const providerType = this as unknown as Type<AbstractMenuProvider>;
|
||||
return {providerType: providerType, paths: paths};
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add sub menu providers to this top provider
|
||||
* @param childProviders - the list of sub providers that will provide subsections for this provider
|
||||
*/
|
||||
public static withSubs(childProviders: (Type<MenuProvider> | MenuProviderTypeWithOptions)[]): MenuProviderTypeWithOptions {
|
||||
if (!AbstractMenuProvider.isPrototypeOf(this)) {
|
||||
throw new Error(
|
||||
'withSubs should only be called from concrete subclasses of AbstractMenuProvider'
|
||||
);
|
||||
}
|
||||
|
||||
const providerType = this as unknown as Type<AbstractMenuProvider>;
|
||||
return {providerType: providerType, childProviderTypes: childProviders};
|
||||
}
|
||||
|
||||
abstract getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
|
||||
|
||||
protected concat(...sections$: Observable<PartialMenuSection[]>[]): Observable<PartialMenuSection[]> {
|
||||
return combineLatest(sections$).pipe(
|
||||
map(sections => flatten(sections)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -80,5 +80,5 @@ export interface MenuSection {
|
||||
*/
|
||||
icon?: string;
|
||||
|
||||
isExpandable?: boolean;
|
||||
alwaysRenderExpandable?: boolean;
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { Router } from '@angular/router';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
|
@@ -15,6 +15,8 @@ import { AuthorizationDataService } from '../../core/data/feature-authorization/
|
||||
import { createSuccessfulRemoteDataObject } from '../remote-data.utils';
|
||||
import { ThemeService } from '../theme-support/theme.service';
|
||||
import { getMockThemeService } from '../mocks/theme-service.mock';
|
||||
import { MenuItemType } from './menu-item-type.model';
|
||||
import { TextMenuItemModel } from './menu-item/models/text.model';
|
||||
|
||||
describe('MenuComponent', () => {
|
||||
let comp: MenuComponent;
|
||||
@@ -22,6 +24,16 @@ describe('MenuComponent', () => {
|
||||
let menuService: MenuService;
|
||||
let router: any;
|
||||
|
||||
const menuSection: MenuSection = {
|
||||
id: 'browse',
|
||||
model: {
|
||||
type: MenuItemType.TEXT,
|
||||
text: 'menu.section.browse_global',
|
||||
} as TextMenuItemModel,
|
||||
icon: 'globe',
|
||||
visible: true,
|
||||
}
|
||||
|
||||
const mockMenuID = 'mock-menuID' as MenuID;
|
||||
|
||||
const mockStatisticSection = { 'id': 'statistics_site', 'active': true, 'visible': true, 'index': 2, 'type': 'statistics', 'model': { 'type': 1, 'text': 'menu.section.statistics', 'link': 'statistics' } };
|
||||
@@ -76,7 +88,7 @@ describe('MenuComponent', () => {
|
||||
comp.menuID = mockMenuID;
|
||||
menuService = (comp as any).menuService;
|
||||
router = TestBed.inject(Router);
|
||||
spyOn(comp as any, 'getSectionDataInjector').and.returnValue(MenuSection);
|
||||
spyOn(comp as any, 'getSectionDataInjector').and.returnValue(menuSection);
|
||||
spyOn(comp as any, 'getSectionComponent').and.returnValue(observableOf({}));
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -218,7 +218,7 @@ export class MenuComponent implements OnInit, OnDestroy {
|
||||
private getSectionComponent(section: MenuSection): Observable<GenericConstructor<AbstractMenuSectionComponent>> {
|
||||
return this.menuService.hasSubSections(this.menuID, section.id).pipe(
|
||||
map((expandable: boolean) => {
|
||||
return getComponentForMenu(this.menuID, expandable || section.isExpandable, this.themeService.getThemeName());
|
||||
return getComponentForMenu(this.menuID, expandable || section.alwaysRenderExpandable, this.themeService.getThemeName());
|
||||
}
|
||||
),
|
||||
);
|
||||
|
@@ -5,17 +5,10 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import {
|
||||
inject,
|
||||
Type,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AbstractMenuProvider } from './menu-provider';
|
||||
import { MenuProviderService } from './menu-provider.service';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// export function resolveStaticMenus(): (ActivatedRouteSnapshot, RouterStateSnapshot, ProviderMenuService) => Observable<boolean> {
|
||||
// return (
|
||||
|
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
|
||||
import { AppState, keySelector } from '../../app.reducer';
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { filter, map, switchMap, take } from 'rxjs/operators';
|
||||
import {
|
||||
ActivateMenuSectionAction,
|
||||
AddMenuSectionAction,
|
||||
|
@@ -5,48 +5,22 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import {
|
||||
InjectionToken,
|
||||
Provider,
|
||||
Type,
|
||||
} from '@angular/core';
|
||||
import { InjectionToken, Provider, Type, } from '@angular/core';
|
||||
import { MenuID } from './menu-id.model';
|
||||
import { AbstractMenuProvider } from './menu-provider';
|
||||
import { AbstractMenuProvider, MenuProviderTypeWithOptions } from './menu-provider';
|
||||
import { MenuProviderService } from './menu-provider.service';
|
||||
import { hasValue, isNotEmpty } from '../empty.util';
|
||||
|
||||
export const MENU_PROVIDER = new InjectionToken<AbstractMenuProvider>('MENU_PROVIDER');
|
||||
|
||||
type MenuStructure = {
|
||||
[key in MenuID]: (Type<AbstractMenuProvider> | {providerType: Type<AbstractMenuProvider>, paths: string[]} | {providerType: Type<AbstractMenuProvider>, childProviderTypes: any[]})[];
|
||||
[key in MenuID]: (Type<AbstractMenuProvider> | MenuProviderTypeWithOptions)[];
|
||||
};
|
||||
|
||||
function resolveProvider(providerType: Type<AbstractMenuProvider> , menuID: string, index: number, paths?: string[], parentID?: string, childProviders? : Type<AbstractMenuProvider>[]) {
|
||||
return {
|
||||
provide: MENU_PROVIDER,
|
||||
multi: true,
|
||||
useFactory(provider: AbstractMenuProvider): AbstractMenuProvider {
|
||||
provider.menuID = menuID as MenuID;
|
||||
provider.index = provider.index ?? index;
|
||||
if (hasValue(parentID)) {
|
||||
provider.menuProviderId = `${parentID}_${provider.constructor.name}-${provider.index}`
|
||||
provider.parentID = parentID;
|
||||
} else {
|
||||
provider.menuProviderId = `${provider.constructor.name}-${provider.index}`;
|
||||
}
|
||||
if (isNotEmpty(paths)) {
|
||||
provider.activePaths = paths;
|
||||
provider.shouldPersistOnRouteChange = false;
|
||||
}
|
||||
if (isNotEmpty(childProviders)) {
|
||||
provider.shouldPersistOnRouteChange = false;
|
||||
}
|
||||
return provider;
|
||||
},
|
||||
deps: [providerType],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the menu structure by converting the provider types into resolved providers
|
||||
* @param structure - The app menus structure
|
||||
*/
|
||||
export function buildMenuStructure(structure: MenuStructure): Provider[] {
|
||||
const providers: Provider[] = [
|
||||
MenuProviderService,
|
||||
@@ -54,44 +28,77 @@ export function buildMenuStructure(structure: MenuStructure): Provider[] {
|
||||
|
||||
Object.entries(structure).forEach(([menuID, providerTypes]) => {
|
||||
for (const [index, providerType] of providerTypes.entries()) {
|
||||
// todo: should complain if not injectable!
|
||||
|
||||
if (providerType.hasOwnProperty('providerType') && providerType.hasOwnProperty('paths')) {
|
||||
const providerPart = (providerType as any).providerType;
|
||||
const paths = (providerType as any).paths;
|
||||
providers.push(providerPart);
|
||||
providers.push(resolveProvider(providerPart, menuID, index, paths));
|
||||
} else if (providerType.hasOwnProperty('providerType') && providerType.hasOwnProperty('childProviderTypes')){
|
||||
const providerPart = (providerType as any).providerType;
|
||||
|
||||
const childProviderList = [];
|
||||
const childProviderTypes = (providerType as any).childProviderTypes;
|
||||
childProviderTypes.forEach((childProviderType, childIndex: number) => {
|
||||
|
||||
|
||||
if (childProviderType.hasOwnProperty('providerType') && childProviderType.hasOwnProperty('paths')) {
|
||||
const childProviderTypePart = (childProviderType as any).providerType;
|
||||
const paths = (childProviderType as any).paths;
|
||||
providers.push(childProviderTypePart);
|
||||
providers.push(resolveProvider(childProviderTypePart, menuID, childIndex, paths, `${providerPart.name}-${index}`))
|
||||
childProviderList.push(childProviderTypePart);
|
||||
} else {
|
||||
providers.push(childProviderType)
|
||||
providers.push(resolveProvider(childProviderType, menuID, childIndex, undefined, `${providerPart.name}-${index}`))
|
||||
childProviderList.push(childProviderType);
|
||||
}
|
||||
})
|
||||
|
||||
providers.push(providerPart);
|
||||
providers.push(resolveProvider(providerPart, menuID, index, undefined, undefined, childProviderList));
|
||||
|
||||
|
||||
} else {
|
||||
providers.push(providerType as Type<AbstractMenuProvider> );
|
||||
providers.push(resolveProvider(providerType as Type<AbstractMenuProvider>, menuID, index));
|
||||
}
|
||||
processProviderType(providers, menuID, providerType, index);
|
||||
}
|
||||
});
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a single provider type and add it to the list of providers
|
||||
* When the provider type contains paths, the paths will be added to resolved provider
|
||||
* When the provider type has sub provider, the sub providers will be processed with the current provider type as parent
|
||||
* @param providers - The list of providers
|
||||
* @param providerType - The provider to resolve and add to the list
|
||||
* @param menuID - The ID of the menu to which the provider belongs
|
||||
* @param index - The index of the provider
|
||||
* @param parentID - The ID of the parent provider if relevant
|
||||
* @param hasSubProviders - Whether this provider has sub providers
|
||||
*/
|
||||
function processProviderType(providers: Provider[], menuID: string, providerType: Type<AbstractMenuProvider> | MenuProviderTypeWithOptions, index: number, parentID?: string, hasSubProviders?: boolean) {
|
||||
if (providerType.hasOwnProperty('providerType') && providerType.hasOwnProperty('childProviderTypes')) {
|
||||
const providerPart = (providerType as any).providerType;
|
||||
const childProviderTypes = (providerType as any).childProviderTypes;
|
||||
|
||||
childProviderTypes.forEach((childProviderType, childIndex: number) => {
|
||||
processProviderType(providers, menuID, childProviderType, childIndex, `${providerPart.name}`, hasSubProviders);
|
||||
});
|
||||
processProviderType(providers, menuID, providerPart, index, parentID, true);
|
||||
|
||||
} else if (providerType.hasOwnProperty('providerType') && providerType.hasOwnProperty('paths')) {
|
||||
const providerPart = (providerType as any).providerType;
|
||||
const paths = (providerType as any).paths;
|
||||
addProviderToList(providers, providerPart, menuID, index, parentID, hasSubProviders, paths);
|
||||
} else {
|
||||
addProviderToList(providers, providerType as Type<AbstractMenuProvider>, menuID, index, parentID, hasSubProviders);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves and adds a provider to a list of providers
|
||||
* @param providers - The list of providers
|
||||
* @param providerType - The provider to resolve and add to the list
|
||||
* @param menuID - The ID of the menu to which the provider belongs
|
||||
* @param index - The index of the provider
|
||||
* @param parentID - The ID of the parent provider if relevant
|
||||
* @param hasSubProviders - Whether this provider has sub providers
|
||||
* @param paths - The paths this provider should be active on if relevant
|
||||
*/
|
||||
function addProviderToList(providers: Provider[], providerType: Type<AbstractMenuProvider>, menuID: string, index: number, parentID?: string, hasSubProviders?: boolean, paths?: string[]) {
|
||||
const resolvedProvider = {
|
||||
provide: MENU_PROVIDER,
|
||||
multi: true,
|
||||
useFactory(provider: AbstractMenuProvider): AbstractMenuProvider {
|
||||
provider.menuID = menuID as MenuID;
|
||||
provider.index = provider.index ?? index;
|
||||
if (hasValue(parentID)) {
|
||||
provider.menuProviderId = `${parentID}_${provider.constructor.name}`;
|
||||
provider.parentID = parentID;
|
||||
} else {
|
||||
provider.menuProviderId = `${provider.constructor.name}`;
|
||||
}
|
||||
if (isNotEmpty(paths)) {
|
||||
provider.activePaths = paths;
|
||||
provider.shouldPersistOnRouteChange = false;
|
||||
}
|
||||
if (hasSubProviders) {
|
||||
provider.shouldPersistOnRouteChange = false;
|
||||
}
|
||||
return provider;
|
||||
},
|
||||
deps: [providerType],
|
||||
};
|
||||
providers.push(resolvedProvider);
|
||||
providers.push(providerType);
|
||||
}
|
||||
|
@@ -8,24 +8,17 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest as observableCombineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest as observableCombineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class AccessControlMenuProvider extends AbstractExpandableMenuProvider {
|
||||
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected scriptDataService: ScriptDataService,
|
||||
@@ -34,17 +27,18 @@ export class AccessControlMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf({
|
||||
model: {
|
||||
type: MenuItemType.TEXT,
|
||||
text: 'menu.section.access_control',
|
||||
},
|
||||
icon: 'key'
|
||||
model: {
|
||||
type: MenuItemType.TEXT,
|
||||
text: 'menu.section.access_control',
|
||||
},
|
||||
icon: 'key',
|
||||
visible: true,
|
||||
});
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return observableCombineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||
this.authorizationService.isAuthorized(FeatureID.CanManageGroups),
|
||||
@@ -87,7 +81,7 @@ export class AccessControlMenuProvider extends AbstractExpandableMenuProvider {
|
||||
// link: ''
|
||||
// } as LinkMenuItemModel,
|
||||
// },
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class AdminSearchMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -7,10 +7,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { Observable, of as observableOf, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { BrowseService } from '../../../core/browse/browse.service';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||
@@ -19,11 +16,8 @@ import { BrowseDefinition } from '../../../core/shared/browse-definition.model';
|
||||
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { TextMenuItemModel } from '../menu-item/models/text.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class BrowseMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -33,7 +27,7 @@ export class BrowseMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
getTopSection(): Observable<MenuTopSection> {
|
||||
getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -41,11 +35,12 @@ export class BrowseMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.browse_global',
|
||||
} as TextMenuItemModel,
|
||||
icon: 'globe',
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
getSubSections(): Observable<MenuSubSection[]> {
|
||||
getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return this.browseService.getBrowseDefinitions().pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
map((rd: RemoteData<PaginatedList<BrowseDefinition>>) => {
|
||||
@@ -60,7 +55,7 @@ export class BrowseMenuProvider extends AbstractExpandableMenuProvider {
|
||||
},
|
||||
};
|
||||
}),
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -7,40 +7,27 @@
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { COLLECTION } from '../../../core/shared/collection.resource-type';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { COMMUNITY } from '../../../core/shared/community.resource-type';
|
||||
import { SubscriptionModalComponent } from '../../subscriptions/subscription-modal/subscription-modal.component';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { OnClickMenuItemModel } from '../menu-item/models/onclick.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
|
||||
@Injectable()
|
||||
export class SubscribeMenuProvider extends DSpaceObjectPageMenuProvider<Community | Collection> {
|
||||
export class SubscribeMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected modalService: NgbModal,
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
super();
|
||||
}
|
||||
|
||||
// protected isApplicable(dso: Community | Collection): boolean {
|
||||
// // @ts-ignore
|
||||
// return dso?.type === COMMUNITY.value || dso?.type === COLLECTION.value;
|
||||
// }
|
||||
|
||||
public getSectionsForContext(dso: Community | Collection): Observable<PartialMenuSection[]> {
|
||||
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
|
||||
return combineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.CanSubscribe, dso.self),
|
||||
]).pipe(
|
||||
|
@@ -7,15 +7,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Observable,
|
||||
of,
|
||||
} from 'rxjs';
|
||||
import { Observable, of, } from 'rxjs';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractMenuProvider,
|
||||
PartialMenuSection,
|
||||
} from '../menu-provider';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class CommunityListMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -7,19 +7,12 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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 { LinkMenuItemModel } from '../menu-item/models/link.model';
|
||||
import {
|
||||
AbstractMenuProvider,
|
||||
PartialMenuSection,
|
||||
} from '../menu-provider';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class CurationMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -6,13 +6,9 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getDSORoute } from '../../../app-routing-paths';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
@@ -20,15 +16,14 @@ import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { LinkMenuItemModel } from '../menu-item/models/link.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
|
||||
@Injectable()
|
||||
export class DSpaceObjectEditMenuProvider extends DSpaceObjectPageMenuProvider<DSpaceObject> {
|
||||
export class DSpaceObjectEditMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
constructor(
|
||||
protected authorizationDataService: AuthorizationDataService,
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
super();
|
||||
}
|
||||
|
||||
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
|
||||
|
@@ -9,21 +9,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of, } from 'rxjs';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { AbstractExpandableParentMenuProvider } from './expandable-parent-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
import { DSpaceObject } from 'src/app/core/shared/dspace-object.model';
|
||||
import { hasValue } from '../../empty.util';
|
||||
|
||||
@Injectable()
|
||||
export class DsoOptionMenu extends AbstractExpandableParentMenuProvider {
|
||||
export class DsoOptionMenu extends DSpaceObjectPageMenuProvider {
|
||||
|
||||
public getSections(): Observable<PartialMenuSection[]> {
|
||||
alwaysRenderExpandable = true;
|
||||
|
||||
protected isApplicable(dso: DSpaceObject): boolean {
|
||||
return hasValue(dso);
|
||||
}
|
||||
|
||||
getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
|
||||
return of([
|
||||
{
|
||||
visible: true,
|
||||
model: {
|
||||
type: MenuItemType.TEXT,
|
||||
text: `menu.section.browse_global_communities_and_collections`,
|
||||
text: this.getDsoType(dso) + '.page.options',
|
||||
},
|
||||
icon: 'diagram-project'
|
||||
icon: 'ellipsis-vertical'
|
||||
},
|
||||
] as PartialMenuSection[]);
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* 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 {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||
import { AbstractRouteContextMenuProvider } from './route-context.menu';
|
||||
|
||||
export abstract class DSpaceObjectPageMenuProvider<T extends DSpaceObject> extends AbstractRouteContextMenuProvider<T> {
|
||||
allRoutes = false;
|
||||
|
||||
protected constructor(
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T | undefined> {
|
||||
// todo: would be cool to automatically switch to cached version of specific DSO
|
||||
// ...but we can't really know which is which because the other resolver may run _after_
|
||||
// we could refactor the resolver to a function though; then it's less problematic to just call it here
|
||||
return this.dsoDataService.findById(route.params.id, true, false).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((dsoRD) => {
|
||||
if (dsoRD.hasSucceeded) {
|
||||
return dsoRD.payload as T;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the dso or entity type for an object to be used in generic messages
|
||||
*/
|
||||
protected getDsoType(dso: T) {
|
||||
const renderType = dso.getRenderTypes()[0];
|
||||
if (typeof renderType === 'string' || renderType instanceof String) {
|
||||
return renderType.toLowerCase();
|
||||
} else {
|
||||
return dso.type.toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,23 +8,21 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ThemedEditCollectionSelectorComponent } from '../../dso-selector/modal-wrappers/edit-collection-selector/themed-edit-collection-selector.component';
|
||||
import { ThemedEditCommunitySelectorComponent } from '../../dso-selector/modal-wrappers/edit-community-selector/themed-edit-community-selector.component';
|
||||
import { ThemedEditItemSelectorComponent } from '../../dso-selector/modal-wrappers/edit-item-selector/themed-edit-item-selector.component';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
ThemedEditCollectionSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/edit-collection-selector/themed-edit-collection-selector.component';
|
||||
import {
|
||||
ThemedEditCommunitySelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/edit-community-selector/themed-edit-community-selector.component';
|
||||
import {
|
||||
ThemedEditItemSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/edit-item-selector/themed-edit-item-selector.component';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class EditMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -35,7 +33,7 @@ export class EditMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -43,11 +41,12 @@ export class EditMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.edit',
|
||||
},
|
||||
icon: 'pencil',
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return combineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
|
||||
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
|
||||
@@ -85,7 +84,7 @@ export class EditMenuProvider extends AbstractExpandableMenuProvider {
|
||||
},
|
||||
},
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* 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 { combineLatest, Observable, of as observableOf, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
AbstractMenuProvider,
|
||||
MenuProvider,
|
||||
MenuProviderTypeWithPaths,
|
||||
MenuProviderTypeWithSubs,
|
||||
} from '../menu-provider';
|
||||
import { Inject, Injector, Optional, Type } from '@angular/core';
|
||||
import { AbstractExpandableMenuProvider, MenuSubSection } from './expandable-menu-provider';
|
||||
import { ActivatedRoute, ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { isEmpty } from '../../empty.util';
|
||||
import { MENU_PROVIDER } from '../menu.structure';
|
||||
import { MenuService } from '../menu.service';
|
||||
|
||||
|
||||
export abstract class AbstractExpandableParentMenuProvider extends AbstractMenuProvider {
|
||||
isExpandable = true;
|
||||
|
||||
public static withSubs(childProviders: (Type<MenuProvider>| MenuProviderTypeWithPaths)[]) {
|
||||
if (!AbstractMenuProvider.isPrototypeOf(this)) {
|
||||
throw new Error(
|
||||
'onRoute should only be called from concrete subclasses of AbstractMenuProvider'
|
||||
);
|
||||
}
|
||||
|
||||
const providerType = this as unknown as Type<AbstractMenuProvider>;
|
||||
return {providerType: providerType, childProviderTypes: childProviders};
|
||||
}
|
||||
}
|
@@ -8,26 +8,19 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest as observableCombineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest as observableCombineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { METADATA_EXPORT_SCRIPT_NAME, ScriptDataService, } from '../../../core/data/processes/script-data.service';
|
||||
import {
|
||||
METADATA_EXPORT_SCRIPT_NAME,
|
||||
ScriptDataService,
|
||||
} from '../../../core/data/processes/script-data.service';
|
||||
import { ExportBatchSelectorComponent } from '../../dso-selector/modal-wrappers/export-batch-selector/export-batch-selector.component';
|
||||
import { ExportMetadataSelectorComponent } from '../../dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
||||
ExportBatchSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/export-batch-selector/export-batch-selector.component';
|
||||
import {
|
||||
ExportMetadataSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class ExportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -39,7 +32,7 @@ export class ExportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -47,12 +40,12 @@ export class ExportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.export',
|
||||
},
|
||||
icon: 'file-export',
|
||||
shouldPersistOnRouteChange: true,
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return observableCombineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||
this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME),
|
||||
@@ -68,7 +61,6 @@ export class ExportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
this.modalService.open(ExportMetadataSelectorComponent);
|
||||
},
|
||||
},
|
||||
shouldPersistOnRouteChange: true,
|
||||
},
|
||||
{
|
||||
visible: authorized && metadataExportScriptExists,
|
||||
@@ -79,9 +71,8 @@ export class ExportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
this.modalService.open(ExportBatchSelectorComponent);
|
||||
},
|
||||
},
|
||||
shouldPersistOnRouteChange: true,
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class HealthMenuProvider extends AbstractMenuProvider {
|
||||
|
37
src/app/shared/menu/providers/helper-providers/dso.menu.ts
Normal file
37
src/app/shared/menu/providers/helper-providers/dso.menu.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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 { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { AbstractRouteContextMenuProvider } from './route-context.menu';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { hasValue } from '../../../empty.util';
|
||||
|
||||
export abstract class DSpaceObjectPageMenuProvider extends AbstractRouteContextMenuProvider<DSpaceObject> {
|
||||
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject | undefined> {
|
||||
const dsoRD: RemoteData<DSpaceObject> = route.data.dso;
|
||||
if (hasValue(dsoRD) && dsoRD.hasSucceeded && hasValue(dsoRD.payload)) {
|
||||
return of(dsoRD.payload);
|
||||
} else {
|
||||
return of(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the dso or entity type for an object to be used in generic messages
|
||||
*/
|
||||
protected getDsoType(dso: DSpaceObject) {
|
||||
const renderType = dso.getRenderTypes()[0];
|
||||
if (typeof renderType === 'string' || renderType instanceof String) {
|
||||
return renderType.toLowerCase();
|
||||
} else {
|
||||
return dso.type.toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,29 +5,18 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import { Omit } from '@material-ui/core';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, of as observableOf, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import {
|
||||
AbstractMenuProvider,
|
||||
PartialMenuSection,
|
||||
} from '../menu-provider';
|
||||
import { Type } from '@angular/core';
|
||||
|
||||
export type MenuTopSection = Omit<PartialMenuSection, 'visible'>;
|
||||
export type MenuSubSection = Omit<PartialMenuSection, 'parentID'>;
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../../menu-provider';
|
||||
|
||||
export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvider {
|
||||
protected showWithoutSubsections = false;
|
||||
|
||||
abstract getTopSection(): Observable<MenuTopSection>;
|
||||
alwaysRenderExpandable = true;
|
||||
|
||||
abstract getSubSections(): Observable<MenuSubSection[]>;
|
||||
|
||||
abstract getTopSection(): Observable<PartialMenuSection>;
|
||||
|
||||
abstract getSubSections(): Observable<PartialMenuSection[]>;
|
||||
|
||||
protected includeSubSections(): boolean {
|
||||
return true;
|
||||
@@ -41,7 +30,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
|
||||
full ? this.getSubSections() : observableOf([]),
|
||||
]).pipe(
|
||||
map((
|
||||
[partialTopSection, partialSubSections]: [MenuTopSection, MenuSubSection[]]
|
||||
[partialTopSection, partialSubSections]: [PartialMenuSection, PartialMenuSection[]]
|
||||
) => {
|
||||
const subSections = partialSubSections.map((partialSub, index) => {
|
||||
return {
|
||||
@@ -56,7 +45,6 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
|
||||
{
|
||||
...partialTopSection,
|
||||
id: this.menuProviderId,
|
||||
visible: full ? subSections.some(sub => sub.visible) : this.showWithoutSubsections,
|
||||
},
|
||||
];
|
||||
})
|
@@ -5,23 +5,14 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import {
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { switchMap, tap } from 'rxjs/operators';
|
||||
import { hasValue } from '../../empty.util';
|
||||
import {
|
||||
AbstractMenuProvider,
|
||||
PartialMenuSection,
|
||||
} from '../menu-provider';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import { Observable, of as observableOf, } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../../menu-provider';
|
||||
|
||||
export abstract class AbstractRouteContextMenuProvider<T> extends AbstractMenuProvider {
|
||||
shouldPersistOnRouteChange = false;
|
||||
|
||||
abstract getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T | undefined>;
|
||||
|
||||
abstract getSectionsForContext(routeContext: T): Observable<PartialMenuSection[]>;
|
||||
@@ -29,10 +20,8 @@ export abstract class AbstractRouteContextMenuProvider<T> extends AbstractMenuPr
|
||||
getSections(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<PartialMenuSection[]> {
|
||||
|
||||
return this.getRouteContext(route, state).pipe(
|
||||
|
||||
switchMap((routeContext: T) => {
|
||||
if (this.isApplicable(routeContext)) {
|
||||
|
||||
return this.getSectionsForContext(routeContext);
|
||||
} else {
|
||||
return observableOf([]);
|
@@ -8,24 +8,13 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest as observableCombineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest as observableCombineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import {
|
||||
METADATA_IMPORT_SCRIPT_NAME,
|
||||
ScriptDataService,
|
||||
} from '../../../core/data/processes/script-data.service';
|
||||
import { METADATA_IMPORT_SCRIPT_NAME, ScriptDataService, } from '../../../core/data/processes/script-data.service';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class ImportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -37,7 +26,7 @@ export class ImportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -45,12 +34,12 @@ export class ImportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.import',
|
||||
},
|
||||
icon: 'file-import',
|
||||
shouldPersistOnRouteChange: true,
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return observableCombineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||
this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_IMPORT_SCRIPT_NAME),
|
||||
@@ -73,7 +62,7 @@ export class ImportMenuProvider extends AbstractExpandableMenuProvider {
|
||||
link: '/admin/batch-import',
|
||||
},
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -8,12 +8,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ResearcherProfileDataService } from '../../../core/profile/researcher-profile-data.service';
|
||||
@@ -25,26 +21,28 @@ import { MenuItemType } from '../menu-item-type.model';
|
||||
import { OnClickMenuItemModel } from '../menu-item/models/onclick.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { MenuService } from '../menu.service';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
|
||||
@Injectable()
|
||||
// todo: the "Item-ness" of this class is basically unenforced though...
|
||||
export class ClaimMenuProvider extends DSpaceObjectPageMenuProvider<Item> {
|
||||
export class ClaimMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected menuService: MenuService,
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
protected translate: TranslateService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected researcherProfileService: ResearcherProfileDataService,
|
||||
protected modalService: NgbModal,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
protected isApplicable(item: Item): boolean {
|
||||
return this.getDsoType(item) === 'person';
|
||||
protected isApplicable(item: DSpaceObject): boolean {
|
||||
if (item instanceof Item) {
|
||||
return this.getDsoType(item) === 'person';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public getSectionsForContext(item: Item): Observable<PartialMenuSection[]> {
|
||||
|
@@ -6,13 +6,9 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getDSORoute } from '../../../app-routing-paths';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
@@ -20,19 +16,21 @@ import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { LinkMenuItemModel } from '../menu-item/models/link.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
|
||||
@Injectable()
|
||||
export class OrcidMenuProvider extends DSpaceObjectPageMenuProvider<Item> {
|
||||
export class OrcidMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
super();
|
||||
}
|
||||
|
||||
protected isApplicable(item: Item): boolean {
|
||||
return this.getDsoType(item) === 'person';
|
||||
if (item instanceof Item) {
|
||||
return this.getDsoType(item) === 'person';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public getSectionsForContext(item: Item): Observable<PartialMenuSection[]> {
|
||||
|
@@ -6,12 +6,8 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, Observable, } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
@@ -19,16 +15,15 @@ import { DsoVersioningModalService } from '../../dso-page/dso-versioning-modal-s
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { OnClickMenuItemModel } from '../menu-item/models/onclick.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
|
||||
@Injectable()
|
||||
export class VersioningMenuProvider extends DSpaceObjectPageMenuProvider<Item> {
|
||||
export class VersioningMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected dsoVersioningModalService: DsoVersioningModalService,
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
super();
|
||||
}
|
||||
|
||||
public getSectionsForContext(item: Item): Observable<PartialMenuSection[]> {
|
||||
|
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* 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 { Optional } from '@angular/core';
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import {
|
||||
Observable,
|
||||
of,
|
||||
} from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||
import { ItemPageResolver } from '../../../item-page/item-page.resolver';
|
||||
import { DSpaceObjectPageMenuProvider } from './dso.menu';
|
||||
|
||||
export abstract class ItemPageMenuProvider extends DSpaceObjectPageMenuProvider<Item> {
|
||||
allRoutes = false;
|
||||
|
||||
protected constructor(
|
||||
protected dsoDataService: DSpaceObjectDataService,
|
||||
@Optional() protected resolver?: ItemPageResolver,
|
||||
) {
|
||||
super(dsoDataService);
|
||||
}
|
||||
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Item | undefined> {
|
||||
if (this.resolver === null) {
|
||||
return of(undefined);
|
||||
}
|
||||
|
||||
// todo: it should be better to reuse the exact resolver that the page uses already, since the RD is guaranteed to be cached already
|
||||
return (this.resolver.resolve(route, state) as Observable<RemoteData<Item>>).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((dsoRD) => {
|
||||
if (dsoRD.hasSucceeded) {
|
||||
return dsoRD.payload;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@@ -8,24 +8,22 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ThemedCreateCollectionParentSelectorComponent } from '../../dso-selector/modal-wrappers/create-collection-parent-selector/themed-create-collection-parent-selector.component';
|
||||
import { ThemedCreateCommunityParentSelectorComponent } from '../../dso-selector/modal-wrappers/create-community-parent-selector/themed-create-community-parent-selector.component';
|
||||
import { ThemedCreateItemParentSelectorComponent } from '../../dso-selector/modal-wrappers/create-item-parent-selector/themed-create-item-parent-selector.component';
|
||||
import {
|
||||
ThemedCreateCollectionParentSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/create-collection-parent-selector/themed-create-collection-parent-selector.component';
|
||||
import {
|
||||
ThemedCreateCommunityParentSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/create-community-parent-selector/themed-create-community-parent-selector.component';
|
||||
import {
|
||||
ThemedCreateItemParentSelectorComponent
|
||||
} from '../../dso-selector/modal-wrappers/create-item-parent-selector/themed-create-item-parent-selector.component';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { TextMenuItemModel } from '../menu-item/models/text.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -36,7 +34,7 @@ export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -44,11 +42,12 @@ export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.new'
|
||||
} as TextMenuItemModel,
|
||||
icon: 'plus',
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return combineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
|
||||
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
|
||||
@@ -95,7 +94,7 @@ export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
||||
link: '/processes/new'
|
||||
},
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* 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 { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationsMenuProvider extends AbstractExpandableMenuProvider {
|
||||
constructor(
|
||||
protected authorizationService: AuthorizationDataService,
|
||||
protected scriptDataService: ScriptDataService,
|
||||
protected modalService: NgbModal,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
type: MenuItemType.TEXT,
|
||||
text: 'menu.section.notifications',
|
||||
},
|
||||
icon: 'bell',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
return combineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||
this.authorizationService.isAuthorized(FeatureID.CanSeeQA),
|
||||
]).pipe(
|
||||
map(([authorized, canSeeQA]) => {
|
||||
return [
|
||||
{
|
||||
visible: authorized && canSeeQA,
|
||||
model: {
|
||||
type: MenuItemType.LINK,
|
||||
text: 'menu.section.quality-assurance',
|
||||
link: '/admin/notifications/quality-assurance',
|
||||
},
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class ProcessesMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -8,21 +8,13 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
of as observableOf,
|
||||
} from 'rxjs';
|
||||
import { combineLatest, map, Observable, of as observableOf, } from 'rxjs';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import {
|
||||
AbstractExpandableMenuProvider,
|
||||
MenuSubSection,
|
||||
MenuTopSection,
|
||||
} from './expandable-menu-provider';
|
||||
import { AbstractExpandableMenuProvider, } from './helper-providers/expandable-menu-provider';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class RegistriesMenuProvider extends AbstractExpandableMenuProvider {
|
||||
@@ -34,7 +26,7 @@ export class RegistriesMenuProvider extends AbstractExpandableMenuProvider {
|
||||
super();
|
||||
}
|
||||
|
||||
public getTopSection(): Observable<MenuTopSection> {
|
||||
public getTopSection(): Observable<PartialMenuSection> {
|
||||
return observableOf(
|
||||
{
|
||||
model: {
|
||||
@@ -42,11 +34,12 @@ export class RegistriesMenuProvider extends AbstractExpandableMenuProvider {
|
||||
text: 'menu.section.registries',
|
||||
},
|
||||
icon: 'list',
|
||||
visible: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public getSubSections(): Observable<MenuSubSection[]> {
|
||||
public getSubSections(): Observable<PartialMenuSection[]> {
|
||||
return combineLatest([
|
||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||
]).pipe(
|
||||
@@ -68,7 +61,7 @@ export class RegistriesMenuProvider extends AbstractExpandableMenuProvider {
|
||||
link: 'admin/registries/bitstream-formats',
|
||||
},
|
||||
},
|
||||
] as MenuSubSection[];
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -7,29 +7,15 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import {
|
||||
Observable,
|
||||
of,
|
||||
} from 'rxjs';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import { Observable, of, } from 'rxjs';
|
||||
import { hasNoValue, hasValue } from '../../empty.util';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { PartialMenuSection } from '../menu-provider';
|
||||
import { AbstractRouteContextMenuProvider } from './route-context.menu';
|
||||
import { AbstractRouteContextMenuProvider } from './helper-providers/route-context.menu';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||
import { getDSORoute } from '../../../app-routing-paths';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { getItemModuleRoute, getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
||||
import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||
|
||||
interface StatisticsLink {
|
||||
id: string,
|
||||
@@ -40,9 +26,9 @@ interface StatisticsLink {
|
||||
export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSpaceObject> {
|
||||
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject> {
|
||||
|
||||
let dsoRD: RemoteData<DSpaceObject> = route.data.dso
|
||||
while (hasValue(route.parent) && hasNoValue(dsoRD) ) {
|
||||
let dsoRD: RemoteData<DSpaceObject> = route.data.dso;
|
||||
// Check if one of the parent routes has a DSO
|
||||
while (hasValue(route.parent) && hasNoValue(dsoRD)) {
|
||||
route = route.parent;
|
||||
dsoRD = route.data.dso;
|
||||
}
|
||||
@@ -52,32 +38,6 @@ export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSp
|
||||
} else {
|
||||
return of(undefined);
|
||||
}
|
||||
|
||||
// let page = state.url.split('/')[1];
|
||||
// let uuid = route.params.id;
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// // todo: wow
|
||||
// if (page === 'entities') {
|
||||
// page = 'items';
|
||||
// }
|
||||
//
|
||||
// if (['items', 'communities', 'collections'].includes(page)) {
|
||||
// while (hasValue(route.parent) && hasNoValue(uuid) ) {
|
||||
// route = route.parent;
|
||||
// uuid = route.params.id;
|
||||
// }
|
||||
//
|
||||
// if (hasNoValue(uuid)) {
|
||||
// return of(undefined);
|
||||
// } else {
|
||||
// return of(`statistics/${page}/${uuid}`);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return of(`statistics`);
|
||||
}
|
||||
|
||||
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
|
||||
@@ -86,29 +46,12 @@ export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSp
|
||||
|
||||
let dsoRoute;
|
||||
if (hasValue(dso)) {
|
||||
// const dsoRoute = getDSORoute(dso) todo maybe have the stats page work on entity url so we can just use the getDSORoute thing 🙄
|
||||
if (hasValue(dso)) {
|
||||
console.log('DSO',dso);
|
||||
switch ((dso as any).type) {
|
||||
case Community.type.value:
|
||||
dsoRoute = getCommunityPageRoute(dso.uuid);
|
||||
break;
|
||||
case Collection.type.value:
|
||||
dsoRoute = getCollectionPageRoute(dso.uuid);
|
||||
break;
|
||||
case Item.type.value:
|
||||
dsoRoute = new URLCombiner(getItemModuleRoute(), dso.uuid).toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dsoRoute = getDSORoute(dso);
|
||||
if (hasValue(dsoRoute)) {
|
||||
link = `statistics/${dsoRoute}`
|
||||
link = `statistics/${dsoRoute}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return of([
|
||||
{
|
||||
visible: true,
|
||||
|
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class SystemWideAlertMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
combineLatest,
|
||||
map,
|
||||
Observable,
|
||||
} from 'rxjs';
|
||||
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';
|
||||
import { AbstractMenuProvider, PartialMenuSection, } from '../menu-provider';
|
||||
|
||||
@Injectable()
|
||||
export class WorkflowMenuProvider extends AbstractMenuProvider {
|
||||
|
@@ -11,6 +11,7 @@ import { ThemedItemStatisticsPageComponent } from './item-statistics-page/themed
|
||||
import { ThemedSiteStatisticsPageComponent } from './site-statistics-page/themed-site-statistics-page.component';
|
||||
import { ItemResolver } from '../item-page/item.resolver';
|
||||
import { StatisticsAdministratorGuard } from '../core/data/feature-authorization/feature-authorization-guard/statistics-administrator.guard';
|
||||
import { ENTITY_MODULE_PATH } from '../item-page/item-page-routing-paths';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -46,6 +47,19 @@ import { StatisticsAdministratorGuard } from '../core/data/feature-authorization
|
||||
component: ThemedItemStatisticsPageComponent,
|
||||
canActivate: [StatisticsAdministratorGuard]
|
||||
},
|
||||
{
|
||||
path: `${ENTITY_MODULE_PATH}/:entity-type/:id`,
|
||||
resolve: {
|
||||
scope: ItemResolver,
|
||||
breadcrumb: I18nBreadcrumbResolver
|
||||
},
|
||||
data: {
|
||||
title: 'statistics.title',
|
||||
breadcrumbKey: 'statistics'
|
||||
},
|
||||
component: ThemedItemStatisticsPageComponent,
|
||||
canActivate: [StatisticsAdministratorGuard]
|
||||
},
|
||||
{
|
||||
path: `collections/:id`,
|
||||
resolve: {
|
||||
|
@@ -2854,36 +2854,8 @@
|
||||
|
||||
"menu.section.export_batch": "Batch Export (ZIP)",
|
||||
|
||||
"menu.section.icon.access_control": "Access Control menu section",
|
||||
|
||||
"menu.section.icon.admin_search": "Admin search menu section",
|
||||
|
||||
"menu.section.icon.control_panel": "Control Panel menu section",
|
||||
|
||||
"menu.section.icon.curation_tasks": "Curation Task menu section",
|
||||
|
||||
"menu.section.icon.edit": "Edit menu section",
|
||||
|
||||
"menu.section.icon.export": "Export menu section",
|
||||
|
||||
"menu.section.icon.find": "Find menu section",
|
||||
|
||||
"menu.section.icon.health": "Health check menu section",
|
||||
|
||||
"menu.section.icon.import": "Import menu section",
|
||||
|
||||
"menu.section.icon.new": "New menu section",
|
||||
|
||||
"menu.section.icon.pin": "Pin sidebar",
|
||||
|
||||
"menu.section.icon.processes": "Processes Health",
|
||||
|
||||
"menu.section.icon.registries": "Registries menu section",
|
||||
|
||||
"menu.section.icon.statistics_task": "Statistics Task menu section",
|
||||
|
||||
"menu.section.icon.workflow": "Administer workflow menu section",
|
||||
|
||||
"menu.section.icon.unpin": "Unpin sidebar",
|
||||
|
||||
"menu.section.import": "Import",
|
||||
|
@@ -106,7 +106,7 @@ export class BrowserInitService extends InitService {
|
||||
this.initKlaro();
|
||||
|
||||
await this.authenticationReady$().toPromise();
|
||||
this.initPersistentMenus();
|
||||
this.menuProviderService.initPersistentMenus();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
Reference in New Issue
Block a user