Fixes some issues with row actions which were allowing them to be added from the automation section (which is not allowed) as well as breaking app access once they were added - this hides them properly so they can't be added as well as fixing the issue when they exist.
This commit is contained in:
parent
ba3f69ead9
commit
76652ddab5
|
@ -20,7 +20,7 @@
|
|||
.map(automation => ({
|
||||
...automation,
|
||||
displayName:
|
||||
$automationStore.automationDisplayData[automation._id].displayName ||
|
||||
$automationStore.automationDisplayData[automation._id]?.displayName ||
|
||||
automation.name,
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import * as triggers from "../../automations/triggers"
|
||||
import { sdk as coreSdk } from "@budibase/shared-core"
|
||||
import { DocumentType } from "../../db/utils"
|
||||
import { updateTestHistory, removeDeprecated } from "../../automations/utils"
|
||||
import {
|
||||
updateTestHistory,
|
||||
removeInvalidDefinitions,
|
||||
} from "../../automations/utils"
|
||||
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
|
||||
import { context, cache, events, db as dbCore } from "@budibase/backend-core"
|
||||
import { automations, features } from "@budibase/pro"
|
||||
|
@ -20,11 +23,11 @@ import { builderSocket } from "../../websockets"
|
|||
import env from "../../environment"
|
||||
|
||||
async function getActionDefinitions() {
|
||||
return removeDeprecated(await actionDefs())
|
||||
return removeInvalidDefinitions(await actionDefs())
|
||||
}
|
||||
|
||||
function getTriggerDefinitions() {
|
||||
return removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
||||
return removeInvalidDefinitions(triggers.TRIGGER_DEFINITIONS)
|
||||
}
|
||||
|
||||
/*************************
|
||||
|
|
|
@ -3,11 +3,17 @@ import { definitions } from "./triggerInfo"
|
|||
import { automationQueue } from "./bullboard"
|
||||
import { updateEntityMetadata } from "../utilities"
|
||||
import { MetadataTypes } from "../constants"
|
||||
import { db as dbCore, context, utils } from "@budibase/backend-core"
|
||||
import { context, db as dbCore, utils } from "@budibase/backend-core"
|
||||
import { getAutomationMetadataParams } from "../db/utils"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import { quotas } from "@budibase/pro"
|
||||
import { Automation, AutomationJob } from "@budibase/types"
|
||||
import {
|
||||
Automation,
|
||||
AutomationActionStepId,
|
||||
AutomationJob,
|
||||
AutomationStepSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
import { automationsEnabled } from "../features"
|
||||
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
||||
import tracer from "dd-trace"
|
||||
|
@ -111,10 +117,16 @@ export async function updateTestHistory(
|
|||
)
|
||||
}
|
||||
|
||||
export function removeDeprecated(definitions: any) {
|
||||
export function removeInvalidDefinitions(
|
||||
definitions: Record<string, AutomationStepSchema>
|
||||
) {
|
||||
const disallowedStepIds: (
|
||||
| AutomationTriggerStepId
|
||||
| AutomationActionStepId
|
||||
)[] = [AutomationTriggerStepId.ROW_ACTION]
|
||||
const base = cloneDeep(definitions)
|
||||
for (let key of Object.keys(base)) {
|
||||
if (base[key].deprecated) {
|
||||
if (base[key].deprecated || disallowedStepIds.includes(base[key].stepId)) {
|
||||
delete base[key]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,10 +87,10 @@ export async function fetch() {
|
|||
include_docs: true,
|
||||
})
|
||||
)
|
||||
return response.rows
|
||||
.map(row => row.doc)
|
||||
.filter(doc => !!doc)
|
||||
.map(trimUnexpectedObjectFields)
|
||||
const automations: PersistedAutomation[] = response.rows
|
||||
.filter(row => !!row.doc)
|
||||
.map(row => row.doc!)
|
||||
return automations.map(trimUnexpectedObjectFields)
|
||||
}
|
||||
|
||||
export async function get(automationId: string) {
|
||||
|
|
|
@ -29,8 +29,7 @@ export async function getBuilderData(
|
|||
const rowActionNameCache: Record<string, TableRowActions> = {}
|
||||
async function getRowActionName(tableId: string, rowActionId: string) {
|
||||
if (!rowActionNameCache[tableId]) {
|
||||
const rowActions = await sdk.rowActions.get(tableId)
|
||||
rowActionNameCache[tableId] = rowActions
|
||||
rowActionNameCache[tableId] = await sdk.rowActions.get(tableId)
|
||||
}
|
||||
|
||||
return rowActionNameCache[tableId].actions[rowActionId]?.name
|
||||
|
@ -45,9 +44,11 @@ export async function getBuilderData(
|
|||
}
|
||||
|
||||
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
||||
if (!tableId || !rowActionId) {
|
||||
continue
|
||||
}
|
||||
|
||||
const tableName = await getTableName(tableId)
|
||||
|
||||
const rowActionName = await getRowActionName(tableId, rowActionId)
|
||||
|
||||
result[automation._id!] = {
|
||||
|
|
|
@ -174,9 +174,7 @@ export interface AutomationStepSchema {
|
|||
deprecated?: boolean
|
||||
stepId: AutomationTriggerStepId | AutomationActionStepId
|
||||
blockToLoop?: string
|
||||
inputs: {
|
||||
[key: string]: any
|
||||
}
|
||||
inputs: Record<string, any>
|
||||
schema: {
|
||||
inputs: InputOutputBlock
|
||||
outputs: InputOutputBlock
|
||||
|
|
Loading…
Reference in New Issue