-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathNodeEndpointsTooltipContent.tsx
More file actions
82 lines (69 loc) · 2.39 KB
/
NodeEndpointsTooltipContent.tsx
File metadata and controls
82 lines (69 loc) · 2.39 KB
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
80
81
82
import type {DefinitionListItemProps} from '@gravity-ui/uikit';
import {DefinitionList} from '@gravity-ui/uikit';
import type {TSystemStateInfo} from '../../../types/api/nodes';
import {cn} from '../../../utils/cn';
import {useIsUserAllowedToMakeChanges} from '../../../utils/hooks/useIsUserAllowedToMakeChanges';
import {LinkWithIcon} from '../../LinkWithIcon/LinkWithIcon';
import i18n from './i18n';
import './NodeEndpointsTooltipContent.scss';
const b = cn('ydb-node-endpoints-tooltip-content');
interface NodeEdpointsTooltipProps {
data?: TSystemStateInfo;
nodeHref?: string;
}
export const NodeEndpointsTooltipContent = ({data, nodeHref}: NodeEdpointsTooltipProps) => {
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
const info: (DefinitionListItemProps & {key: string})[] = [];
if (data?.Roles?.length) {
info.push({
name: i18n('field_roles'),
children: data.Roles.join(', '),
key: 'Roles',
});
}
if (data?.Tenants?.[0]) {
info.push({
name: i18n('field_database'),
children: data.Tenants[0],
key: 'Database',
});
}
if (data?.Host) {
info.push({
name: i18n('field_host'),
children: data.Host,
copyText: data.Host,
key: 'Host',
});
}
if (data?.Rack) {
info.push({name: i18n('field_rack'), children: data.Rack, key: 'Rack'});
}
if (data?.Endpoints && data.Endpoints.length) {
data.Endpoints.forEach(({Name, Address}) => {
if (Name && Address) {
info.push({name: Name, children: Address, key: Name});
}
});
}
if (isUserAllowedToMakeChanges && nodeHref) {
info.push({
name: 'Links',
children: <LinkWithIcon title={i18n('context_developer-ui')} url={nodeHref} />,
key: 'developerUi',
});
}
return (
<div className={b('list-container')}>
<DefinitionList responsive>
{info.map(({children, key, ...rest}) => {
return (
<DefinitionList.Item key={key} {...rest}>
<div className={b('definition')}>{children}</div>
</DefinitionList.Item>
);
})}
</DefinitionList>
</div>
);
};