-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathListKustomizations.tsx
59 lines (56 loc) · 1.55 KB
/
ListKustomizations.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
56
57
58
59
import { MenuItem } from '@material-ui/core';
import { RequestStateHandler } from '@weaveworks/weave-gitops';
import { RequestError } from '@weaveworks/weave-gitops/ui/lib/types';
import { useListKustomizationSOPS } from '../../../hooks/listSOPSKustomization';
import { Select } from '../../../utils/form';
const ListKustomizations = ({
value,
hasError,
handleFormData,
clusterName,
}: {
value: string;
hasError: boolean;
handleFormData: (value: any) => void;
clusterName: string;
}) => {
const {
isLoading,
error: listError,
data,
} = useListKustomizationSOPS(
{ clusterName },
{
retry: false,
},
);
return (
<RequestStateHandler loading={isLoading} error={listError as RequestError}>
<Select
className="form-section"
required
name="kustomization"
label="KUSTOMIZATION"
description="Choose the kustomization that will be used by SOPS to decrypt the secret."
onChange={event => handleFormData(event.target.value)}
value={value}
error={hasError}
>
{data?.kustomizations?.length ? (
data?.kustomizations?.map((k, index: number) => {
return (
<MenuItem key={index} value={`${k.name}/${k.namespace}`}>
{k.name}
</MenuItem>
);
})
) : (
<MenuItem value="" disabled={true}>
No Kustomization found in {clusterName}
</MenuItem>
)}
</Select>
</RequestStateHandler>
);
};
export default ListKustomizations;