@@ -4,27 +4,27 @@ import {skipToken} from '@reduxjs/toolkit/query';
4
4
5
5
import { ResponseError } from '../../../../components/Errors/ResponseError' ;
6
6
import { ResizeableDataTable } from '../../../../components/ResizeableDataTable/ResizeableDataTable' ;
7
+ import { TableColumnSetup } from '../../../../components/TableColumnSetup/TableColumnSetup' ;
7
8
import { TableSkeleton } from '../../../../components/TableSkeleton/TableSkeleton' ;
8
9
import { TableWithControlsLayout } from '../../../../components/TableWithControlsLayout/TableWithControlsLayout' ;
9
10
import { nodesListApi , selectNodesMap } from '../../../../store/reducers/nodesList' ;
10
11
import { partitionsApi , setSelectedConsumer } from '../../../../store/reducers/partitions/partitions' ;
11
12
import { selectConsumersNames , topicApi } from '../../../../store/reducers/topic' ;
12
13
import { cn } from '../../../../utils/cn' ;
13
- import { DEFAULT_TABLE_SETTINGS , PARTITIONS_HIDDEN_COLUMNS_KEY } from '../../../../utils/constants' ;
14
- import {
15
- useAutoRefreshInterval ,
16
- useSetting ,
17
- useTypedDispatch ,
18
- useTypedSelector ,
19
- } from '../../../../utils/hooks' ;
14
+ import { DEFAULT_TABLE_SETTINGS } from '../../../../utils/constants' ;
15
+ import { useAutoRefreshInterval , useTypedDispatch , useTypedSelector } from '../../../../utils/hooks' ;
16
+ import { useSelectedColumns } from '../../../../utils/hooks/useSelectedColumns' ;
20
17
21
- import {
22
- PartitionsControls ,
23
- PartitionsTableColumnSetup ,
24
- } from './PartitionsControls/PartitionsControls' ;
18
+ import { PartitionsControls } from './PartitionsControls/PartitionsControls' ;
25
19
import { PARTITIONS_COLUMNS_WIDTH_LS_KEY } from './columns' ;
26
20
import i18n from './i18n' ;
27
21
import { addHostToPartitions } from './utils' ;
22
+ import {
23
+ PARTITIONS_COLUMNS_IDS ,
24
+ PARTITIONS_COLUMNS_TITLES ,
25
+ allPartitionsColumnsIds ,
26
+ generalPartitionColumnsIds ,
27
+ } from './utils/constants' ;
28
28
import type { PreparedPartitionDataWithHosts } from './utils/types' ;
29
29
import { useGetPartitionsColumns } from './utils/useGetPartitionsColumns' ;
30
30
@@ -64,9 +64,15 @@ export const Partitions = ({path, database, databaseFullPath}: PartitionsProps)
64
64
const nodesLoading = nodesIsFetching && nodesData === undefined ;
65
65
const nodeHostsMap = useTypedSelector ( ( state ) => selectNodesMap ( state , database ) ) ;
66
66
67
- const [ hiddenColumns , setHiddenColumns ] = useSetting < string [ ] > ( PARTITIONS_HIDDEN_COLUMNS_KEY ) ;
67
+ const columns = useGetPartitionsColumns ( selectedConsumer ) ;
68
68
69
- const [ columns , columnsIdsForSelector ] = useGetPartitionsColumns ( selectedConsumer ) ;
69
+ const { columnsToShow, columnsToSelect, setColumns} = useSelectedColumns (
70
+ columns ,
71
+ 'partitionsSelectedColumns' ,
72
+ PARTITIONS_COLUMNS_TITLES ,
73
+ selectedConsumer ? allPartitionsColumnsIds : generalPartitionColumnsIds ,
74
+ [ PARTITIONS_COLUMNS_IDS . PARTITION_ID ] ,
75
+ ) ;
70
76
71
77
const params = topicLoading
72
78
? skipToken
@@ -95,14 +101,6 @@ export const Partitions = ({path, database, databaseFullPath}: PartitionsProps)
95
101
}
96
102
} , [ dispatch , topicLoading , selectedConsumer , consumers ] ) ;
97
103
98
- const columnsToShow = React . useMemo ( ( ) => {
99
- return columns . filter ( ( column ) => ! hiddenColumns . includes ( column . name ) ) ;
100
- } , [ columns , hiddenColumns ] ) ;
101
-
102
- const hadleTableColumnsSetupChange = ( newHiddenColumns : string [ ] ) => {
103
- setHiddenColumns ( newHiddenColumns ) ;
104
- } ;
105
-
106
104
const handleSelectedConsumerChange = ( value ?: string ) => {
107
105
dispatch ( setSelectedConsumer ( value ) ) ;
108
106
} ;
@@ -125,13 +123,7 @@ export const Partitions = ({path, database, databaseFullPath}: PartitionsProps)
125
123
} ;
126
124
127
125
const renderExtraControls = ( ) => {
128
- return (
129
- < PartitionsTableColumnSetup
130
- hiddenColumns = { hiddenColumns }
131
- onHiddenColumnsChange = { hadleTableColumnsSetupChange }
132
- initialColumnsIds = { columnsIdsForSelector }
133
- />
134
- ) ;
126
+ return < TableColumnSetup items = { columnsToSelect } showStatus onUpdate = { setColumns } /> ;
135
127
} ;
136
128
137
129
const renderContent = ( ) => {
0 commit comments