feat: add route provider to setting management config

pull/4377/head
Arman Ozak 5 years ago
parent 5c49e008c8
commit 21e3d9aac5

@ -0,0 +1,42 @@
import { eLayoutType, RoutesService, SettingTabsService } from '@abp/ng.core';
import { eThemeSharedRouteNames } from '@abp/ng.theme.shared';
import { APP_INITIALIZER } from '@angular/core';
import { debounceTime, map } from 'rxjs/operators';
import { eSettingManagementRouteNames } from '../enums/route-names';
export const SETTING_MANAGEMENT_ROUTE_PROVIDERS = [
{ provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService], multi: true },
{
provide: APP_INITIALIZER,
useFactory: hideRoutes,
deps: [RoutesService, SettingTabsService],
multi: true,
},
];
export function configureRoutes(routes: RoutesService) {
return () => {
routes.add([
{
name: eSettingManagementRouteNames.Settings,
path: '/setting-management',
parentName: eThemeSharedRouteNames.Administration,
requiredPolicy: 'AbpAccount.SettingManagement',
layout: eLayoutType.application,
order: 6,
iconClass: 'fa fa-cog',
},
]);
};
}
export function hideRoutes(routes: RoutesService, tabs: SettingTabsService) {
return () => {
tabs.visible$
.pipe(
debounceTime(0),
map(nodes => !nodes.length),
)
.subscribe(invisible => routes.patch('AbpSettingManagement::Settings', { invisible }));
};
}
Loading…
Cancel
Save