Skip to content

Commit bb8cdce

Browse files
RaubzeugElena Makarova
andauthored
feat: use existing clusters statuses in filter (#884)
Co-authored-by: Elena Makarova <[email protected]>
1 parent cba3b8b commit bb8cdce

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/containers/Clusters/Clusters.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ import {getMinorVersion} from '../../utils/versions';
2323

2424
import {ClustersStatistics} from './ClustersStatistics';
2525
import {CLUSTERS_COLUMNS, CLUSTERS_COLUMNS_WIDTH_LS_KEY} from './columns';
26-
import {
27-
CLUSTER_STATUSES,
28-
COLUMNS_NAMES,
29-
COLUMNS_TITLES,
30-
DEFAULT_COLUMNS,
31-
SELECTED_COLUMNS_KEY,
32-
} from './constants';
26+
import {COLUMNS_NAMES, COLUMNS_TITLES, DEFAULT_COLUMNS, SELECTED_COLUMNS_KEY} from './constants';
3327
import i18n from './i18n';
3428
import {b} from './shared';
3529
import {useSelectedColumns} from './useSelectedColumns';
@@ -103,6 +97,16 @@ export function Clusters() {
10397
[filteredClusters],
10498
);
10599

100+
const statuses = React.useMemo(() => {
101+
return Array.from(
102+
new Set(
103+
(clusters ?? []).map((cluster) => cluster.status).filter(Boolean),
104+
) as Set<string>,
105+
)
106+
.sort()
107+
.map((el) => ({value: el, content: el}));
108+
}, [clusters]);
109+
106110
if (query.isLoading) {
107111
return <Loader size="l" />;
108112
}
@@ -130,7 +134,7 @@ export function Clusters() {
130134
placeholder={i18n('controls_select-placeholder')}
131135
label={i18n('controls_status-select-label')}
132136
value={status}
133-
options={CLUSTER_STATUSES}
137+
options={statuses}
134138
onUpdate={changeStatus}
135139
width="max"
136140
/>

src/containers/Clusters/constants.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type {SelectOption} from '@gravity-ui/uikit';
2-
31
export const SELECTED_COLUMNS_KEY = 'selectedColumns';
42

53
export const COLUMNS_NAMES = {
@@ -47,22 +45,3 @@ export const COLUMNS_TITLES = {
4745
[COLUMNS_NAMES.DESCRIPTION]: 'Description',
4846
[COLUMNS_NAMES.BALANCER]: 'Balancer',
4947
} as const;
50-
51-
export const CLUSTER_STATUSES: SelectOption[] = [
52-
{
53-
value: 'production',
54-
content: 'Production',
55-
},
56-
{
57-
value: 'preprod',
58-
content: 'Preprod',
59-
},
60-
{
61-
value: 'testing',
62-
content: 'Testing',
63-
},
64-
{
65-
value: 'development',
66-
content: 'Development',
67-
},
68-
];

0 commit comments

Comments
 (0)