|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 17 | +import { FormControlLabel, Switch } from '@mui/material'; |
| 18 | +import { useState } from 'react'; |
17 | 19 | import { useTranslation } from 'react-i18next'; |
18 | 20 | import Secret from '../../lib/k8s/secret'; |
| 21 | +import { CreateResourceButton } from '../common'; |
19 | 22 | import ResourceListView from '../common/Resource/ResourceListView'; |
20 | 23 |
|
21 | 24 | export default function SecretList() { |
| 25 | + const SECRET_LIST_HELM_SECRET_HIDE_STORAGE_KEY = 'SECRET_LIST_HELM_SECRET_HIDE_STORAGE_KEY'; |
| 26 | + const SECRET_LIST_HELM_SECRET_HIDE_DEFAULT = true; |
22 | 27 | const { t } = useTranslation(['glossary', 'translation']); |
| 28 | + const [hideHelm, setHideHelm] = useState( |
| 29 | + Boolean( |
| 30 | + localStorage.getItem(SECRET_LIST_HELM_SECRET_HIDE_STORAGE_KEY) || |
| 31 | + SECRET_LIST_HELM_SECRET_HIDE_DEFAULT |
| 32 | + ) |
| 33 | + ); |
| 34 | + |
| 35 | + const [secrets, error] = Secret.useList(); |
| 36 | + |
| 37 | + const filteredSecrets = |
| 38 | + hideHelm && secrets ? secrets.filter(secret => secret.type !== 'helm.sh/release.v1') : secrets; |
23 | 39 |
|
24 | 40 | return ( |
25 | 41 | <ResourceListView |
26 | 42 | title={t('Secrets')} |
27 | | - resourceClass={Secret} |
| 43 | + data={filteredSecrets} |
| 44 | + errorMessage={Secret.getErrorMessage(error)} |
| 45 | + headerProps={{ |
| 46 | + noNamespaceFilter: false, |
| 47 | + titleSideActions: [ |
| 48 | + <CreateResourceButton key="create-button" resourceClass={Secret} />, |
| 49 | + <FormControlLabel |
| 50 | + key="helm-switch" |
| 51 | + checked={hideHelm} |
| 52 | + control={ |
| 53 | + <Switch |
| 54 | + checked={hideHelm} |
| 55 | + onChange={(e, checked) => { |
| 56 | + localStorage.setItem( |
| 57 | + SECRET_LIST_HELM_SECRET_HIDE_STORAGE_KEY, |
| 58 | + checked.toString() |
| 59 | + ); |
| 60 | + setHideHelm(checked); |
| 61 | + }} |
| 62 | + color="primary" |
| 63 | + /> |
| 64 | + } |
| 65 | + label={t('translation|Hide Helm Secrets')} |
| 66 | + sx={{ marginLeft: '0.5rem' }} |
| 67 | + />, |
| 68 | + ], |
| 69 | + }} |
28 | 70 | columns={[ |
29 | 71 | 'name', |
30 | 72 | 'namespace', |
|
0 commit comments