-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathListSecretsStore.tsx
56 lines (54 loc) · 1.41 KB
/
ListSecretsStore.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
import { MenuItem } from '@material-ui/core';
import { RequestStateHandler } from '@weaveworks/weave-gitops';
import { useListExternalSecretStores } from '../../../contexts/Secrets';
import { RequestError } from '../../../types/custom';
import { Select } from '../../../utils/form';
const ListSecretsStore = ({
value,
hasError,
handleFormData,
clusterName,
}: {
value: string;
hasError: boolean;
handleFormData: (value: any) => void;
clusterName: string;
}) => {
const {
data,
isLoading,
error: listError,
} = useListExternalSecretStores({
clusterName,
});
return (
<RequestStateHandler loading={isLoading} error={listError as RequestError}>
<Select
required
name="secretStoreRef"
label="SECRET STORE"
onChange={event => handleFormData(event.target.value)}
value={value}
error={hasError}
>
{data?.stores?.length ? (
data?.stores?.map((s, index: number) => {
return (
<MenuItem
key={index}
value={`${s.name}/${s.kind}/${s.namespace}/${s.type}`}
>
{s.name}
</MenuItem>
);
})
) : (
<MenuItem value="" disabled={true}>
No SecretStore found in {clusterName}
</MenuItem>
)}
</Select>
</RequestStateHandler>
);
};
export default ListSecretsStore;