1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Prevent renaming row actions

This commit is contained in:
Adria Navarro 2024-07-22 17:20:30 +02:00
parent d01bd54fd1
commit 703e2c1873

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 { generateAutomationID, getAutomationParams } from "../../../db/utils"
import { deleteEntityMetadata } from "../../../utilities" import { deleteEntityMetadata } from "../../../utilities"
import { MetadataTypes } from "../../../constants" import { MetadataTypes } from "../../../constants"
@ -117,7 +122,6 @@ export async function create(automation: Automation) {
export async function update(automation: Automation) { export async function update(automation: Automation) {
automation = { ...automation } automation = { ...automation }
if (!automation._id || !automation._rev) { if (!automation._id || !automation._rev) {
throw new HTTPError("_id or _rev fields missing", 400) throw new HTTPError("_id or _rev fields missing", 400)
} }
@ -281,4 +285,14 @@ function guardInvalidUpdatesAndThrow(
} }
}) })
} }
if (isRowAction(automation) && automation.name !== oldAutomation.name) {
throw new Error("Row actions cannot be renamed")
}
}
function isRowAction(automation: Automation) {
const result =
automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
return result
} }