fix(ui): copy and dismiss a new API token

This commit is contained in:
sam committed 2026-10-27 15:31:13 +11:00
1 parent abe4c488cf
commit e5cb0ac00b
7 files changed
+16 -10

No files matched your search

+10 -4
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { Item, ItemGroup } from "@/components/ui/item";
import { onMounted, ref } from "vue";
import { Plus } from "@lucide/vue";
import { Copy, Plus, X } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -45,6 +45,8 @@ const create = () =>
await load();
});
const copy = () => navigator.clipboard.writeText(created.value);
const revoke = (id: string) =>
run(async () => {
await api.revokeToken(id);
@@ -55,15 +57,19 @@ onMounted(load);
</script>
<template>
<Section title="API tokens" :description="available ? 'Send it as Authorization: Bearer <token>.' : undefined">
<Section title="API tokens">
<template v-if="available" #action>
<Button size="sm" :disabled="busy" @click="create"><Plus data-icon="inline-start" />New token</Button>
</template>
<p v-if="!available && !busy && !error" class="text-fg-subtle">Personal tokens need a signed-in person.</p>
<p v-if="error" role="alert" class="mb-3 text-danger">{{ error }}</p>
<div v-if="created" class="mb-3 rounded-lg border border-border p-3">
<p class="mb-2 text-xs">Not shown again.</p>
<Input :model-value="created" readonly aria-label="New token" @focus="($event.target as HTMLInputElement).select()" />
<p class="mb-2 text-xs">Copy this token now. It cannot be shown again.</p>
<div class="flex gap-2">
<Input :model-value="created" readonly aria-label="New token" @focus="($event.target as HTMLInputElement).select()" />
<Button variant="outline" size="sm" aria-label="Copy token" @click="copy"><Copy /></Button>
<Button variant="ghost" size="sm" aria-label="Dismiss" @click="created = ''"><X /></Button>
</div>
</div>
<p v-if="available && !tokens.length && !busy && !error" class="text-fg-subtle">No tokens yet.</p>
<ItemGroup v-if="tokens.length" aria-label="API tokens">