1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00
This commit is contained in:
Adria Navarro 2024-07-19 12:24:45 +02:00
parent 1b2182a690
commit 6221b9320e
4 changed files with 35 additions and 6 deletions

View file

@ -59,7 +59,7 @@ const automationActions = store => ({
},
fetch: async () => {
const responses = await Promise.all([
API.getAutomations(),
API.getAutomations({ enrich: true }),
API.getAutomationDefinitions(),
])
store.update(state => {

View file

@ -26,9 +26,13 @@ export const buildAutomationEndpoints = API => ({
/**
* Gets a list of all automations.
*/
getAutomations: async () => {
getAutomations: async ({ enrich }) => {
let url = "/api/automations?"
if (enrich) {
url += "enrich=true"
}
return await API.get({
url: "/api/automations",
url,
})
},

View file

@ -74,7 +74,14 @@ export async function update(ctx: UserCtx) {
}
export async function fetch(ctx: UserCtx) {
ctx.body = await sdk.automations.fetch()
const enrich = ctx.request.query["enrich"] === "true"
const automations = await sdk.automations.fetch()
if (enrich) {
ctx.body = await sdk.automations.enrichDisplayData(automations)
} else {
ctx.body = automations
}
}
export async function find(ctx: UserCtx) {

View file

@ -1,4 +1,9 @@
import { Automation, Webhook, WebhookActionType } from "@budibase/types"
import {
Automation,
AutomationTriggerStepId,
Webhook,
WebhookActionType,
} from "@budibase/types"
import { generateAutomationID, getAutomationParams } from "../../../db/utils"
import { deleteEntityMetadata } from "../../../utilities"
import { MetadataTypes } from "../../../constants"
@ -81,7 +86,7 @@ export async function fetch() {
include_docs: true,
})
)
return response.rows.map(row => row.doc)
return response.rows.map(row => row.doc).filter(doc => !!doc)
}
export async function get(automationId: string) {
@ -254,6 +259,7 @@ async function checkForWebhooks({ oldAuto, newAuto }: any) {
}
return newAuto
}
function guardInvalidUpdatesAndThrow(
automation: Automation,
oldAutomation: Automation
@ -281,3 +287,15 @@ function guardInvalidUpdatesAndThrow(
})
}
}
export async function enrichDisplayData(automations: Automation[]) {
const rowActionAutomations = automations.filter(
({ definition }) =>
definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
)
for (const automation of rowActionAutomations) {
automation.name = `TODO: ${automation.name}`
}
return automations
}