Skip to content

Commit 98bfb54

Browse files
authored
fix: whole tablet family for tabletPage (#2054)
1 parent 66cbd6f commit 98bfb54

File tree

4 files changed

+49
-27
lines changed

4 files changed

+49
-27
lines changed

src/containers/Tablet/Tablet.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ export function Tablet() {
115115
<PageMetaWithAutorefresh items={metaItems} />
116116
<LoaderWrapper loading={loading} size="l">
117117
{error ? <ResponseError error={error} /> : null}
118-
{currentData ? <TabletContent id={id} tablet={tablet} history={history} /> : null}
118+
{currentData ? (
119+
<TabletContent id={id} tablet={tablet} history={history} database={database} />
120+
) : null}
119121
</LoaderWrapper>
120122
</Flex>
121123
);
@@ -125,10 +127,12 @@ function TabletContent({
125127
id,
126128
tablet,
127129
history,
130+
database,
128131
}: {
129132
id: string;
130133
tablet: TTabletStateInfo;
131134
history: ITabletPreparedHistoryItem[];
135+
database?: string;
132136
}) {
133137
const isEmpty = !Object.keys(tablet).length;
134138
const {Overall, HiveId, FollowerId} = tablet;
@@ -150,7 +154,7 @@ function TabletContent({
150154
<TabletControls tablet={tablet} />
151155
<TabletInfo tablet={tablet} />
152156
</Flex>
153-
<TabletTabs id={id} hiveId={HiveId} history={history} />
157+
<TabletTabs id={id} hiveId={HiveId} history={history} database={database} />
154158
</EmptyStateWrapper>
155159
);
156160
}
@@ -159,9 +163,11 @@ function TabletTabs({
159163
id,
160164
hiveId,
161165
history,
166+
database,
162167
}: {
163168
id: string;
164169
hiveId?: string;
170+
database?: string;
165171
history: ITabletPreparedHistoryItem[];
166172
}) {
167173
const [{activeTab, ...restParams}, setParams] = useQueryParams(tabletPageQueryParams);
@@ -200,7 +206,9 @@ function TabletTabs({
200206
}}
201207
/>
202208
</div>
203-
{tabletTab === 'history' ? <TabletTable history={history} /> : null}
209+
{tabletTab === 'history' ? (
210+
<TabletTable history={history} tabletId={id} database={database} />
211+
) : null}
204212
{tabletTab === 'channels' && !noAdvancedInfo ? (
205213
<Channels id={id} hiveId={hiveId} />
206214
) : null}

src/containers/Tablet/components/TabletTable/TabletTable.tsx

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import type {Column} from '@gravity-ui/react-data-table';
24
import DataTable from '@gravity-ui/react-data-table';
35

@@ -6,12 +8,16 @@ import {InternalLink} from '../../../../components/InternalLink/InternalLink';
68
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
79
import {TabletState} from '../../../../components/TabletState/TabletState';
810
import {TabletUptime} from '../../../../components/UptimeViewer/UptimeViewer';
11+
import {getTabletPagePath} from '../../../../routes';
912
import type {ITabletPreparedHistoryItem} from '../../../../types/store/tablet';
1013
import {getDefaultNodePath} from '../../../Node/NodePages';
1114

1215
const TABLET_COLUMNS_WIDTH_LS_KEY = 'tabletTableColumnsWidth';
1316

14-
const columns: Column<ITabletPreparedHistoryItem>[] = [
17+
const getColumns: (props: {
18+
database?: string;
19+
tabletId: string;
20+
}) => Column<ITabletPreparedHistoryItem>[] = ({database, tabletId}) => [
1521
{
1622
name: 'Generation',
1723
align: DataTable.RIGHT,
@@ -32,10 +38,15 @@ const columns: Column<ITabletPreparedHistoryItem>[] = [
3238
render: ({row}) => <TabletState state={row.state} />,
3339
},
3440
{
35-
name: 'Follower ID',
41+
name: 'Tablet',
3642
sortable: false,
3743
render: ({row}) => {
38-
return row.leader ? 'leader' : row.followerId;
44+
const tabletPath = getTabletPagePath(tabletId, {
45+
database,
46+
followerId: row.leader ? undefined : row.followerId?.toString(),
47+
});
48+
const tabletName = `${tabletId}${row.followerId ? `.${row.followerId}` : ''}`;
49+
return <InternalLink to={tabletPath}>{tabletName}</InternalLink>;
3950
},
4051
},
4152
{
@@ -61,13 +72,20 @@ const columns: Column<ITabletPreparedHistoryItem>[] = [
6172

6273
const TABLE_SETTINGS = {
6374
displayIndices: false,
75+
highlightRows: true,
6476
};
6577

6678
interface TabletTableProps {
6779
history: ITabletPreparedHistoryItem[];
80+
database?: string;
81+
tabletId: string;
6882
}
6983

70-
export const TabletTable = ({history}: TabletTableProps) => {
84+
export const TabletTable = ({history, database, tabletId}: TabletTableProps) => {
85+
const columns = React.useMemo(() => {
86+
return getColumns({database, tabletId});
87+
}, [database, tabletId]);
88+
7189
return (
7290
<ResizeableDataTable
7391
columnsWidthLSKey={TABLET_COLUMNS_WIDTH_LS_KEY}

src/services/api/viewer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,15 @@ export class ViewerAPI extends BaseYdbAPI {
280280
}
281281

282282
getTablet(
283-
{id, database}: {id: string; database?: string},
283+
{id, database, followerId}: {id: string; database?: string; followerId?: string},
284284
{concurrentId, signal}: AxiosOptions = {},
285285
) {
286286
return this.get<TEvTabletStateResponse>(
287287
this.getPath('/viewer/json/tabletinfo'),
288288
{
289289
enums: true,
290290
database,
291-
filter: `(TabletId=${id})`,
291+
filter: `(TabletId=${id};FollowerId=${followerId || 0})`,
292292
},
293293
{
294294
concurrentId,
@@ -307,7 +307,7 @@ export class ViewerAPI extends BaseYdbAPI {
307307
enums: true,
308308
merge: false,
309309
database,
310-
filter: `(TabletId=${id})`,
310+
filter: `(TabletId=${id};State!=Dead)`,
311311
},
312312
{
313313
concurrentId,

src/store/reducers/tablet.ts

+13-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const tabletApi = api.injectEndpoints({
1717
) => {
1818
try {
1919
const [tabletResponseData, historyResponseData, nodesList] = await Promise.all([
20-
window.api.viewer.getTablet({id, database}, {signal}),
20+
window.api.viewer.getTablet({id, database, followerId}, {signal}),
2121
window.api.viewer.getTabletHistory({id, database}, {signal}),
2222
window.api.viewer.getNodesList({signal}),
2323
]);
@@ -27,29 +27,25 @@ export const tabletApi = api.injectEndpoints({
2727
ITabletPreparedHistoryItem[]
2828
>((list, nodeId) => {
2929
const tabletInfo = historyResponseData[nodeId]?.TabletStateInfo;
30-
if (tabletInfo && tabletInfo.length) {
31-
const leaderTablet = tabletInfo.find((t) => t.Leader) || tabletInfo[0];
3230

33-
const {ChangeTime, Generation, State, Leader, FollowerId} =
34-
leaderTablet;
31+
tabletInfo?.forEach((tablet) => {
32+
const {ChangeTime, Generation, State, Leader, FollowerId} = tablet;
3533

3634
const fqdn =
3735
nodeHostsMap && nodeId
3836
? nodeHostsMap.get(Number(nodeId))?.Host
3937
: undefined;
4038

41-
if (State !== 'Dead') {
42-
list.push({
43-
nodeId,
44-
generation: Generation,
45-
changeTime: ChangeTime,
46-
state: State,
47-
leader: Leader,
48-
followerId: FollowerId,
49-
fqdn,
50-
});
51-
}
52-
}
39+
list.push({
40+
nodeId,
41+
generation: Generation,
42+
changeTime: ChangeTime,
43+
state: State,
44+
leader: Leader,
45+
followerId: FollowerId,
46+
fqdn,
47+
});
48+
});
5349
return list;
5450
}, []);
5551

0 commit comments

Comments
 (0)