From b118166693028b2af2c20d372e7e0e0cc65fc14a Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Wed, 13 May 2026 11:16:10 +0100 Subject: [PATCH] refactor(keys): ConfirmDialog with type-to-confirm, EmptyState - Replace window.confirm for key revoke with ConfirmDialog + confirmText prop requiring user to type the key label before confirmation - Replace terse "No API keys" text with EmptyState component (Key, Plus, Shield icons) - Add focus-visible ring on Revoke button Co-Authored-By: Claude Sonnet 4.6 --- web/src/views/KeysView.vue | 51 +++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/web/src/views/KeysView.vue b/web/src/views/KeysView.vue index 17598df..3e428a4 100644 --- a/web/src/views/KeysView.vue +++ b/web/src/views/KeysView.vue @@ -9,8 +9,11 @@ import Button from '@/components/ui/Button.vue' import Dialog from '@/components/ui/Dialog.vue' import Input from '@/components/ui/Input.vue' import Spinner from '@/components/ui/Spinner.vue' +import ConfirmDialog from '@/components/ui/ConfirmDialog.vue' +import EmptyState from '@/components/ui/EmptyState.vue' import { toast } from 'vue-sonner' import { formatDate } from '@/lib/utils' +import { Key, Plus, Shield } from 'lucide-vue-next' import type { ApiKey } from '@/types' const keys = ref([]) @@ -20,6 +23,10 @@ const newKeyLabel = ref('') const creating = ref(false) const generatedKey = ref(null) +// Revoke confirm state +const showRevokeConfirm = ref(false) +const pendingRevokeKey = ref(null) + onMounted(() => loadKeys()) async function loadKeys() { @@ -48,8 +55,15 @@ async function handleCreate() { } } -async function handleRevoke(key: ApiKey) { - if (!confirm(`Revoke key "${key.label}"? This cannot be undone.`)) return +function requestRevoke(key: ApiKey) { + pendingRevokeKey.value = key + showRevokeConfirm.value = true +} + +async function executeRevoke() { + if (!pendingRevokeKey.value) return + const key = pendingRevokeKey.value + pendingRevokeKey.value = null try { await adminApi.revokeKey(key.id) toast.success('Key revoked') @@ -58,13 +72,18 @@ async function handleRevoke(key: ApiKey) { toast.error('Failed to revoke key') } } + +function openCreateDialog() { + showCreate.value = true + generatedKey.value = null +} + + +