From e068e301ff230ca3d3290b0ec999759e4cc85c66 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 16 Aug 2023 18:21:53 +0100 Subject: [PATCH] Updating automation history tab to handle the stopped error status which can occur for CRONs. --- .../_components/StatusRenderer.svelte | 10 ++++++---- .../settings/automation-history/index.svelte | 4 +++- packages/server/src/threads/automation.ts | 6 +++++- packages/types/src/documents/app/automation.ts | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte index f041faa349..fd289163b4 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte @@ -4,11 +4,13 @@ $: isError = !value || value.toLowerCase() === "error" $: isStoppedError = value?.toLowerCase() === "stopped_error" - $: isStopped = value?.toLowerCase() === "stopped" || isStoppedError - $: info = getInfo(isError, isStopped) + $: isStopped = value?.toLowerCase() === "stopped" + $: info = getInfo(isError, isStopped, isStoppedError) - const getInfo = (error, stopped) => { - if (error) { + function getInfo(error, stopped, stoppedError) { + if (stoppedError) { + return { color: "red", message: "Stopped - Error" } + } else if (error) { return { color: "red", message: "Error" } } else if (stopped) { return { color: "yellow", message: "Stopped" } diff --git a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/index.svelte b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/index.svelte index 190ced4b36..373a47aa2e 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/index.svelte @@ -22,7 +22,8 @@ const ERROR = "error", SUCCESS = "success", - STOPPED = "stopped" + STOPPED = "stopped", + STOPPED_ERROR = "stopped_error" const sidePanel = getContext("side-panel") let pageInfo = createPaginationStore() @@ -52,6 +53,7 @@ { value: SUCCESS, label: "Success" }, { value: ERROR, label: "Error" }, { value: STOPPED, label: "Stopped" }, + { value: STOPPED_ERROR, label: "Stopped - Error" }, ] const runHistorySchema = { diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 8bf0b506fe..fc64e206d6 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -20,6 +20,7 @@ import { AutomationMetadata, AutomationStatus, AutomationStep, + AutomationStepStatus, } from "@budibase/types" import { AutomationContext, @@ -452,7 +453,10 @@ class Orchestrator { this.executionOutput.steps.splice(loopStepNumber + 1, 0, { id: step.id, stepId: step.stepId, - outputs: { status: AutomationStatus.NO_ITERATIONS, success: true }, + outputs: { + status: AutomationStepStatus.NO_ITERATIONS, + success: true, + }, inputs: {}, }) diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts index 05ac76d5e9..f4a0dd33f2 100644 --- a/packages/types/src/documents/app/automation.ts +++ b/packages/types/src/documents/app/automation.ts @@ -179,12 +179,15 @@ export interface AutomationTrigger extends AutomationTriggerSchema { id: string } +export enum AutomationStepStatus { + NO_ITERATIONS = "no_iterations", +} + export enum AutomationStatus { SUCCESS = "success", ERROR = "error", STOPPED = "stopped", STOPPED_ERROR = "stopped_error", - NO_ITERATIONS = "no_iterations", } export interface AutomationResults {