-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathListClusters.tsx
55 lines (53 loc) · 1.62 KB
/
ListClusters.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { MenuItem } from '@material-ui/core';
import { Flex, RequestStateHandler, Text } from '@weaveworks/weave-gitops';
import { RequestError } from '@weaveworks/weave-gitops/ui/lib/types';
import { useListCluster } from '../../../hooks/clusters';
import { Select } from '../../../utils/form';
const ListClusters = ({
value,
hasError,
handleFormData,
}: {
value: string;
hasError: boolean;
handleFormData: (value: any) => void;
}) => {
const { isLoading, data, error: listError } = useListCluster();
return (
<RequestStateHandler loading={isLoading} error={listError as RequestError}>
<Select
name="clusterName"
required={true}
label="CLUSTER"
onChange={event => handleFormData(event.target.value)}
value={value}
error={hasError}
>
{data?.gitopsClusters
?.filter(e =>
e.conditions?.find(c => c.status === 'True' && c.type === 'Ready'),
)
.map((option, index: number) => {
return (
<MenuItem
key={index}
value={
option.namespace
? `${option.namespace}/${option.name}`
: option.name
}
>
<Flex column>
<Text>{option.name}</Text>
<Text color="neutral30" size="small">
{option.namespace ? `ns: ${option.namespace}` : '-'}
</Text>
</Flex>
</MenuItem>
);
})}
</Select>
</RequestStateHandler>
);
};
export default ListClusters;