Cleanup dead code
This commit is contained in:
parent
e67352d51b
commit
998d0002b8
|
@ -1,56 +1,7 @@
|
||||||
import {
|
import { Automation, AutomationActionStepId } from "@budibase/types"
|
||||||
Automation,
|
|
||||||
AutomationActionStepId,
|
|
||||||
AutomationBuilderData,
|
|
||||||
} from "@budibase/types"
|
|
||||||
import { sdk as coreSdk } from "@budibase/shared-core"
|
|
||||||
import sdk from "../../../sdk"
|
|
||||||
|
|
||||||
export function checkForCollectStep(automation: Automation) {
|
export function checkForCollectStep(automation: Automation) {
|
||||||
return automation.definition.steps.some(
|
return automation.definition.steps.some(
|
||||||
(step: any) => step.stepId === AutomationActionStepId.COLLECT
|
(step: any) => step.stepId === AutomationActionStepId.COLLECT
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getBuilderData(
|
|
||||||
automations: Automation[]
|
|
||||||
): Promise<Record<string, AutomationBuilderData>> {
|
|
||||||
const tableNameCache: Record<string, string> = {}
|
|
||||||
async function getTableName(tableId: string) {
|
|
||||||
if (!tableNameCache[tableId]) {
|
|
||||||
const table = await sdk.tables.getTable(tableId)
|
|
||||||
tableNameCache[tableId] = table.name
|
|
||||||
}
|
|
||||||
|
|
||||||
return tableNameCache[tableId]
|
|
||||||
}
|
|
||||||
|
|
||||||
const result: Record<string, AutomationBuilderData> = {}
|
|
||||||
for (const automation of automations) {
|
|
||||||
const isRowAction = coreSdk.automations.isRowAction(automation)
|
|
||||||
if (!isRowAction) {
|
|
||||||
result[automation._id!] = { displayName: automation.name }
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
|
||||||
if (!tableId || !rowActionId) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const tableName = await getTableName(tableId)
|
|
||||||
const rowActionName = automation.name
|
|
||||||
result[automation._id!] = {
|
|
||||||
displayName: rowActionName,
|
|
||||||
triggerInfo: {
|
|
||||||
type: "Automation trigger",
|
|
||||||
table: { id: tableId, name: tableName },
|
|
||||||
rowAction: {
|
|
||||||
id: rowActionId,
|
|
||||||
name: rowActionName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue