From 183bf9a84a4c445a714ed64f482a37571fa1da35 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 9 Jan 2023 09:20:26 +0000 Subject: [PATCH] Fix automation error linking from apps page and improve automation fetching logic in automation history --- .../pages/builder/portal/apps/index.svelte | 3 +-- .../[appId]/automation-history/index.svelte | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 07f9cce35e..69d3d3c69b 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -95,10 +95,9 @@ const goToAutomationError = appId => { const params = new URLSearchParams({ - tab: "Automation History", open: "error", }) - $goto(`../overview/${appId}?${params.toString()}`) + $goto(`../overview/${appId}/automation-history?${params.toString()}`) } const errorCount = errors => { diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte index 3968011914..30f77696f4 100644 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte @@ -33,6 +33,7 @@ let automationId = null let status = null let timeRange = null + let loaded = false $: licensePlan = $auth.user?.license?.plan $: app = $overview.selectedApp @@ -66,7 +67,16 @@ { column: "status", component: StatusRenderer }, ] - async function fetchLogs(automationId, status, page, timeRange) { + async function fetchLogs( + automationId, + status, + page, + timeRange, + force = false + ) { + if (!force && !loaded) { + return + } let startDate = null if (timeRange) { const [length, units] = timeRange.split("-") @@ -118,19 +128,19 @@ await automationStore.actions.fetch() const params = new URLSearchParams(window.location.search) const shouldOpen = params.get("open") === ERROR - // open with errors, open panel for latest if (shouldOpen) { status = ERROR } - await automationStore.actions.fetch() - await fetchLogs(null, status) - if (shouldOpen) { - viewDetails({ detail: runHistory[0] }) - } automationOptions = [] for (let automation of $automationStore.automations) { automationOptions.push({ value: automation._id, label: automation.name }) } + await fetchLogs(automationId, status, 0, timeRange, true) + // Open the first automation info if one exists + if (shouldOpen && runHistory?.[0]) { + viewDetails({ detail: runHistory[0] }) + } + loaded = true }) onDestroy(() => {