forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nav_tabs.tsx
64 lines (57 loc) · 1.9 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
/*
* 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 { UsersTableType } from '../store/model';
import type { UsersNavTab } from './navigation/types';
import { USERS_PATH } from '../../../../common/constants';
const getTabsOnUsersUrl = (tabName: UsersTableType) => `${USERS_PATH}/${tabName}`;
export const navTabsUsers = (
hasMlUserPermissions: boolean,
isRiskyUserEnabled: boolean
): UsersNavTab => {
const hiddenTabs = [];
const userNavTabs = {
[UsersTableType.allUsers]: {
id: UsersTableType.allUsers,
name: i18n.NAVIGATION_ALL_USERS_TITLE,
href: getTabsOnUsersUrl(UsersTableType.allUsers),
disabled: false,
},
[UsersTableType.authentications]: {
id: UsersTableType.authentications,
name: i18n.NAVIGATION_AUTHENTICATIONS_TITLE,
href: getTabsOnUsersUrl(UsersTableType.authentications),
disabled: false,
},
[UsersTableType.anomalies]: {
id: UsersTableType.anomalies,
name: i18n.NAVIGATION_ANOMALIES_TITLE,
href: getTabsOnUsersUrl(UsersTableType.anomalies),
disabled: false,
},
[UsersTableType.events]: {
id: UsersTableType.events,
name: i18n.NAVIGATION_EVENTS_TITLE,
href: getTabsOnUsersUrl(UsersTableType.events),
disabled: false,
},
[UsersTableType.risk]: {
id: UsersTableType.risk,
name: i18n.NAVIGATION_RISK_TITLE,
href: getTabsOnUsersUrl(UsersTableType.risk),
disabled: false,
},
};
if (!hasMlUserPermissions) {
hiddenTabs.push(UsersTableType.anomalies);
}
if (!isRiskyUserEnabled) {
hiddenTabs.push(UsersTableType.risk);
}
return omit(hiddenTabs, userNavTabs);
};