podman-desktop/packages/renderer/src/lib/configmaps-secrets/ConfigMapSecretActions.svelte
Philippe Martin bb1c3c0fbd
chore: enable the @typescript-eslint/explicit-function-return-type for renderer part (#10705)
* fix: eslint config
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: components
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: store
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: window mocks
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: components 2/x
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: components 3/x
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: rebase
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: components 5/x
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: components 6/x
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: typo
Signed-off-by: Philippe Martin <phmartin@redhat.com>

* fix: rebase
Signed-off-by: Philippe Martin <phmartin@redhat.com>
2025-01-20 14:30:31 +01:00

41 lines
1.4 KiB
Svelte

<script lang="ts">
import { faTrash } from '@fortawesome/free-solid-svg-icons';
import { createEventDispatcher } from 'svelte';
import { withConfirmation } from '/@/lib/dialogs/messagebox-utils';
import ListItemButtonIcon from '../ui/ListItemButtonIcon.svelte';
import { ConfigMapSecretUtils } from './configmap-secret-utils';
import type { ConfigMapSecretUI } from './ConfigMapSecretUI';
export let configMapSecret: ConfigMapSecretUI;
export let detailed = false;
const dispatch = createEventDispatcher<{ update: ConfigMapSecretUI }>();
export let onUpdate: (update: ConfigMapSecretUI) => void = update => {
dispatch('update', update);
};
const configmapSecretUtils = new ConfigMapSecretUtils();
async function deleteConfigMapSecret(): Promise<void> {
configMapSecret.status = 'DELETING';
onUpdate(configMapSecret);
if (configmapSecretUtils.isSecret(configMapSecret)) {
await window.kubernetesDeleteSecret(configMapSecret.name);
} else {
await window.kubernetesDeleteConfigMap((configMapSecret as ConfigMapSecretUI).name);
}
}
</script>
<ListItemButtonIcon
title={`Delete ${configmapSecretUtils.isSecret(configMapSecret) ? 'Secret' : 'ConfigMap'}`}
onClick={(): void =>
withConfirmation(
deleteConfigMapSecret,
`delete ${configmapSecretUtils.isSecret(configMapSecret) ? 'secret' : 'configmap'} ${configMapSecret.name}`,
)}
detailed={detailed}
icon={faTrash} />