fix(ui): dismiss all alerts and show the full alert list

This commit is contained in:
sam committed 2026-10-18 23:48:42 +11:00
1 parent 5e62f8311f
commit 18d36b00bc
2 files changed
+21 -4

No files matched your search

+13 -3
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { Bell, X } from "@lucide/vue";
import { Bell, CheckCheck, X } from "@lucide/vue";
import { RouterLink } from "vue-router";
import { Badge } from "@/components/ui/badge";
@@ -9,7 +9,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover
import { groupBySeverity, type AlertSeverity, type OperatorAlert } from "./alerts";
import { useAlerts } from "./use-alerts";
const { alerts, failed, dismiss } = useAlerts();
const { alerts, failed, dismiss, dismissAll } = useAlerts();
const open = ref(false);
const groups = computed(() => groupBySeverity(alerts.value));
@@ -40,7 +40,17 @@ function failedDeliveries(alert: OperatorAlert): number {
<PopoverContent align="end" :collision-padding="8" class="w-[calc(100vw-1rem)] max-w-none p-0 sm:w-96">
<p v-if="failed" class="px-3 py-6 text-center text-sm text-danger" role="alert">Alerts could not be loaded.</p>
<p v-else-if="!groups.length" class="px-3 py-6 text-center text-sm text-fg-subtle">No alerts.</p>
<div v-else class="max-h-96 overflow-y-auto">
<div v-else class="relative max-h-[calc(100dvh-6rem)] overflow-y-auto">
<Button
variant="ghost"
size="icon-sm"
class="absolute top-1.5 right-1.5"
aria-label="Dismiss all"
title="Dismiss all"
@click="dismissAll"
>
<CheckCheck class="size-4" aria-hidden="true" />
</Button>
<section v-for="group in groups" :key="group.severity" class="border-b p-3 last:border-b-0">
<h3 class="mb-2 text-sm font-semibold">{{ group.label }}</h3>
<ul class="grid gap-3">
+8 -1
View File
@@ -39,10 +39,17 @@ export function useAlerts() {
}
}
async function dismissAll() {
const ids = alerts.value.map((a) => a.id);
alerts.value = [];
const results = await Promise.allSettled(ids.map((id) => api.dismissAlert(id)));
if (results.some((r) => r.status === "rejected")) await load();
}
const { activity, connectionRevision } = storeToRefs(useSessionStore());
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
watch(connectionRevision, load);
onMounted(load);
return { alerts, failed, dismiss };
return { alerts, failed, dismiss, dismissAll };
}