1+ import React from 'react' ;
2+
13import { SegmentedRadioGroup } from '@gravity-ui/uikit' ;
24
35import { TableWithControlsLayout } from '../../components/TableWithControlsLayout/TableWithControlsLayout' ;
6+ import {
7+ useConfigAvailable ,
8+ useFeatureFlagsAvailable ,
9+ } from '../../store/reducers/capabilities/hooks' ;
410import { cn } from '../../utils/cn' ;
511
612import { Config } from './components/Config/Config' ;
713import { FeatureFlags } from './components/FeatureFlags/FeatureFlags' ;
814import { Startup } from './components/Startup/Startup' ;
15+ import type { ConfigType } from './types' ;
916import { ConfigTypeTitles , ConfigTypes } from './types' ;
1017import { useConfigQueryParams } from './useConfigsQueryParams' ;
1118
1219import './Configs.scss' ;
20+
1321interface ConfigsProps {
1422 database ?: string ;
1523 className ?: string ;
@@ -21,6 +29,21 @@ const b = cn('ydb-configs');
2129export function Configs ( { database, className, scrollContainerRef} : ConfigsProps ) {
2230 const { configType} = useConfigQueryParams ( ) ;
2331
32+ const isFeaturesAvailable = useFeatureFlagsAvailable ( ) ;
33+ const isConfigsAvailable = useConfigAvailable ( ) ;
34+
35+ const options = React . useMemo ( ( ) => {
36+ const options : ConfigType [ ] = [ ] ;
37+ if ( isFeaturesAvailable ) {
38+ options . push ( ConfigTypes . features ) ;
39+ }
40+ if ( isConfigsAvailable ) {
41+ options . push ( ConfigTypes . current ) ;
42+ options . push ( ConfigTypes . startup ) ;
43+ }
44+ return options ;
45+ } , [ isFeaturesAvailable , isConfigsAvailable ] ) ;
46+
2447 const renderContent = ( ) => {
2548 switch ( configType ) {
2649 case ConfigTypes . current :
@@ -35,7 +58,7 @@ export function Configs({database, className, scrollContainerRef}: ConfigsProps)
3558 return (
3659 < TableWithControlsLayout fullHeight className = { b ( null , className ) } >
3760 < TableWithControlsLayout . Controls >
38- < ConfigSelector />
61+ < ConfigSelector options = { options } />
3962 </ TableWithControlsLayout . Controls >
4063 < TableWithControlsLayout . Table scrollContainerRef = { scrollContainerRef } >
4164 { renderContent ( ) }
@@ -44,20 +67,20 @@ export function Configs({database, className, scrollContainerRef}: ConfigsProps)
4467 ) ;
4568}
4669
47- function ConfigSelector ( ) {
70+ function ConfigSelector ( { options } : { options : ConfigType [ ] } ) {
4871 const { configType, handleConfigTypeChange} = useConfigQueryParams ( ) ;
4972
73+ if ( ! options . length ) {
74+ return null ;
75+ }
76+
5077 return (
5178 < SegmentedRadioGroup value = { configType } onUpdate = { handleConfigTypeChange } >
52- < SegmentedRadioGroup . Option value = { ConfigTypes . current } >
53- { ConfigTypeTitles [ ConfigTypes . current ] }
54- </ SegmentedRadioGroup . Option >
55- < SegmentedRadioGroup . Option value = { ConfigTypes . startup } >
56- { ConfigTypeTitles [ ConfigTypes . startup ] }
57- </ SegmentedRadioGroup . Option >
58- < SegmentedRadioGroup . Option value = { ConfigTypes . features } >
59- { ConfigTypeTitles [ ConfigTypes . features ] }
60- </ SegmentedRadioGroup . Option >
79+ { options . map ( ( option ) => (
80+ < SegmentedRadioGroup . Option key = { option } value = { option } >
81+ { ConfigTypeTitles [ option ] }
82+ </ SegmentedRadioGroup . Option >
83+ ) ) }
6184 </ SegmentedRadioGroup >
6285 ) ;
6386}
0 commit comments