fix(ui): destructive actions confirm via AlertDialog, naming the item (#1749)
Quality / check (push) Canceled after 7m10s
deploy / gate (push) Successful in 4m49s
deploy / archied-image (push) Successful in 3m29s
deploy / agent-image (push) Successful in 12s
deploy / dist-zip (push) Skipped

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:
sam committed 2026-11-07 00:11:16 +11:00
1 parent ef623f6c68
commit 12eea5eee3
5 files changed
+74 -5

No files matched your search

+15 -2
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { Item, ItemActions, ItemContent, ItemGroup } from "@/components/ui/item";
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { computed, onMounted, ref } from "vue";
import PageHeader from "@/base/PageHeader.vue";
@@ -13,7 +14,7 @@ import { api, classifyActionError } from "@/lib/api";
import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts";
const recovery=ref("");
const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code});
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const pending=ref<{id:string;name:string}|null>(null);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}}
onMounted(load);
@@ -28,7 +29,7 @@ const change=()=>run(async()=>{await api.changePassword(current.value,next.value
<Alert v-if="$route.query.welcome" class="mb-4">Your organisation and admin account are ready. Add a passkey below, <RouterLink class="underline" to="/org/members">add members</RouterLink>, or <RouterLink class="underline" to="/settings/authentication">configure OIDC</RouterLink>.</Alert>
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
<Section title="Passkeys">
<ItemGroup v-if="keys.length" class="mb-3"><Item v-for="key in keys" :key="key.id" as="li" variant="outline" size="xs"><ItemContent class="min-w-0 truncate"><span class="truncate">{{key.name}}</span></ItemContent><ItemActions><Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="remove(key.id)">Remove</Button></ItemActions></Item></ItemGroup>
<ItemGroup v-if="keys.length" class="mb-3"><Item v-for="key in keys" :key="key.id" as="li" variant="outline" size="xs"><ItemContent class="min-w-0 truncate"><span class="truncate">{{key.name}}</span></ItemContent><ItemActions><Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="pending = key">Remove</Button></ItemActions></Item></ItemGroup>
<form v-if="eligible" class="flex flex-wrap gap-2" @submit.prevent="enroll"><Input v-model="keyName" aria-label="Passkey name" placeholder="Passkey name (optional)" maxlength="200" class="min-w-40 flex-1"/><Button type="submit" :disabled="busy">Add passkey</Button></form>
<p v-else class="text-fg-muted">Passkeys need an HTTPS domain or localhost. Set the instance URL in <RouterLink class="underline" to="/settings/authentication">Authentication settings</RouterLink>.</p>
</Section>
@@ -45,4 +46,16 @@ const change=()=>run(async()=>{await api.changePassword(current.value,next.value
</form>
</Section>
</div>
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove passkey?</AlertDialogTitle>
<AlertDialogDescription>Remove the passkey "{{ pending?.name }}"? You will no longer be able to sign in with it.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="if (pending) { const k = pending; pending = null; remove(k.id); }">Remove passkey</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>
+15 -1
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { Item, ItemGroup } from "@/components/ui/item";
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
import { onMounted, ref } from "vue";
import { Copy, Plus, X } from "@lucide/vue";
@@ -63,6 +64,7 @@ const create = () =>
const copy = () => navigator.clipboard.writeText(created.value);
const pending = ref<PersonalToken | null>(null);
const revoke = (id: string) =>
run(async () => {
await api.revokeToken(id);
@@ -103,8 +105,20 @@ onMounted(load);
<span class="text-caption text-fg-subtle">Created <Timestamp :at="token.created_at" /></span>
<span class="text-caption text-fg-subtle">Expires <Timestamp v-if="token.expires_at" :at="token.expires_at" /><template v-else>Never</template></span>
<span class="text-caption text-fg-subtle">Last used <Timestamp v-if="token.last_used_at" :at="token.last_used_at" /><template v-else>Never</template></span>
<Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="revoke(token.id)">Revoke</Button>
<Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="pending = token">Revoke</Button>
</Item>
</ItemGroup>
</Section>
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Revoke token?</AlertDialogTitle>
<AlertDialogDescription>Revoke "{{ pending?.name || pending?.id.slice(0, 12) }}"? Anything using it stops working immediately.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="if (pending) { const t = pending; pending = null; revoke(t.id); }">Revoke token</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>
+15 -1
View File
@@ -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>
+14
View File
@@ -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>
+15 -1
View File
@@ -3,6 +3,7 @@ import { Check, Copy, KeyRound, Lock, LockOpen, Plus, Trash2 } from "@lucide/vue
import { onMounted, ref } from "vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Section } from "@/components/ui/section";
@@ -53,6 +54,7 @@ const {
remove,
refusals,
} = useSources();
const pending = ref<Source | null>(null);
const customPath = ref("");
const copied = ref<string | null>(null);
@@ -214,7 +216,7 @@ function url(source: Source): string {
size="icon-sm"
aria-label="Delete source"
:disabled="busy"
@click="remove(source)"
@click="pending = source"
>
<Trash2 />
</Button>
@@ -232,4 +234,16 @@ function url(source: Source): string {
<EmptyHeader><EmptyTitle>No sources yet</EmptyTitle></EmptyHeader>
</Empty>
</section>
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete source?</AlertDialogTitle>
<AlertDialogDescription>Delete the source "{{ pending?.path }}"? Its webhook endpoint stops accepting deliveries.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="if (pending) { const src = pending; pending = null; remove(src); }">Delete source</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>