Skip to content

Commit 8531b95

Browse files
authored
fix: check feature flag api is available (#1308)
1 parent 8e05166 commit 8531b95

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/containers/Tenant/Diagnostics/Diagnostics.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {StringParam, useQueryParams} from 'use-query-params';
77

88
import {AutoRefreshControl} from '../../../components/AutoRefreshControl/AutoRefreshControl';
99
import routes, {createHref} from '../../../routes';
10+
import {useFeatureFlagsAvailable} from '../../../store/reducers/capabilities/hooks';
1011
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../store/reducers/tenant/constants';
1112
import {setDiagnosticsTab} from '../../../store/reducers/tenant/tenant';
1213
import type {AdditionalNodesProps, AdditionalTenantsProps} from '../../../types/additionalProps';
@@ -25,7 +26,7 @@ import {Configs} from './Configs/Configs';
2526
import {Consumers} from './Consumers';
2627
import Describe from './Describe/Describe';
2728
import DetailedOverview from './DetailedOverview/DetailedOverview';
28-
import {DATABASE_PAGES, getPagesByType} from './DiagnosticsPages';
29+
import {getDataBasePages, getPagesByType} from './DiagnosticsPages';
2930
import {HotKeys} from './HotKeys/HotKeys';
3031
import {Network} from './Network/Network';
3132
import {Partitions} from './Partitions/Partitions';
@@ -62,7 +63,8 @@ function Diagnostics(props: DiagnosticsProps) {
6263
const tenantName = isDatabaseEntityType(props.type) ? props.path : props.tenantName;
6364
const isDatabase = isDatabaseEntityType(props.type) || props.path === props.tenantName;
6465

65-
const pages = isDatabase ? DATABASE_PAGES : getPagesByType(props.type);
66+
const hasFeatureFlags = useFeatureFlagsAvailable();
67+
const pages = isDatabase ? getDataBasePages({hasFeatureFlags}) : getPagesByType(props.type);
6668
let activeTab = pages.find((el) => el.id === diagnosticsTab);
6769
if (!activeTab) {
6870
activeTab = pages[0];

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

+6
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,9 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
130130
};
131131

132132
export const getPagesByType = (type?: EPathType) => (type && pathTypeToPages[type]) || DIR_PAGES;
133+
134+
export const getDataBasePages = ({hasFeatureFlags}: {hasFeatureFlags?: boolean}) => {
135+
return hasFeatureFlags
136+
? DATABASE_PAGES
137+
: DATABASE_PAGES.filter((item) => item.id !== TENANT_DIAGNOSTICS_TABS_IDS.configs);
138+
};

src/store/reducers/capabilities/hooks.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ export const useTracingLevelOptionAvailable = () => {
3030
export const useStorageGroupsHandlerAvailable = () => {
3131
return useGetFeatureVersion('/storage/groups') > 2;
3232
};
33+
34+
export const useFeatureFlagsAvailable = () => {
35+
return useGetFeatureVersion('/viewer/feature_flags') > 1;
36+
};

src/types/api/capabilities.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ export interface CapabilitiesResponse {
66
}
77

88
// Add feature name before using it
9-
export type Capability = '/pdisk/info' | '/scheme/directory' | '/storage/groups' | '/viewer/query';
9+
export type Capability =
10+
| '/pdisk/info'
11+
| '/scheme/directory'
12+
| '/storage/groups'
13+
| '/viewer/query'
14+
| '/viewer/feature_flags';

0 commit comments

Comments
 (0)