Enrich
This commit is contained in:
parent
1b2182a690
commit
6221b9320e
|
@ -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 => {
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue