diff --git a/frontend/plugin-page/src/App.vue b/frontend/plugin-page/src/App.vue index 46d3111..e8a3410 100644 --- a/frontend/plugin-page/src/App.vue +++ b/frontend/plugin-page/src/App.vue @@ -4,9 +4,11 @@ import { endpoints } from "../../shared/api/endpoints" import { getJson } from "../../shared/api/client" import type { UiBootstrap } from "../../shared/types/bootstrap" import type { DashboardSummary } from "../../shared/types/dashboard" +import type { UiAction } from "../../shared/types/ui" const bootstrap = ref(null) const dashboard = ref(null) +const uiActions = ref([]) const loading = ref(true) const error = ref("") @@ -36,12 +38,10 @@ const text = { } as const const workbenchUrl = computed(() => `${bootstrap.value?.api_base ?? ""}/web`) -const quickLinks = computed(() => [ - { label: text.openJobs, href: workbenchViewUrl("jobs") }, - { label: text.openLogs, href: workbenchViewUrl("logs") }, - { label: text.openSettings, href: workbenchViewUrl("settings") }, - { label: text.openMaterials, href: workbenchViewUrl("materials") }, -]) +const quickLinks = computed(() => { + const actionLinks = uiActions.value.map(actionToLink).filter((link): link is { label: string; href: string } => Boolean(link)) + return actionLinks.length ? actionLinks : fallbackQuickLinks() +}) const queueTotal = computed(() => { const queue = dashboard.value?.queue return queue ? queue.pending + queue.running + queue.failed + queue.dead_letter : 0 @@ -59,6 +59,11 @@ async function load() { ]) bootstrap.value = bootstrapData dashboard.value = dashboardData + try { + uiActions.value = await getJson(endpoints.uiActions) + } catch { + uiActions.value = [] + } } catch (err) { error.value = err instanceof Error ? err.message : text.loadFailed } finally { @@ -76,6 +81,37 @@ function formatBytes(value = 0) { function workbenchViewUrl(view: string) { return `${workbenchUrl.value}?view=${encodeURIComponent(view)}` } + +function fallbackQuickLinks() { + return [ + { label: text.openJobs, href: workbenchViewUrl("jobs") }, + { label: text.openLogs, href: workbenchViewUrl("logs") }, + { label: text.openSettings, href: workbenchViewUrl("settings") }, + { label: text.openMaterials, href: workbenchViewUrl("materials") }, + ] +} + +function actionToLink(action: UiAction) { + if (!bootstrap.value) return null + if (action.action_type === "open_workbench") { + return { label: actionLabel(action), href: String(action.payload.url || workbenchUrl.value) } + } + const view = action.payload.view + if (typeof view === "string") { + return { label: actionLabel(action), href: workbenchViewUrl(view) } + } + return null +} + +function actionLabel(action: UiAction) { + const labels: Record = { + open_workbench: text.workbench, + quick_profile: text.profiles, + open_logs: text.openLogs, + open_settings: text.openSettings, + } + return labels[action.action_id] ?? action.label +}