-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathNodeHostWrapper.tsx
66 lines (57 loc) · 2.2 KB
/
NodeHostWrapper.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
import block from 'bem-cn-lite';
import {Button, Popover, PopoverBehavior} from '@gravity-ui/uikit';
import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
import type {NodeAddress} from '../../types/additionalProps';
import {getDefaultNodePath} from '../../containers/Node/NodePages';
import {isUnavailableNode} from '../../utils/nodes';
import EntityStatus from '../EntityStatus/EntityStatus';
import {NodeEndpointsTooltipContent} from '../TooltipsContent';
import {IconWrapper} from '../Icon';
import './NodeHostWrapper.scss';
const b = block('ydb-node-host-wrapper');
interface NodeHostWrapperProps {
node: NodesPreparedEntity;
getNodeRef?: (node?: NodeAddress) => string | null;
}
export const NodeHostWrapper = ({node, getNodeRef}: NodeHostWrapperProps) => {
if (!node.Host) {
return <span>—</span>;
}
const isNodeAvailable = !isUnavailableNode(node);
const nodeRef = isNodeAvailable && getNodeRef ? getNodeRef(node) + 'internal' : undefined;
const nodePath = isNodeAvailable
? getDefaultNodePath(node.NodeId, {
tenantName: node.TenantName,
})
: undefined;
return (
<div className={b()}>
<Popover
disabled={!isNodeAvailable}
content={<NodeEndpointsTooltipContent data={node} />}
placement={['top', 'bottom']}
behavior={PopoverBehavior.Immediate}
>
<div className={b('host-wrapper')}>
<EntityStatus
name={node.Host}
status={node.SystemState}
path={nodePath}
hasClipboardButton
className={b('host')}
/>
{nodeRef && (
<Button
size="s"
href={nodeRef}
className={b('external-button')}
target="_blank"
>
<IconWrapper name="external" />
</Button>
)}
</div>
</Popover>
</div>
);
};