Files
archie/ui/src/dashboard/SetupPanel.vue
T

60 lines
2.0 KiB
Vue

<script setup lang="ts">
import { storeToRefs } from "pinia";
import { Check, Circle } from "@lucide/vue";
import { computed, ref, watch } from "vue";
import {
Card,
CardAction,
CardContent,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { setupPanelState, type SetupPanelState } from "./setup-preference";
import { useTasksStore } from "@/stores/tasks";
const { setup } = storeToRefs(useTasksStore());
/**
* The setup checklist, rendered only while there is setup work left.
*
* A fully configured daemon renders nothing: the old completion card ("Setup
* complete", with a check and a dismiss button) celebrated the absence of a
* problem and occupied a grid cell until dismissed. Setup regressing to
* incomplete brings the checklist back on its own.
*/
const panel = ref<SetupPanelState>(setupPanelState(setup.value));
watch(setup, () => {
panel.value = setupPanelState(setup.value);
});
const steps = computed(() => setup.value?.steps ?? []);
const pct = computed(() => {
const total = steps.value.length;
if (!total) return 0;
return Math.round(((total - panel.value.remaining.length) / total) * 100);
});
</script>
<template>
<Card v-if="panel.kind === 'incomplete'" size="sm">
<CardHeader>
<CardTitle>Setup</CardTitle>
<CardAction>
<span class="text-sm font-semibold text-link tabular-nums">{{ pct }}%</span>
</CardAction>
</CardHeader>
<CardContent>
<ul class="grid gap-2 text-sm">
<li v-for="(step, i) in steps" :key="i" class="flex items-center gap-2" :title="step.detail || undefined">
<Check v-if="step.done" class="size-3.5 shrink-0 text-ok" aria-label="Done" />
<Circle v-else class="size-3.5 shrink-0 text-fg-subtle" aria-label="To do" />
<span :class="step.done ? 'text-fg-muted' : 'font-medium'">{{ step.title }}</span>
<span v-if="!step.done && step.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ step.detail }}</span>
</li>
</ul>
</CardContent>
</Card>
</template>