forked from cloudforet-io/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurator.ts
68 lines (59 loc) · 2.22 KB
/
configurator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { RouteConfig } from 'vue-router';
import type { FeatureConfiguratorType, FeatureMenuConfig, FeatureUiAffect } from '@/lib/config/global-config/types/type';
import type { Menu } from '@/lib/menu/config';
import { MENU_ID } from '@/lib/menu/config';
import adminAssetInventoryRoutes from '@/services/asset-inventory/routes/admin/routes';
import assetInventoryRoute from '@/services/asset-inventory/routes/routes';
class AssetInventoryConfigurator implements FeatureConfiguratorType {
private version: 'V1' | 'V2' = 'V1';
readonly uiAffect: FeatureUiAffect[] = [
{
feature: 'ALERT_MANAGER',
affects: [
{
method: 'visibleAssetAlertTab',
version: 'V2',
},
],
},
];
initialize(version: 'V1' | 'V2'): void {
this.version = version;
}
// eslint-disable-next-line class-methods-use-this
getRoutes(isAdmin?: boolean): RouteConfig | null {
return isAdmin ? adminAssetInventoryRoutes : assetInventoryRoute;
}
getMenu(): FeatureMenuConfig {
const baseMenu: Menu = {
id: MENU_ID.ASSET_INVENTORY,
needPermissionByRole: true,
subMenuList: [],
order: 4,
};
return {
menu: {
...baseMenu,
subMenuList: [
{ id: MENU_ID.CLOUD_SERVICE, needPermissionByRole: true },
{ id: MENU_ID.SERVER, needPermissionByRole: true },
{ id: MENU_ID.SECURITY, needPermissionByRole: true },
{ id: MENU_ID.METRIC_EXPLORER, needPermissionByRole: true },
{ id: MENU_ID.COLLECTOR, needPermissionByRole: true },
],
},
adminMenu: {
...baseMenu,
subMenuList: [
{ id: MENU_ID.CLOUD_SERVICE },
{ id: MENU_ID.SERVER },
{ id: MENU_ID.SECURITY },
{ id: MENU_ID.METRIC_EXPLORER },
{ id: MENU_ID.COLLECTOR },
],
},
version: this.version,
};
}
}
export default new AssetInventoryConfigurator();