forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nav_tabs.tsx
79 lines (72 loc) · 2.29 KB
/
nav_tabs.tsx
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
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { omit } from 'lodash/fp';
import * as i18n from './translations';
import { HostsTableType } from '../store/model';
import type { HostsNavTab } from './navigation/types';
import { HOSTS_PATH } from '../../../../common/constants';
const getTabsOnHostsUrl = (tabName: HostsTableType) => `${HOSTS_PATH}/${tabName}`;
export const navTabsHosts = ({
hasMlUserPermissions,
isRiskyHostsEnabled,
isEnterprise,
}: {
hasMlUserPermissions: boolean;
isRiskyHostsEnabled: boolean;
isEnterprise?: boolean;
}): HostsNavTab => {
const hiddenTabs = [];
const hostsNavTabs = {
[HostsTableType.hosts]: {
id: HostsTableType.hosts,
name: i18n.NAVIGATION_ALL_HOSTS_TITLE,
href: getTabsOnHostsUrl(HostsTableType.hosts),
disabled: false,
},
[HostsTableType.uncommonProcesses]: {
id: HostsTableType.uncommonProcesses,
name: i18n.NAVIGATION_UNCOMMON_PROCESSES_TITLE,
href: getTabsOnHostsUrl(HostsTableType.uncommonProcesses),
disabled: false,
},
[HostsTableType.anomalies]: {
id: HostsTableType.anomalies,
name: i18n.NAVIGATION_ANOMALIES_TITLE,
href: getTabsOnHostsUrl(HostsTableType.anomalies),
disabled: false,
},
[HostsTableType.events]: {
id: HostsTableType.events,
name: i18n.NAVIGATION_EVENTS_TITLE,
href: getTabsOnHostsUrl(HostsTableType.events),
disabled: false,
},
[HostsTableType.risk]: {
id: HostsTableType.risk,
name: i18n.NAVIGATION_HOST_RISK_TITLE,
href: getTabsOnHostsUrl(HostsTableType.risk),
disabled: false,
},
[HostsTableType.sessions]: {
id: HostsTableType.sessions,
name: i18n.NAVIGATION_SESSIONS_TITLE,
href: getTabsOnHostsUrl(HostsTableType.sessions),
disabled: false,
isBeta: false,
},
};
if (!hasMlUserPermissions) {
hiddenTabs.push(HostsTableType.anomalies);
}
if (!isRiskyHostsEnabled) {
hiddenTabs.push(HostsTableType.risk);
}
if (!isEnterprise) {
hiddenTabs.push(HostsTableType.sessions);
}
return omit(hiddenTabs, hostsNavTabs);
};