Deprecate old JS script block, mark new one as... well, new.
This commit is contained in:
parent
bf281fdff5
commit
96869c2b4d
|
@ -186,6 +186,12 @@
|
|||
</div>
|
||||
{:else if isDisabled}
|
||||
<Icon name="Help" tooltip={disabled()[idx].message} />
|
||||
{:else if action.new}
|
||||
<div class="tag-color">
|
||||
<Tags>
|
||||
<Tag>New</Tag>
|
||||
</Tags>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,7 @@ import { EventEmitter } from "events"
|
|||
|
||||
export const definition: AutomationStepDefinition = {
|
||||
name: "JS Scripting",
|
||||
deprecated: true,
|
||||
tagline: "Execute JavaScript Code",
|
||||
icon: "Code",
|
||||
description: "Run a piece of JavaScript code in your automation",
|
||||
|
|
|
@ -12,12 +12,13 @@ import {
|
|||
import { processStringSync } from "@budibase/string-templates"
|
||||
|
||||
export const definition: AutomationStepDefinition = {
|
||||
name: "JS Scripting V2",
|
||||
name: "JS Scripting",
|
||||
tagline: "Execute JavaScript Code",
|
||||
icon: "Code",
|
||||
description: "Run a piece of JavaScript code in your automation",
|
||||
type: AutomationStepType.ACTION,
|
||||
internal: true,
|
||||
new: true,
|
||||
stepId: AutomationActionStepId.EXECUTE_SCRIPT_V2,
|
||||
inputs: {},
|
||||
features: {
|
||||
|
@ -57,7 +58,9 @@ export async function run({
|
|||
inputs: ExecuteScriptStepInputs
|
||||
context: Record<string, any>
|
||||
}): Promise<ExecuteScriptStepOutputs> {
|
||||
if (inputs.code == null) {
|
||||
let { code } = inputs
|
||||
|
||||
if (code == null) {
|
||||
return {
|
||||
success: false,
|
||||
response: {
|
||||
|
@ -66,6 +69,17 @@ export async function run({
|
|||
}
|
||||
}
|
||||
|
||||
code = code.trim()
|
||||
|
||||
if (!code.startsWith("{{ js ")) {
|
||||
return {
|
||||
success: false,
|
||||
response: {
|
||||
message: "Expected code to be a {{ js }} template block",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return {
|
||||
success: true,
|
||||
|
|
|
@ -154,6 +154,7 @@ export interface AutomationStepSchemaBase {
|
|||
type: AutomationStepType
|
||||
internal?: boolean
|
||||
deprecated?: boolean
|
||||
new?: boolean
|
||||
blockToLoop?: string
|
||||
schema: {
|
||||
inputs: InputOutputBlock
|
||||
|
|
Loading…
Reference in New Issue