|
38 | 38 | import { page } from '$app/state';
|
39 | 39 | import UpdateVariablesModal from './updateVariablesModal.svelte';
|
40 | 40 | import SecretVariableModal from './secretVariableModal.svelte';
|
| 41 | + import { Confirm } from '$lib/components'; |
41 | 42 |
|
42 | 43 | export let variableList: Models.VariableList;
|
43 | 44 | export let globalVariableList: Models.VariableList | undefined = undefined;
|
|
64 | 65 | let showEditorModal = false;
|
65 | 66 | let showUpdate = false;
|
66 | 67 | let showSecretModal = false;
|
| 68 | + let showDeleteModal = false; |
| 69 | + let deleteError: string; |
67 | 70 | let offset = 0;
|
68 | 71 | const limit = 10;
|
69 | 72 |
|
|
134 | 137 | }
|
135 | 138 | }
|
136 | 139 |
|
137 |
| - async function handleVariableDeleted(variable: Models.Variable) { |
| 140 | + async function handleVariableDeleted() { |
138 | 141 | try {
|
139 |
| - await sdkDeleteVariable(variable.$id); |
| 142 | + await sdkDeleteVariable(selectedVar.$id); |
| 143 | + showDeleteModal = false; |
| 144 | + selectedVar = null; |
140 | 145 | addNotification({
|
141 | 146 | type: 'success',
|
142 | 147 | message: `${$project.name} ${
|
|
145 | 150 | });
|
146 | 151 | trackEvent(Submit.VariableDelete);
|
147 | 152 | } catch (error) {
|
148 |
| - addNotification({ |
149 |
| - type: 'error', |
150 |
| - message: error.message |
151 |
| - }); |
| 153 | + deleteError = error.message; |
152 | 154 | trackError(error, Submit.VariableDelete);
|
153 | 155 | }
|
154 | 156 | }
|
|
402 | 404 | status="danger"
|
403 | 405 | trailingIcon={IconTrash}
|
404 | 406 | on:click={async (e) => {
|
405 |
| - handleVariableDeleted(variable); |
| 407 | + selectedVar = variable; |
| 408 | + showDeleteModal = true; |
406 | 409 | toggle(e);
|
407 | 410 | }}>
|
408 | 411 | Delete
|
|
480 | 483 | {variableList}
|
481 | 484 | bind:show={showVariablesUpload} />
|
482 | 485 | {/if}
|
| 486 | + |
| 487 | +{#if showDeleteModal} |
| 488 | + <Confirm |
| 489 | + title="Delete variable" |
| 490 | + bind:open={showDeleteModal} |
| 491 | + bind:error={deleteError} |
| 492 | + onSubmit={handleVariableDeleted}> |
| 493 | + <p>Are you sure you want to delete this variable? This action is irreversible.</p> |
| 494 | + </Confirm> |
| 495 | +{/if} |
0 commit comments