From 665e9fc69d6df355651fe2a6f9c0452879a13a37 Mon Sep 17 00:00:00 2001 From: Elena Makarova Date: Tue, 15 Oct 2024 13:00:19 +0300 Subject: [PATCH] fix: add node fqdn and loading state --- src/containers/Cluster/Cluster.tsx | 8 +++++++- src/containers/Tablets/Tablets.tsx | 9 +++------ src/containers/Tablets/TabletsTable.tsx | 7 ++++++- src/store/reducers/cluster/cluster.ts | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/containers/Cluster/Cluster.tsx b/src/containers/Cluster/Cluster.tsx index 37ad5eaa3..e0c8c0cf3 100644 --- a/src/containers/Cluster/Cluster.tsx +++ b/src/containers/Cluster/Cluster.tsx @@ -11,6 +11,7 @@ import {InternalLink} from '../../components/InternalLink'; import routes, {getLocationObjectFromHref} from '../../routes'; import { clusterApi, + selectClusterTabletsWithFqdn, selectClusterTitle, updateDefaultClusterTab, } from '../../store/reducers/cluster/cluster'; @@ -74,6 +75,10 @@ export function Cluster({ const clusterError = error && typeof error === 'object' ? error : undefined; + const clusterTablets = useTypedSelector((state) => + selectClusterTabletsWithFqdn(state, clusterName ?? undefined), + ); + React.useEffect(() => { dispatch(setHeaderBreadcrumbs('cluster', {})); }, [dispatch]); @@ -162,7 +167,8 @@ export function Cluster({
diff --git a/src/containers/Tablets/Tablets.tsx b/src/containers/Tablets/Tablets.tsx index bdbeaf4f4..950e96e74 100644 --- a/src/containers/Tablets/Tablets.tsx +++ b/src/containers/Tablets/Tablets.tsx @@ -1,7 +1,6 @@ import {skipToken} from '@reduxjs/toolkit/query'; import {ResponseError} from '../../components/Errors/ResponseError'; -import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton'; import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets'; import type {TabletsApiRequestParams} from '../../types/store/tablets'; import {cn} from '../../utils/cn'; @@ -38,14 +37,12 @@ export function Tablets({nodeId, path, database, className}: TabletsProps) { const loading = isFetching && currentData === undefined; const tablets = useTypedSelector((state) => selectTabletsWithFqdn(state, params)); - if (loading) { - return ; - } - return (
{error ? : null} - {currentData ? : null} + {currentData || loading ? ( + + ) : null}
); } diff --git a/src/containers/Tablets/TabletsTable.tsx b/src/containers/Tablets/TabletsTable.tsx index 6129e1452..d86d8f78f 100644 --- a/src/containers/Tablets/TabletsTable.tsx +++ b/src/containers/Tablets/TabletsTable.tsx @@ -7,6 +7,7 @@ import {DeveloperUILinkButton} from '../../components/DeveloperUILinkButton/Deve import {EntityStatus} from '../../components/EntityStatus/EntityStatus'; import {InternalLink} from '../../components/InternalLink'; import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable'; +import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton'; import {TabletState} from '../../components/TabletState/TabletState'; import {getTabletPagePath} from '../../routes'; import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication'; @@ -168,9 +169,13 @@ interface TabletsTableProps { fqdn?: string; })[]; className?: string; + loading?: boolean; } -export function TabletsTable({database, tablets, className}: TabletsTableProps) { +export function TabletsTable({database, tablets, className, loading}: TabletsTableProps) { + if (loading) { + return ; + } return ( selectClusterInfo(state, clusterName), + (state: RootState) => selectNodeHostsMap(state), + (data, nodeHostsMap): (TTabletStateInfo & {fqdn?: string})[] => { + const tablets = data?.clusterData?.SystemTablets; + if (!tablets) { + return []; + } + if (!nodeHostsMap) { + return tablets; + } + return tablets.map((tablet) => { + const fqdn = tablet.NodeId === undefined ? undefined : nodeHostsMap.get(tablet.NodeId); + return {...tablet, fqdn}; + }); + }, +);