Skip to content

Commit 9d198c5

Browse files
authored
feat: show developer ui links for hosts and tablets (#1017)
1 parent 291adbc commit 9d198c5

File tree

5 files changed

+70
-7
lines changed

5 files changed

+70
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.developer-ui-link {
2+
display: none;
3+
4+
&_visible {
5+
display: inline-block;
6+
}
7+
8+
.data-table__row:hover & {
9+
display: inline-block;
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {ArrowUpRightFromSquare} from '@gravity-ui/icons';
2+
import {Button, Icon} from '@gravity-ui/uikit';
3+
4+
import {cn} from '../../utils/cn';
5+
6+
import './DeveloperUiLink.scss';
7+
8+
const b = cn('developer-ui-link');
9+
10+
interface DeveloperUiLinkProps {
11+
className?: string;
12+
visible?: boolean;
13+
href: string;
14+
}
15+
16+
export function DeveloperUiLink({href, visible = false, className}: DeveloperUiLinkProps) {
17+
return (
18+
<Button size="s" href={href} className={b({visible}, className)} target="_blank">
19+
<Icon data={ArrowUpRightFromSquare} />
20+
</Button>
21+
);
22+
}

src/components/NodeHostWrapper/NodeHostWrapper.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {getDefaultNodePath} from '../../containers/Node/NodePages';
55
import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
66
import type {NodeAddress} from '../../types/additionalProps';
77
import {cn} from '../../utils/cn';
8+
import {createDeveloperUILinkWithNodeId} from '../../utils/developerUI/developerUI';
89
import {isUnavailableNode} from '../../utils/nodes';
910
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
1011
import {EntityStatus} from '../EntityStatus/EntityStatus';
@@ -25,15 +26,22 @@ export const NodeHostWrapper = ({node, getNodeRef}: NodeHostWrapperProps) => {
2526
}
2627

2728
const isNodeAvailable = !isUnavailableNode(node);
28-
const nodeRef = isNodeAvailable && getNodeRef ? getNodeRef(node) + 'internal' : undefined;
29+
30+
let nodeHref: string | undefined;
31+
if (getNodeRef) {
32+
nodeHref = getNodeRef(node) + 'internal';
33+
} else if (node.NodeId) {
34+
nodeHref = createDeveloperUILinkWithNodeId(node.NodeId) + 'internal';
35+
}
36+
2937
const nodePath = isNodeAvailable
3038
? getDefaultNodePath(node.NodeId, {
3139
tenantName: node.TenantName,
3240
})
3341
: undefined;
3442

35-
const additionalControls = nodeRef ? (
36-
<Button size="s" href={nodeRef} className={b('external-button')} target="_blank">
43+
const additionalControls = nodeHref ? (
44+
<Button size="s" href={nodeHref} className={b('external-button')} target="_blank">
3745
<Icon data={ArrowUpRightFromSquare} />
3846
</Button>
3947
) : null;

src/containers/Tablets/Tablets.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import {Icon, Label, Text} from '@gravity-ui/uikit';
44
import {skipToken} from '@reduxjs/toolkit/query';
55

66
import {ButtonWithConfirmDialog} from '../../components/ButtonWithConfirmDialog/ButtonWithConfirmDialog';
7+
import {DeveloperUiLink} from '../../components/DeveloperUiLink/DeveloperUiLink';
78
import {EntityStatus} from '../../components/EntityStatus/EntityStatus';
89
import {ResponseError} from '../../components/Errors/ResponseError';
910
import {InternalLink} from '../../components/InternalLink';
1011
import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable';
1112
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
1213
import routes, {createHref} from '../../routes';
14+
import {backend} from '../../store';
1315
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
1416
import {ETabletState} from '../../types/api/tablet';
1517
import type {TTabletStateInfo} from '../../types/api/tablet';
@@ -41,6 +43,7 @@ const columns: DataTableColumn<TTabletStateInfo & {fqdn?: string}>[] = [
4143
},
4244
{
4345
name: 'TabletId',
46+
width: 230,
4447
get header() {
4548
return i18n('Tablet');
4649
},
@@ -49,7 +52,17 @@ const columns: DataTableColumn<TTabletStateInfo & {fqdn?: string}>[] = [
4952
row.TabletId &&
5053
createHref(routes.tablet, {id: row.TabletId}, {nodeId: row.NodeId, type: row.Type});
5154

52-
return <InternalLink to={tabletPath}>{row.TabletId}</InternalLink>;
55+
return (
56+
<EntityStatus
57+
name={row.TabletId?.toString()}
58+
path={tabletPath}
59+
hasClipboardButton
60+
showStatus={false}
61+
additionalControls={
62+
<DeveloperUiLink href={`${backend}/tablets?TabletID=${row.TabletId}`} />
63+
}
64+
/>
65+
);
5366
},
5467
},
5568
{

src/containers/Tenant/Diagnostics/TopShards/getTopShardsColumns.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import DataTable from '@gravity-ui/react-data-table';
22
import type {Column} from '@gravity-ui/react-data-table';
33
import type {Location} from 'history';
44

5+
import {DeveloperUiLink} from '../../../../components/DeveloperUiLink/DeveloperUiLink';
6+
import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
57
import {InternalLink} from '../../../../components/InternalLink';
68
import {LinkToSchemaObject} from '../../../../components/LinkToSchemaObject/LinkToSchemaObject';
79
import {UsageLabel} from '../../../../components/UsageLabel/UsageLabel';
810
import routes, {createHref} from '../../../../routes';
11+
import {backend} from '../../../../store';
912
import {getLoadSeverityForShard} from '../../../../store/reducers/tenantOverview/topShards/utils';
1013
import type {KeyValueRow} from '../../../../types/api/query';
1114
import type {ValueOf} from '../../../../types/common';
@@ -83,9 +86,15 @@ const tabletIdColumn: Column<KeyValueRow> = {
8386
return '–';
8487
}
8588
return (
86-
<InternalLink to={createHref(routes.tablet, {id: row.TabletId})}>
87-
{row.TabletId}
88-
</InternalLink>
89+
<EntityStatus
90+
name={row.TabletId?.toString()}
91+
path={createHref(routes.tablet, {id: row.TabletId})}
92+
hasClipboardButton
93+
showStatus={false}
94+
additionalControls={
95+
<DeveloperUiLink href={`${backend}/tablets?TabletID=${row.TabletId}`} />
96+
}
97+
/>
8998
);
9099
},
91100
sortable: false,

0 commit comments

Comments
 (0)