Skip to content

Commit 979a5c0

Browse files
committed
fix:added a delete modal for env variables
1 parent ab5ddc2 commit 979a5c0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script lang="ts">
2+
import Confirm from '$lib/components/confirm.svelte';
3+
import type { Models } from '@appwrite.io/console';
4+
5+
export let show = false;
6+
export let selectedVar: Models.Variable;
7+
export let onDelete: (variable: Models.Variable) => Promise<void>;
8+
9+
let error: string;
10+
11+
async function handleDelete() {
12+
try {
13+
await onDelete(selectedVar);
14+
show = false;
15+
} catch (e) {
16+
error = e.message;
17+
}
18+
}
19+
</script>
20+
21+
<Confirm title="Delete variable" bind:open={show} bind:error onSubmit={handleDelete}>
22+
<p>Are you sure you want to delete this variable? This action is irreversible.</p>
23+
</Confirm>

src/routes/(console)/project-[region]-[project]/updateVariables.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import { page } from '$app/state';
3939
import UpdateVariablesModal from './updateVariablesModal.svelte';
4040
import SecretVariableModal from './secretVariableModal.svelte';
41+
import DeleteVariableModal from './deleteVariableModal.svelte';
4142
4243
export let variableList: Models.VariableList;
4344
export let globalVariableList: Models.VariableList | undefined = undefined;
@@ -64,6 +65,7 @@
6465
let showEditorModal = false;
6566
let showUpdate = false;
6667
let showSecretModal = false;
68+
let showDeleteModal = false;
6769
let offset = 0;
6870
const limit = 10;
6971
@@ -402,7 +404,8 @@
402404
status="danger"
403405
trailingIcon={IconTrash}
404406
on:click={async (e) => {
405-
handleVariableDeleted(variable);
407+
selectedVar = variable;
408+
showDeleteModal = true;
406409
toggle(e);
407410
}}>
408411
Delete
@@ -480,3 +483,10 @@
480483
{variableList}
481484
bind:show={showVariablesUpload} />
482485
{/if}
486+
487+
{#if showDeleteModal}
488+
<DeleteVariableModal
489+
bind:show={showDeleteModal}
490+
{selectedVar}
491+
onDelete={handleVariableDeleted} />
492+
{/if}

0 commit comments

Comments
 (0)