@@ -4,10 +4,11 @@ import {useDispatch} from 'react-redux';
44
55import DataTable from '@gravity-ui/react-data-table' ;
66
7+ import type { EPathType } from '../../types/api/schema' ;
8+
79import { AccessDenied } from '../../components/Errors/403' ;
810import { Illustration } from '../../components/Illustration' ;
911import { Loader } from '../../components/Loader' ;
10-
1112import { Search } from '../../components/Search' ;
1213import { ProblemFilter } from '../../components/ProblemFilter' ;
1314import { UptimeFilter } from '../../components/UptimeFIlter' ;
@@ -35,6 +36,8 @@ import {
3536import { changeFilter , getSettingValue } from '../../store/reducers/settings' ;
3637import { hideTooltip , showTooltip } from '../../store/reducers/tooltip' ;
3738
39+ import { isDatabaseEntityType } from '../Tenant/utils/schema' ;
40+
3841import { getNodesColumns } from './getNodesColumns' ;
3942
4043import './Nodes.scss' ;
@@ -48,22 +51,23 @@ interface IAdditionalNodesInfo extends Record<string, unknown> {
4851}
4952
5053interface 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
0 commit comments