diff --git a/frontend/src/lib/components/Dropdown.svelte b/frontend/src/lib/components/Dropdown.svelte index f9aa585695..d684abcdb7 100644 --- a/frontend/src/lib/components/Dropdown.svelte +++ b/frontend/src/lib/components/Dropdown.svelte @@ -55,10 +55,10 @@ {#each dropdownItems as item, i} {#if item.action} {/if} - + + + { + deleteConfirmedCallback = undefined + }} + on:confirmed={() => { + if (deleteConfirmedCallback) { + deleteConfirmedCallback() + } + deleteConfirmedCallback = undefined + }} > +
+ Are you sure you want to remove this resource? + +
+ You can press + SHIFT + while removing a resource to bypass confirmation. +
+
+
+
diff --git a/frontend/src/routes/variables.svelte b/frontend/src/routes/variables.svelte index 64570c38c2..86a1ef986e 100644 --- a/frontend/src/routes/variables.svelte +++ b/frontend/src/routes/variables.svelte @@ -21,6 +21,9 @@ import CenteredPage from '$lib/components/CenteredPage.svelte' import Icon from 'svelte-awesome' import { faPlus, faCircle } from '@fortawesome/free-solid-svg-icons' + import ConfirmationModal from '$lib/components/common/confirmationModal/ConfirmationModal.svelte' + import Alert from '$lib/components/common/alert/Alert.svelte' + import Badge from '$lib/components/common/badge/Badge.svelte' type ListableVariableW = ListableVariable & { canWrite: boolean } @@ -30,6 +33,9 @@ let shareModal: ShareModal let variableEditor: VariableEditor + let deleteConfirmedCallback: (() => void) | undefined = undefined + $: open = Boolean(deleteConfirmedCallback) + // If relative, the dropdown is positioned relative to its button async function loadVariables(): Promise { variables = (await VariableService.listVariable({ workspace: $workspaceStore! })).map((x) => { @@ -119,7 +125,16 @@ }, { displayName: 'Delete', - action: () => deleteVariable(path, account), + + action: (event) => { + if (event?.shiftKey) { + deleteVariable(path, account) + } else { + deleteConfirmedCallback = () => { + deleteVariable(path, account) + } + } + }, disabled: !canWrite }, { @@ -182,5 +197,28 @@ /> - + { + deleteConfirmedCallback = undefined + }} + on:confirmed={() => { + if (deleteConfirmedCallback) { + deleteConfirmedCallback() + } + deleteConfirmedCallback = undefined + }} +> +
+ Are you sure you want to remove this variable? + +
+ You can press + SHIFT + while removing a variable to bypass confirmation. +
+
+
+