Skip to content

Commit a542dbc

Browse files
fix(Diagnostics): display nodes tab for not db entities
1 parent 24c29cc commit a542dbc

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/containers/Nodes/Nodes.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import {useDispatch} from 'react-redux';
44

55
import DataTable from '@gravity-ui/react-data-table';
66

7+
import type {EPathType} from '../../types/api/schema';
8+
79
import {AccessDenied} from '../../components/Errors/403';
810
import {Illustration} from '../../components/Illustration';
911
import {Loader} from '../../components/Loader';
10-
1112
import {Search} from '../../components/Search';
1213
import {ProblemFilter} from '../../components/ProblemFilter';
1314
import {UptimeFilter} from '../../components/UptimeFIlter';
@@ -35,6 +36,8 @@ import {
3536
import {changeFilter, getSettingValue} from '../../store/reducers/settings';
3637
import {hideTooltip, showTooltip} from '../../store/reducers/tooltip';
3738

39+
import {isDatabaseEntityType} from '../Tenant/utils/schema';
40+
3841
import {getNodesColumns} from './getNodesColumns';
3942

4043
import './Nodes.scss';
@@ -48,22 +51,23 @@ interface IAdditionalNodesInfo extends Record<string, unknown> {
4851
}
4952

5053
interface NodesProps {
51-
tenantPath?: string;
54+
path?: string;
55+
type?: EPathType;
5256
className?: string;
5357
additionalNodesInfo?: IAdditionalNodesInfo;
5458
}
5559

56-
export const Nodes = ({tenantPath, className, additionalNodesInfo = {}}: NodesProps) => {
60+
export const Nodes = ({path, type, className, additionalNodesInfo = {}}: NodesProps) => {
5761
const dispatch = useDispatch();
5862

59-
const isClusterNodes = !tenantPath;
63+
const isClusterNodes = !path;
6064

6165
// Since Nodes component is used in several places,
6266
// we need to reset filters, searchValue and loading state
6367
// in nodes reducer when path changes
6468
useEffect(() => {
6569
dispatch(resetNodesState());
66-
}, [dispatch, tenantPath]);
70+
}, [dispatch, path]);
6771

6872
const {wasLoaded, loading, error, nodesUptimeFilter, searchValue, totalNodes} =
6973
useTypedSelector((state) => state.nodes);
@@ -77,12 +81,14 @@ export const Nodes = ({tenantPath, className, additionalNodesInfo = {}}: NodesPr
7781
);
7882

7983
const fetchNodes = useCallback(() => {
80-
if (tenantPath && !JSON.parse(useNodesEndpoint)) {
81-
dispatch(getComputeNodes(tenantPath));
84+
// For not DB entities we always use /compute endpoint instead of /nodes
85+
// since /nodes can return data only for tenants
86+
if (path && (!JSON.parse(useNodesEndpoint) || !isDatabaseEntityType(type))) {
87+
dispatch(getComputeNodes(path));
8288
} else {
83-
dispatch(getNodes({tenant: tenantPath}));
89+
dispatch(getNodes({tenant: path}));
8490
}
85-
}, [dispatch, tenantPath, useNodesEndpoint]);
91+
}, [dispatch, path, type, useNodesEndpoint]);
8692

8793
useAutofetcher(fetchNodes, [fetchNodes], isClusterNodes ? true : autorefresh);
8894

src/containers/Tenant/Diagnostics/Diagnostics.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ function Diagnostics(props: DiagnosticsProps) {
131131
case GeneralPagesIds.nodes: {
132132
return (
133133
<Nodes
134-
tenantPath={tenantNameString}
134+
path={currentSchemaPath}
135+
type={type}
135136
additionalNodesInfo={props.additionalNodesInfo}
136137
/>
137138
);

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ export const DATABASE_PAGES = [
8989
describe,
9090
];
9191

92-
export const TABLE_PAGES = [overview, topShards, graph, tablets, hotKeys, describe];
92+
export const TABLE_PAGES = [overview, topShards, nodes, graph, tablets, hotKeys, describe];
9393

94-
export const DIR_PAGES = [overview, topShards, describe];
94+
export const DIR_PAGES = [overview, topShards, nodes, describe];
9595

96-
export const CDC_STREAM_PAGES = [overview, consumers, partitions, describe];
97-
export const TOPIC_PAGES = [overview, consumers, partitions, describe];
96+
export const CDC_STREAM_PAGES = [overview, consumers, partitions, nodes, describe];
97+
export const TOPIC_PAGES = [overview, consumers, partitions, nodes, describe];
9898

9999
// verbose mapping to guarantee correct tabs for new path types
100100
// TS will error when a new type is added but not mapped here

0 commit comments

Comments
 (0)