Prevent renaming row actions

This commit is contained in:
Adria Navarro 2024-07-22 17:20:30 +02:00
parent d01bd54fd1
commit 703e2c1873
1 changed files with 16 additions and 2 deletions

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 { deleteEntityMetadata } from "../../../utilities"
import { MetadataTypes } from "../../../constants"
@ -117,7 +122,6 @@ export async function create(automation: Automation) {
export async function update(automation: Automation) {
automation = { ...automation }
if (!automation._id || !automation._rev) {
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
}