fix(ui): the token revoke dialog runs the revoke it was opened for
This commit is contained in:
1 file changed
+9
-3
@@ -65,12 +65,18 @@ const create = () =>
|
||||
|
||||
const copy = () => navigator.clipboard.writeText(created.value);
|
||||
|
||||
// The token is kept until the next Revoke: Reka closes the dialog before the
|
||||
// action's click runs, so clearing it on close would drop the revoke.
|
||||
const pending = ref<PersonalToken | null>(null);
|
||||
const dialogOpen = ref(false);
|
||||
const revoke = (id: string) =>
|
||||
run(async () => {
|
||||
await api.revokeToken(id);
|
||||
await load();
|
||||
});
|
||||
const confirmRevoke = () => {
|
||||
if (pending.value) revoke(pending.value.id);
|
||||
};
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
@@ -106,11 +112,11 @@ 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="pending = token">Revoke</Button>
|
||||
<Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="pending = token; dialogOpen = true">Revoke</Button>
|
||||
</Item>
|
||||
</ItemGroup>
|
||||
</Section>
|
||||
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
|
||||
<AlertDialog :open="dialogOpen" @update:open="(v: boolean) => { dialogOpen = v; }">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Revoke token?</AlertDialogTitle>
|
||||
@@ -118,7 +124,7 @@ onMounted(load);
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction @click="if (pending) { const t = pending; pending = null; revoke(t.id); }">Revoke token</AlertDialogAction>
|
||||
<AlertDialogAction @click="confirmRevoke">Revoke token</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
Reference in new issue
Block a user