fix(ui/org): failures read from the error catalogue

This commit is contained in:
sam committed 2026-11-13 13:41:32 +11:00
1 parent cdd636d5aa
commit 47a340bf79
47 files changed
+236 -104

No files matched your search

+5 -3
View File
@@ -12,13 +12,15 @@ import {
} from "@/components/ui/dropdown-menu";
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "@/components/ui/sidebar";
import { useOrgStore } from "@/stores/org";
import { errors } from "@/copy/errors";
import { describeError } from "@/lib/api";
const orgStore = useOrgStore();
const { homeOrg, memberOrgs, orgs } = storeToRefs(orgStore);
const { isMobile } = useSidebar();
const failed = ref("");
onMounted(() => void orgStore.loadOrg().catch((cause) => (failed.value = String((cause as Error).message || cause))));
onMounted(() => void orgStore.loadOrg().catch((cause) => (failed.value = describeError(cause, errors.common.unknown))));
const choices = computed(() => orgs.value.filter((o) => memberOrgs.value.includes(o.id)));
const active = computed(() => orgs.value.find((o) => o.id === homeOrg.value));
@@ -30,7 +32,7 @@ async function choose(id: string): Promise<void> {
try {
await orgStore.actInOrg(id);
} catch (cause) {
failed.value = String((cause as Error).message || cause);
failed.value = describeError(cause, errors.common.unknown);
}
}
</script>
@@ -50,7 +52,7 @@ async function choose(id: string): Promise<void> {
{{ active ? initial(active.name) : failed ? "!" : "…" }}
</div>
<div class="grid flex-1 text-left leading-tight">
<span class="truncate text-label font-medium">{{ active?.name ?? (failed ? "Organisations unavailable" : "Loading…") }}</span>
<span class="truncate text-label font-medium">{{ active?.name ?? (failed ? errors.components.org.unavailable : "Loading…") }}</span>
</div>
<ChevronsUpDown v-if="choices.length > 1" class="ml-auto" aria-hidden="true" />
</SidebarMenuButton>
@@ -14,6 +14,7 @@ import {
} from "@/components/ui/command";
import { Kbd } from "@/components/ui/kbd";
import { api } from "@/lib/api";
import { errors } from "@/copy/errors";
import { navEntries } from "@/lib/nav";
import { statusLabel } from "@/lib/task-meta";
@@ -125,7 +126,7 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
</CommandItem>
</CommandGroup>
<CommandGroup v-if="workflowsError" heading="Workflows">
<CommandItem value="workflows-error" @select="loadEntries">Couldn't load workflows — Retry</CommandItem>
<CommandItem value="workflows-error" @select="loadEntries">{{ errors.components.commandPalette.workflows }}</CommandItem>
</CommandGroup>
<CommandGroup v-else-if="workflows.length" heading="Workflows">
<CommandItem
@@ -138,7 +139,7 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
</CommandItem>
</CommandGroup>
<CommandGroup v-if="tasksError" heading="Tasks">
<CommandItem value="tasks-error" @select="loadEntries">Couldn't load tasks — Retry</CommandItem>
<CommandItem value="tasks-error" @select="loadEntries">{{ errors.components.commandPalette.tasks }}</CommandItem>
</CommandGroup>
<CommandGroup v-else-if="tasks.length" heading="Tasks">
<CommandItem
+5 -3
View File
@@ -11,16 +11,18 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { useOrgStore } from "@/stores/org";
import { errors } from "@/copy/errors";
import { describeError } from "@/lib/api";
import { useHoverOpen } from "./hover-open";
const orgStore = useOrgStore();
const { homeOrg, memberOrgs, orgs } = storeToRefs(orgStore);
const failed = ref("");
onMounted(() => void orgStore.loadOrg().catch((cause) => (failed.value = String((cause as Error).message || cause))));
onMounted(() => void orgStore.loadOrg().catch((cause) => (failed.value = describeError(cause, errors.common.unknown))));
const choices = computed(() => orgs.value.filter((o) => memberOrgs.value.includes(o.id)));
const name = computed(() => orgs.value.find((o) => o.id === homeOrg.value)?.name ?? (failed.value ? "Organisations unavailable" : "Loading…"));
const name = computed(() => orgs.value.find((o) => o.id === homeOrg.value)?.name ?? (failed.value ? errors.components.org.unavailable : "Loading…"));
async function choose(id: string): Promise<void> {
if (id === homeOrg.value) return;
@@ -28,7 +30,7 @@ async function choose(id: string): Promise<void> {
try {
await orgStore.actInOrg(id);
} catch (cause) {
failed.value = String((cause as Error).message || cause);
failed.value = describeError(cause, errors.common.unknown);
}
}