fix(webui): make task actions and dangerous approvals deliberate

Task rows render one primary control with the rest in an overflow menu
instead of every catalog action at once; dangerous-action approvals and the
daemon-restarting install confirm by name; the Needs-you tile reads the
served attention statuses instead of a hardcoded pair; and dangerous.go
stops calling the 24-hour approval permanent.
This commit is contained in:
sam committed 2026-09-20 23:38:57 +10:00
1 parent 74f0aadc70
commit b9c005fb93
5 files changed
+194 -33

No files matched your search

+63 -3
View File
@@ -1,4 +1,16 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { decideDangerous } from "./state";
import type { DangerousAction } from "./types";
@@ -6,17 +18,65 @@ import type { DangerousAction } from "./types";
/**
* One queued request: what it would do, and the decisions open on it. Approve
* runs it once, "Approve for 24h" runs it for a day, and Deny drops it.
*
* Both approves are destructive-weighted and confirmed first, because they
* grant authority: approve for the one run, the 24h option for every future
* request of the same family. Deny takes nothing away, so it stays plain.
*/
const props = defineProps<{ action: DangerousAction }>();
// Which approve decision is awaiting its confirmation, if any: one dialog
// driven by the decision it will run, rather than two copies of the same
// footer. The decision kinds are fixed by the endpoint ('approve' |
// 'permanent' | 'deny') and must not be reworded here.
const confirming = ref<"approve" | "permanent" | null>(null);
const description = computed(() => props.action.description || "this action");
function decide(decision: "approve" | "permanent" | "deny"): void {
void decideDangerous(props.action.id, decision);
}
function onConfirmationOpen(open: boolean): void {
if (!open) confirming.value = null;
}
</script>
<template>
<div class="flex flex-wrap items-center justify-between gap-3 border-t border-hairline py-3">
<span class="text-sm">{{ props.action.description }}</span>
<div class="flex flex-wrap gap-2">
<Button variant="outline" @click="decideDangerous(props.action.id, 'approve')">Approve</Button>
<Button variant="outline" @click="decideDangerous(props.action.id, 'permanent')">Approve for 24h</Button>
<Button variant="outline" @click="decideDangerous(props.action.id, 'deny')">Deny</Button>
<Button variant="destructive" @click="confirming = 'approve'">Approve</Button>
<Button variant="destructive" @click="confirming = 'permanent'">Approve for 24h</Button>
<Button variant="default" @click="decide('deny')">Deny</Button>
</div>
</div>
<AlertDialog :open="confirming !== null" @update:open="onConfirmationOpen">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{{ confirming === 'permanent' ? 'Approve for 24 hours?' : 'Approve this action?' }}
</AlertDialogTitle>
<AlertDialogDescription>
<template v-if="confirming === 'permanent'">
This runs "{{ description }}" now, and approves its action family for 24 hours — further
requests of the same kind run without asking again.
</template>
<template v-else>
This runs "{{ description }}" once, now.
</template>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
@click="confirming && decide(confirming)"
>
{{ confirming === 'permanent' ? 'Approve for 24h' : 'Approve' }}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>
+39 -3
View File
@@ -1,6 +1,16 @@
<script setup lang="ts">
import { computed } from "vue";
import { computed, ref } from "vue";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import ConfigCard from "./ConfigCard.vue";
import { deferUpdate, installUpdate, update } from "./state";
@@ -23,11 +33,21 @@ const summary = computed(() => {
return "Archie is up to date.";
});
// Installing restarts archied, so it is confirmed first: the operator needs
// to know that this dashboard, and any tasks archied is running, go down with
// it before the install call fires.
const confirmingInstall = ref(false);
function defer(): void {
void deferUpdate(update.value?.snapshot);
}
function onInstallOpen(open: boolean): void {
if (!open) confirmingInstall.value = false;
}
function install(): void {
confirmingInstall.value = false;
void installUpdate(update.value?.snapshot);
}
</script>
@@ -43,8 +63,24 @@ function install(): void {
<div v-if="available.length" class="mt-3 flex flex-wrap gap-2">
<Button variant="outline" @click="defer">Defer</Button>
<!-- Installing restarts archied, so it is offered only when the server
says it can perform one. -->
<Button v-if="update.can_install" @click="install">Install update</Button>
says it can perform one, and confirmed before it runs. -->
<Button v-if="update.can_install" variant="destructive" @click="confirmingInstall = true">Install update</Button>
</div>
<AlertDialog :open="confirmingInstall" @update:open="onInstallOpen">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Install update</AlertDialogTitle>
<AlertDialogDescription>
Installing restarts archied. This dashboard will be unavailable until it comes back, and
any tasks archied is running are interrupted.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive" @click="install">Install update</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</ConfigCard>
</template>