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 => ({
|
.map(automation => ({
|
||||||
...automation,
|
...automation,
|
||||||
displayName:
|
displayName:
|
||||||
$automationStore.automationDisplayData[automation._id].displayName ||
|
$automationStore.automationDisplayData[automation._id]?.displayName ||
|
||||||
automation.name,
|
automation.name,
|
||||||
}))
|
}))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import * as triggers from "../../automations/triggers"
|
import * as triggers from "../../automations/triggers"
|
||||||
import { sdk as coreSdk } from "@budibase/shared-core"
|
import { sdk as coreSdk } from "@budibase/shared-core"
|
||||||
import { DocumentType } from "../../db/utils"
|
import { DocumentType } from "../../db/utils"
|
||||||
import { updateTestHistory, removeDeprecated } from "../../automations/utils"
|
import {
|
||||||
|
updateTestHistory,
|
||||||
|
removeInvalidDefinitions,
|
||||||
|
} from "../../automations/utils"
|
||||||
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
|
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
|
||||||
import { context, cache, events, db as dbCore } from "@budibase/backend-core"
|
import { context, cache, events, db as dbCore } from "@budibase/backend-core"
|
||||||
import { automations, features } from "@budibase/pro"
|
import { automations, features } from "@budibase/pro"
|
||||||
|
@ -20,11 +23,11 @@ import { builderSocket } from "../../websockets"
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
|
|
||||||
async function getActionDefinitions() {
|
async function getActionDefinitions() {
|
||||||
return removeDeprecated(await actionDefs())
|
return removeInvalidDefinitions(await actionDefs())
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTriggerDefinitions() {
|
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 { automationQueue } from "./bullboard"
|
||||||
import { updateEntityMetadata } from "../utilities"
|
import { updateEntityMetadata } from "../utilities"
|
||||||
import { MetadataTypes } from "../constants"
|
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 { getAutomationMetadataParams } from "../db/utils"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { quotas } from "@budibase/pro"
|
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 { automationsEnabled } from "../features"
|
||||||
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
||||||
import tracer from "dd-trace"
|
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)
|
const base = cloneDeep(definitions)
|
||||||
for (let key of Object.keys(base)) {
|
for (let key of Object.keys(base)) {
|
||||||
if (base[key].deprecated) {
|
if (base[key].deprecated || disallowedStepIds.includes(base[key].stepId)) {
|
||||||
delete base[key]
|
delete base[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,10 +87,10 @@ export async function fetch() {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return response.rows
|
const automations: PersistedAutomation[] = response.rows
|
||||||
.map(row => row.doc)
|
.filter(row => !!row.doc)
|
||||||
.filter(doc => !!doc)
|
.map(row => row.doc!)
|
||||||
.map(trimUnexpectedObjectFields)
|
return automations.map(trimUnexpectedObjectFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get(automationId: string) {
|
export async function get(automationId: string) {
|
||||||
|
|
|
@ -29,8 +29,7 @@ export async function getBuilderData(
|
||||||
const rowActionNameCache: Record<string, TableRowActions> = {}
|
const rowActionNameCache: Record<string, TableRowActions> = {}
|
||||||
async function getRowActionName(tableId: string, rowActionId: string) {
|
async function getRowActionName(tableId: string, rowActionId: string) {
|
||||||
if (!rowActionNameCache[tableId]) {
|
if (!rowActionNameCache[tableId]) {
|
||||||
const rowActions = await sdk.rowActions.get(tableId)
|
rowActionNameCache[tableId] = await sdk.rowActions.get(tableId)
|
||||||
rowActionNameCache[tableId] = rowActions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowActionNameCache[tableId].actions[rowActionId]?.name
|
return rowActionNameCache[tableId].actions[rowActionId]?.name
|
||||||
|
@ -45,9 +44,11 @@ export async function getBuilderData(
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
||||||
|
if (!tableId || !rowActionId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const tableName = await getTableName(tableId)
|
const tableName = await getTableName(tableId)
|
||||||
|
|
||||||
const rowActionName = await getRowActionName(tableId, rowActionId)
|
const rowActionName = await getRowActionName(tableId, rowActionId)
|
||||||
|
|
||||||
result[automation._id!] = {
|
result[automation._id!] = {
|
||||||
|
|
|
@ -174,9 +174,7 @@ export interface AutomationStepSchema {
|
||||||
deprecated?: boolean
|
deprecated?: boolean
|
||||||
stepId: AutomationTriggerStepId | AutomationActionStepId
|
stepId: AutomationTriggerStepId | AutomationActionStepId
|
||||||
blockToLoop?: string
|
blockToLoop?: string
|
||||||
inputs: {
|
inputs: Record<string, any>
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
schema: {
|
schema: {
|
||||||
inputs: InputOutputBlock
|
inputs: InputOutputBlock
|
||||||
outputs: InputOutputBlock
|
outputs: InputOutputBlock
|
||||||
|
|
Loading…
Reference in New Issue