Updating filter/condition action to show a stopped status rather than error, updating everything else to be aware of this.
This commit is contained in:
parent
a01790b837
commit
e921547c64
|
@ -19,6 +19,7 @@
|
|||
}
|
||||
}
|
||||
$: isTrigger = isTrigger || block.type === "TRIGGER"
|
||||
$: status = updateStatus(testResult, isTrigger)
|
||||
|
||||
async function onSelect(block) {
|
||||
await automationStore.update(state => {
|
||||
|
@ -26,6 +27,16 @@
|
|||
return state
|
||||
})
|
||||
}
|
||||
|
||||
function updateStatus(results, isTrigger) {
|
||||
if (results.outputs?.status?.toLowerCase() === "stopped") {
|
||||
return { yellow: true, message: "Stopped" }
|
||||
} else if (results.outputs?.success || isTrigger) {
|
||||
return { positive: true, message: "Success" }
|
||||
} else {
|
||||
return { negative: true, message: "Error" }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="blockSection">
|
||||
|
@ -69,13 +80,10 @@
|
|||
{#if showTestStatus && testResult}
|
||||
<div style="float: right;">
|
||||
<StatusLight
|
||||
positive={isTrigger || testResult.outputs?.success}
|
||||
negative={!testResult.outputs?.success}
|
||||
><Body size="XS"
|
||||
>{testResult.outputs?.success || isTrigger
|
||||
? "Success"
|
||||
: "Error"}</Body
|
||||
></StatusLight
|
||||
positive={status?.positive}
|
||||
yellow={status?.yellow}
|
||||
negative={status?.negative}
|
||||
><Body size="XS">{status?.message}</Body></StatusLight
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
import dayjs from "dayjs"
|
||||
|
||||
const ERROR = "error",
|
||||
SUCCESS = "success"
|
||||
SUCCESS = "success",
|
||||
STOPPED = "stopped"
|
||||
export let app
|
||||
|
||||
let runHistory = null
|
||||
|
@ -37,6 +38,7 @@
|
|||
const statusOptions = [
|
||||
{ value: SUCCESS, label: "Success" },
|
||||
{ value: ERROR, label: "Error" },
|
||||
{ value: STOPPED, label: "Stopped" },
|
||||
]
|
||||
|
||||
const runHistorySchema = {
|
||||
|
|
|
@ -3,15 +3,28 @@
|
|||
export let value
|
||||
|
||||
$: isError = !value || value.toLowerCase() === "error"
|
||||
$: color = isError
|
||||
? "var(--spectrum-semantic-negative-color-background)"
|
||||
: "var(--green)"
|
||||
$: isStopped = value?.toLowerCase() === "stopped"
|
||||
$: status = getStatus(isError, isStopped)
|
||||
|
||||
function getStatus(error, stopped) {
|
||||
if (error) {
|
||||
return { color: "var(--red)", message: "Error", icon: "Alert" }
|
||||
} else if (stopped) {
|
||||
return { color: "var(--yellow)", message: "Stopped", icon: "StopCircle" }
|
||||
} else {
|
||||
return {
|
||||
color: "var(--green)",
|
||||
message: "Success",
|
||||
icon: "CheckmarkCircle",
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="cell">
|
||||
<Icon {color} name={isError ? "Alert" : "CheckmarkCircle"} />
|
||||
<div class:green={!isError} class:red={isError}>
|
||||
{isError ? "Error" : "Success"}
|
||||
<Icon color={status.color} name={status.icon} />
|
||||
<div style={`color: ${status.color};`}>
|
||||
{status.message}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -22,12 +35,4 @@
|
|||
gap: var(--spacing-m);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.red {
|
||||
color: var(--spectrum-semantic-negative-color-background);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -2,8 +2,8 @@ import { getAppId, getProdAppDB } from "@budibase/backend-core/context"
|
|||
import {
|
||||
DocumentTypes,
|
||||
generateAutomationLogID,
|
||||
SEPARATOR,
|
||||
isProdAppID,
|
||||
SEPARATOR,
|
||||
} from "../../db/utils"
|
||||
import { Automation, MetadataErrors } from "../../definitions/common"
|
||||
import { app } from "@budibase/backend-core/cache"
|
||||
|
@ -14,6 +14,7 @@ import {
|
|||
AutomationResults,
|
||||
AutomationStatus,
|
||||
} from "../../definitions/automation"
|
||||
|
||||
const { logAlert } = require("@budibase/backend-core/logging")
|
||||
|
||||
function getStatus(results: AutomationResults) {
|
||||
|
@ -27,6 +28,10 @@ function getStatus(results: AutomationResults) {
|
|||
}
|
||||
if (!step.outputs?.success) {
|
||||
status = AutomationStatus.ERROR
|
||||
break
|
||||
} else if (step.outputs?.status?.toLowerCase() === "stopped") {
|
||||
status = AutomationStatus.STOPPED
|
||||
break
|
||||
}
|
||||
}
|
||||
return status
|
||||
|
|
|
@ -50,43 +50,51 @@ exports.definition = {
|
|||
outputs: {
|
||||
properties: {
|
||||
success: {
|
||||
type: "boolean",
|
||||
description: "Whether the action was successful",
|
||||
},
|
||||
result: {
|
||||
type: "boolean",
|
||||
description: "Whether the logic block passed",
|
||||
},
|
||||
},
|
||||
required: ["success"],
|
||||
required: ["success", "result"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
exports.run = async function filter({ inputs }) {
|
||||
let { field, condition, value } = inputs
|
||||
// coerce types so that we can use them
|
||||
if (!isNaN(value) && !isNaN(field)) {
|
||||
value = parseFloat(value)
|
||||
field = parseFloat(field)
|
||||
} else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
|
||||
value = Date.parse(value)
|
||||
field = Date.parse(field)
|
||||
}
|
||||
let success = false
|
||||
if (typeof field !== "object" && typeof value !== "object") {
|
||||
switch (condition) {
|
||||
case FilterConditions.EQUAL:
|
||||
success = field === value
|
||||
break
|
||||
case FilterConditions.NOT_EQUAL:
|
||||
success = field !== value
|
||||
break
|
||||
case FilterConditions.GREATER_THAN:
|
||||
success = field > value
|
||||
break
|
||||
case FilterConditions.LESS_THAN:
|
||||
success = field < value
|
||||
break
|
||||
try {
|
||||
let { field, condition, value } = inputs
|
||||
// coerce types so that we can use them
|
||||
if (!isNaN(value) && !isNaN(field)) {
|
||||
value = parseFloat(value)
|
||||
field = parseFloat(field)
|
||||
} else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
|
||||
value = Date.parse(value)
|
||||
field = Date.parse(field)
|
||||
}
|
||||
} else {
|
||||
success = false
|
||||
let result = false
|
||||
if (typeof field !== "object" && typeof value !== "object") {
|
||||
switch (condition) {
|
||||
case FilterConditions.EQUAL:
|
||||
result = field === value
|
||||
break
|
||||
case FilterConditions.NOT_EQUAL:
|
||||
result = field !== value
|
||||
break
|
||||
case FilterConditions.GREATER_THAN:
|
||||
result = field > value
|
||||
break
|
||||
case FilterConditions.LESS_THAN:
|
||||
result = field < value
|
||||
break
|
||||
}
|
||||
} else {
|
||||
result = false
|
||||
}
|
||||
return { success: true, result }
|
||||
} catch (err) {
|
||||
return { success: false, result: false }
|
||||
}
|
||||
return { success }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export enum AutomationStatus {
|
||||
SUCCESS = "success",
|
||||
ERROR = "error",
|
||||
STOPPED = "stopped",
|
||||
}
|
||||
|
||||
export interface AutomationResults {
|
||||
|
|
|
@ -14,7 +14,7 @@ const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
|||
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
|
||||
|
||||
const CRON_STEP_ID = triggerDefs.CRON.stepId
|
||||
const STOPPED_STATUS = { success: false, status: "STOPPED" }
|
||||
const STOPPED_STATUS = { success: true, status: "STOPPED" }
|
||||
const { cloneDeep } = require("lodash/fp")
|
||||
const env = require("../environment")
|
||||
|
||||
|
@ -276,7 +276,7 @@ class Orchestrator {
|
|||
this._context.steps[stepCount] = outputs
|
||||
// if filter causes us to stop execution don't break the loop, set a var
|
||||
// so that we can finish iterating through the steps and record that it stopped
|
||||
if (step.stepId === FILTER_STEP_ID && !outputs.success) {
|
||||
if (step.stepId === FILTER_STEP_ID && !outputs.result) {
|
||||
stopped = true
|
||||
this.updateExecutionOutput(step.id, step.stepId, step.inputs, {
|
||||
...outputs,
|
||||
|
|
Loading…
Reference in New Issue