Skip to content

Commit 30401fa

Browse files
feat(TenantOverview): add links to sections titles (#599)
1 parent c31d048 commit 30401fa

File tree

13 files changed

+192
-17
lines changed

13 files changed

+192
-17
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByCpu.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import {useDispatch} from 'react-redux';
22
import {useCallback} from 'react';
33

4-
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
4+
import {useAutofetcher, useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
55
import {
66
getTopNodesByCpu,
77
selectTopNodesByCpu,
88
setDataWasNotLoaded,
99
} from '../../../../../store/reducers/tenantOverview/topNodesByCpu/topNodesByCpu';
10+
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
1011
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
1112
import {getTopNodesByCpuColumns} from '../../../../Nodes/getNodesColumns';
12-
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
1313

14+
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
15+
16+
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
17+
import {getSectionTitle} from '../getSectionTitle';
1418
import i18n from '../i18n';
1519

1620
interface TopNodesByCpuProps {
@@ -21,6 +25,8 @@ interface TopNodesByCpuProps {
2125
export function TopNodesByCpu({path, additionalNodesProps}: TopNodesByCpuProps) {
2226
const dispatch = useDispatch();
2327

28+
const query = useSearchQuery();
29+
2430
const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByCpu);
2531
const {autorefresh} = useTypedSelector((state) => state.schema);
2632
const topNodes = useTypedSelector(selectTopNodesByCpu);
@@ -39,11 +45,20 @@ export function TopNodesByCpu({path, additionalNodesProps}: TopNodesByCpuProps)
3945

4046
useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
4147

48+
const title = getSectionTitle({
49+
entity: i18n('nodes'),
50+
postfix: i18n('by-pools-usage'),
51+
link: getTenantPath({
52+
...query,
53+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
54+
}),
55+
});
56+
4257
return (
4358
<TenantOverviewTableLayout
4459
data={topNodes || []}
4560
columns={columns}
46-
title="Top nodes by pools usage"
61+
title={title}
4762
loading={loading}
4863
wasLoaded={wasLoaded}
4964
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByLoad.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import {useDispatch} from 'react-redux';
22
import {useCallback} from 'react';
33

4-
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
4+
import {useAutofetcher, useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
55
import {
66
getTopNodesByLoad,
77
selectTopNodesByLoad,
88
setDataWasNotLoaded,
99
} from '../../../../../store/reducers/tenantOverview/topNodesByLoad/topNodesByLoad';
10+
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
1011
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
1112
import {getTopNodesByLoadColumns} from '../../../../Nodes/getNodesColumns';
12-
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
1313

14+
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
15+
16+
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
17+
import {getSectionTitle} from '../getSectionTitle';
1418
import i18n from '../i18n';
1519

1620
interface TopNodesByLoadProps {
@@ -21,6 +25,8 @@ interface TopNodesByLoadProps {
2125
export function TopNodesByLoad({path, additionalNodesProps}: TopNodesByLoadProps) {
2226
const dispatch = useDispatch();
2327

28+
const query = useSearchQuery();
29+
2430
const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByLoad);
2531
const {autorefresh} = useTypedSelector((state) => state.schema);
2632
const topNodes = useTypedSelector(selectTopNodesByLoad);
@@ -39,11 +45,20 @@ export function TopNodesByLoad({path, additionalNodesProps}: TopNodesByLoadProps
3945

4046
useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
4147

48+
const title = getSectionTitle({
49+
entity: i18n('nodes'),
50+
postfix: i18n('by-load'),
51+
link: getTenantPath({
52+
...query,
53+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
54+
}),
55+
});
56+
4257
return (
4358
<TenantOverviewTableLayout
4459
data={topNodes || []}
4560
columns={columns}
46-
title="Top nodes by load"
61+
title={title}
4762
loading={loading}
4863
wasLoaded={wasLoaded}
4964
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopQueries.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useHistory, useLocation} from 'react-router';
33
import {useCallback} from 'react';
44

55
import {
6+
TENANT_DIAGNOSTICS_TABS_IDS,
67
TENANT_PAGE,
78
TENANT_PAGES_IDS,
89
TENANT_QUERY_TABS_ID,
@@ -14,9 +15,13 @@ import {
1415
import {changeUserInput} from '../../../../../store/reducers/executeQuery';
1516
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
1617
import {parseQuery} from '../../../../../routes';
18+
1719
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
1820
import {getTenantOverviewTopQueriesColumns} from '../../TopQueries/getTopQueriesColumns';
21+
1922
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
23+
import {getSectionTitle} from '../getSectionTitle';
24+
import i18n from '../i18n';
2025

2126
interface TopQueriesProps {
2227
path: string;
@@ -27,6 +32,8 @@ export function TopQueries({path}: TopQueriesProps) {
2732
const location = useLocation();
2833
const history = useHistory();
2934

35+
const query = parseQuery(location);
36+
3037
const {autorefresh} = useTypedSelector((state) => state.schema);
3138

3239
const {
@@ -68,12 +75,21 @@ export function TopQueries({path}: TopQueriesProps) {
6875
[dispatch, history, location],
6976
);
7077

78+
const title = getSectionTitle({
79+
entity: i18n('queries'),
80+
postfix: i18n('by-cpu-time'),
81+
link: getTenantPath({
82+
...query,
83+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.topQueries,
84+
}),
85+
});
86+
7187
return (
7288
<TenantOverviewTableLayout
7389
data={data || []}
7490
columns={columns}
7591
onRowClick={handleRowClick}
76-
title="Top queries by cpu time"
92+
title={title}
7793
loading={loading}
7894
wasLoaded={wasLoaded}
7995
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopShards.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import {useDispatch} from 'react-redux';
22
import {useLocation} from 'react-router';
33

44
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
5+
import {parseQuery} from '../../../../../routes';
6+
57
import {
68
sendTenantOverviewTopShardsQuery,
79
setDataWasNotLoaded,
810
} from '../../../../../store/reducers/tenantOverview/topShards/tenantOverviewTopShards';
11+
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
912
import {getTopShardsColumns} from '../../TopShards/getTopShardsColumns';
13+
14+
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
15+
1016
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
17+
import {getSectionTitle} from '../getSectionTitle';
18+
import i18n from '../i18n';
1119

1220
interface TopShardsProps {
1321
path: string;
@@ -17,6 +25,8 @@ export const TopShards = ({path}: TopShardsProps) => {
1725
const dispatch = useDispatch();
1826
const location = useLocation();
1927

28+
const query = parseQuery(location);
29+
2030
const {autorefresh, currentSchemaPath} = useTypedSelector((state) => state.schema);
2131

2232
const {
@@ -39,11 +49,20 @@ export const TopShards = ({path}: TopShardsProps) => {
3949

4050
const columns = getTopShardsColumns(path, location);
4151

52+
const title = getSectionTitle({
53+
entity: i18n('shards'),
54+
postfix: i18n('by-cpu-usage'),
55+
link: getTenantPath({
56+
...query,
57+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.topShards,
58+
}),
59+
});
60+
4261
return (
4362
<TenantOverviewTableLayout
4463
data={data || []}
4564
columns={columns}
46-
title="Top shards by cpu usage"
65+
title={title}
4766
loading={loading}
4867
wasLoaded={wasLoaded}
4968
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TopNodesByMemory.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import {useDispatch} from 'react-redux';
22
import {useCallback} from 'react';
33

4-
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
4+
import {useAutofetcher, useTypedSelector, useSearchQuery} from '../../../../../utils/hooks';
55
import {
66
getTopNodesByMemory,
77
selectTopNodesByMemory,
88
setDataWasNotLoaded,
99
} from '../../../../../store/reducers/tenantOverview/topNodesByMemory/topNodesByMemory';
10+
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
1011
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
1112
import {getTopNodesByMemoryColumns} from '../../../../Nodes/getNodesColumns';
12-
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
1313

14+
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
15+
16+
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
17+
import {getSectionTitle} from '../getSectionTitle';
1418
import i18n from '../i18n';
1519

1620
interface TopNodesByMemoryProps {
@@ -21,6 +25,8 @@ interface TopNodesByMemoryProps {
2125
export function TopNodesByMemory({path, additionalNodesProps}: TopNodesByMemoryProps) {
2226
const dispatch = useDispatch();
2327

28+
const query = useSearchQuery();
29+
2430
const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByMemory);
2531
const {autorefresh} = useTypedSelector((state) => state.schema);
2632
const topNodes = useTypedSelector(selectTopNodesByMemory);
@@ -41,11 +47,20 @@ export function TopNodesByMemory({path, additionalNodesProps}: TopNodesByMemoryP
4147

4248
useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
4349

50+
const title = getSectionTitle({
51+
entity: i18n('nodes'),
52+
postfix: i18n('by-memory'),
53+
link: getTenantPath({
54+
...query,
55+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
56+
}),
57+
});
58+
4459
return (
4560
<TenantOverviewTableLayout
4661
data={topNodes || []}
4762
columns={columns}
48-
title="Top nodes by memory"
63+
title={title}
4964
loading={loading}
5065
wasLoaded={wasLoaded}
5166
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverviewTableLayout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type {ReactNode} from 'react';
12
import cn from 'bem-cn-lite';
23

34
import DataTable from '@gravity-ui/react-data-table';
@@ -14,7 +15,7 @@ import {ResponseError} from '../../../../components/Errors/ResponseError';
1415
const b = cn('tenant-overview');
1516

1617
interface TenantOverviewTableLayoutProps<T> extends Omit<DataTableProps<T>, 'theme'> {
17-
title: string;
18+
title: ReactNode;
1819
loading?: boolean;
1920
wasLoaded?: boolean;
2021
error?: IResponseError;

src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopGroups.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import {useCallback} from 'react';
22
import {useDispatch} from 'react-redux';
33

4-
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
4+
import {useAutofetcher, useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
55
import {
66
setDataWasNotLoaded,
77
getTopStorageGroups,
88
selectTopStorageGroups,
99
} from '../../../../../store/reducers/tenantOverview/topStorageGroups/topStorageGroups';
10+
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
1011
import {getStorageTopGroupsColumns} from '../../../../Storage/StorageGroups/getStorageGroupsColumns';
12+
13+
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
14+
1115
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
16+
import {getSectionTitle} from '../getSectionTitle';
17+
import i18n from '../i18n';
1218

1319
interface TopGroupsProps {
1420
tenant?: string;
@@ -17,6 +23,8 @@ interface TopGroupsProps {
1723
export function TopGroups({tenant}: TopGroupsProps) {
1824
const dispatch = useDispatch();
1925

26+
const query = useSearchQuery();
27+
2028
const {autorefresh} = useTypedSelector((state) => state.schema);
2129
const {loading, wasLoaded, error} = useTypedSelector((state) => state.topStorageGroups);
2230
const topGroups = useTypedSelector(selectTopStorageGroups);
@@ -36,11 +44,20 @@ export function TopGroups({tenant}: TopGroupsProps) {
3644

3745
useAutofetcher(fetchData, [fetchData], autorefresh);
3846

47+
const title = getSectionTitle({
48+
entity: i18n('groups'),
49+
postfix: i18n('by-usage'),
50+
link: getTenantPath({
51+
...query,
52+
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.storage,
53+
}),
54+
});
55+
3956
return (
4057
<TenantOverviewTableLayout
4158
data={topGroups || []}
4259
columns={columns}
43-
title="Top groups by usage"
60+
title={title}
4461
loading={loading}
4562
wasLoaded={wasLoaded}
4663
error={error}

src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import type {KeyValueRow} from '../../../../../types/api/query';
1212
import {formatBytes, getSizeWithSignificantDigits} from '../../../../../utils/bytesParsers';
1313
import {LinkToSchemaObject} from '../../../../../components/LinkToSchemaObject/LinkToSchemaObject';
1414
import {CellWithPopover} from '../../../../../components/CellWithPopover/CellWithPopover';
15+
1516
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
17+
import {getSectionTitle} from '../getSectionTitle';
18+
import i18n from '../i18n';
1619

1720
import '../TenantOverview.scss';
1821

@@ -72,12 +75,16 @@ export function TopTables({path}: TopTablesProps) {
7275
) : null,
7376
},
7477
];
78+
const title = getSectionTitle({
79+
entity: i18n('tables'),
80+
postfix: i18n('by-size'),
81+
});
7582

7683
return (
7784
<TenantOverviewTableLayout
7885
data={data || []}
7986
columns={columns}
80-
title="Top tables by size"
87+
title={title}
8188
loading={loading}
8289
wasLoaded={wasLoaded}
8390
error={error}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {InternalLink} from '../../../../components/InternalLink/InternalLink';
2+
3+
import i18n from './i18n';
4+
5+
interface GetSectionTitleParams {
6+
entity: string;
7+
postfix: string;
8+
prefix?: string;
9+
link?: string;
10+
}
11+
12+
// Titles are formed by the principle "Top entities by parameter"
13+
export const getSectionTitle = ({
14+
prefix = i18n('top'),
15+
entity,
16+
postfix,
17+
link,
18+
}: GetSectionTitleParams) => {
19+
if (link) {
20+
return (
21+
<>
22+
{prefix} <InternalLink to={link}>{entity}</InternalLink> {postfix}
23+
</>
24+
);
25+
}
26+
27+
return `${prefix} ${entity} ${postfix}`;
28+
};

0 commit comments

Comments
 (0)