Skip to content

Commit c5b2b83

Browse files
committed
fix: add node fqdn and loading state
1 parent f6e610c commit c5b2b83

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

src/containers/Cluster/Cluster.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {InternalLink} from '../../components/InternalLink';
1111
import routes, {getLocationObjectFromHref} from '../../routes';
1212
import {
1313
clusterApi,
14+
selectClusterTabletsWithFqdn,
1415
selectClusterTitle,
1516
updateDefaultClusterTab,
1617
} from '../../store/reducers/cluster/cluster';
@@ -74,6 +75,10 @@ export function Cluster({
7475

7576
const clusterError = error && typeof error === 'object' ? error : undefined;
7677

78+
const clusterTablets = useTypedSelector((state) =>
79+
selectClusterTabletsWithFqdn(state, clusterName ?? undefined),
80+
);
81+
7782
React.useEffect(() => {
7883
dispatch(setHeaderBreadcrumbs('cluster', {}));
7984
}, [dispatch]);
@@ -162,7 +167,8 @@ export function Cluster({
162167
<div className={b('tablets')}>
163168
<div className={b('fake-block')} />
164169
<TabletsTable
165-
tablets={cluster.SystemTablets ?? []}
170+
loading={infoLoading}
171+
tablets={clusterTablets}
166172
className={b('tablets-table')}
167173
/>
168174
</div>

src/containers/Tablets/Tablets.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {skipToken} from '@reduxjs/toolkit/query';
22

33
import {ResponseError} from '../../components/Errors/ResponseError';
4-
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
54
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
65
import type {TabletsApiRequestParams} from '../../types/store/tablets';
76
import {cn} from '../../utils/cn';
@@ -38,14 +37,12 @@ export function Tablets({nodeId, path, database, className}: TabletsProps) {
3837
const loading = isFetching && currentData === undefined;
3938
const tablets = useTypedSelector((state) => selectTabletsWithFqdn(state, params));
4039

41-
if (loading) {
42-
return <TableSkeleton />;
43-
}
44-
4540
return (
4641
<div className={b(null, className)}>
4742
{error ? <ResponseError error={error} /> : null}
48-
{currentData ? <TabletsTable tablets={tablets} database={database} /> : null}
43+
{currentData || loading ? (
44+
<TabletsTable tablets={tablets} database={database} loading={loading} />
45+
) : null}
4946
</div>
5047
);
5148
}

src/containers/Tablets/TabletsTable.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {DeveloperUILinkButton} from '../../components/DeveloperUILinkButton/Deve
77
import {EntityStatus} from '../../components/EntityStatus/EntityStatus';
88
import {InternalLink} from '../../components/InternalLink';
99
import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable';
10+
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
1011
import {TabletState} from '../../components/TabletState/TabletState';
1112
import {getTabletPagePath} from '../../routes';
1213
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
@@ -166,9 +167,13 @@ interface TabletsTableProps {
166167
fqdn?: string;
167168
})[];
168169
className?: string;
170+
loading?: boolean;
169171
}
170172

171-
export function TabletsTable({database, tablets, className}: TabletsTableProps) {
173+
export function TabletsTable({database, tablets, className, loading}: TabletsTableProps) {
174+
if (loading) {
175+
return <TableSkeleton />;
176+
}
172177
return (
173178
<ResizeableDataTable
174179
wrapperClassName={className}

src/store/reducers/cluster/cluster.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {clusterTabsIds, isClusterTab} from '../../../containers/Cluster/utils';
88
import {parseTraceFields} from '../../../services/parsers/parseMetaCluster';
99
import {isClusterInfoV2} from '../../../types/api/cluster';
1010
import type {TClusterInfo} from '../../../types/api/cluster';
11+
import type {TTabletStateInfo} from '../../../types/api/tablet';
1112
import {CLUSTER_DEFAULT_TITLE, DEFAULT_CLUSTER_TAB_KEY} from '../../../utils/constants';
1213
import {isQueryErrorResponse} from '../../../utils/query';
1314
import type {RootState} from '../../defaultStore';
1415
import {api} from '../api';
16+
import {selectNodeHostsMap} from '../nodesList';
1517

1618
import type {ClusterGroupsStats, ClusterState} from './types';
1719
import {
@@ -169,3 +171,21 @@ export const selectClusterTitle = createSelector(
169171
return Name || clusterName || normalizeDomain(Domain) || CLUSTER_DEFAULT_TITLE;
170172
},
171173
);
174+
175+
export const selectClusterTabletsWithFqdn = createSelector(
176+
(state: RootState, clusterName?: string) => selectClusterInfo(state, clusterName),
177+
(state: RootState) => selectNodeHostsMap(state),
178+
(data, nodeHostsMap): (TTabletStateInfo & {fqdn?: string})[] => {
179+
const tablets = data?.clusterData?.SystemTablets;
180+
if (!tablets) {
181+
return [];
182+
}
183+
if (!nodeHostsMap) {
184+
return tablets;
185+
}
186+
return tablets.map((tablet) => {
187+
const fqdn = tablet.NodeId === undefined ? undefined : nodeHostsMap.get(tablet.NodeId);
188+
return {...tablet, fqdn};
189+
});
190+
},
191+
);

0 commit comments

Comments
 (0)