fix(ui): destructive actions confirm via AlertDialog, naming the item (#1749)
Delete policy, remove member, revoke token, remove passkey and delete source now open the shared AlertDialog confirmation that names the item, matching the binding/mapping/event-type deletes that already confirmed.
This commit is contained in:
5 files changed
+74
-5
No files matched your search
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
@@ -89,6 +90,7 @@ async function save(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
const pending = ref<Policy | null>(null);
|
||||
async function remove(p: Policy): Promise<void> {
|
||||
try {
|
||||
await api.deletePolicy(p);
|
||||
@@ -128,7 +130,7 @@ onMounted(load);
|
||||
</div>
|
||||
<div class="flex shrink-0 gap-2">
|
||||
<Button size="sm" variant="outline" @click="edit(p)">Edit</Button>
|
||||
<Button size="sm" variant="outline" @click="remove(p)">Delete</Button>
|
||||
<Button size="sm" variant="outline" @click="pending = p">Delete</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -172,4 +174,16 @@ onMounted(load);
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Delete policy?</AlertDialogTitle>
|
||||
<AlertDialogDescription>Delete the policy "{{ pending?.id }}". This cannot be undone.</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction @click="if (pending) { const p = pending; pending = null; void remove(p); }">Delete policy</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import CreateAccount from "@/accounts/CreateAccount.vue";
|
||||
@@ -126,6 +127,7 @@ const setRole = (member: Member, role: unknown) =>
|
||||
await load();
|
||||
});
|
||||
|
||||
const pending = ref<Member | null>(null);
|
||||
const remove = (member: Member) =>
|
||||
run(member.identity_id + (member.workspace_id ?? ""), async () => {
|
||||
if (!org.value) return;
|
||||
@@ -247,4 +249,16 @@ const remove = (member: Member) =>
|
||||
</Section>
|
||||
</div>
|
||||
</div>
|
||||
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Remove member?</AlertDialogTitle>
|
||||
<AlertDialogDescription>Remove {{ pending?.display_name }} from this organisation? Their access stops immediately.</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction @click="if (pending) { const m = pending; pending = null; remove(m); }">Remove member</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</template>
|
||||
Reference in new issue
Block a user