enable code block again (#1909)

This commit is contained in:
Shuchang Zheng
2025-03-09 20:31:21 -07:00
committed by GitHub
parent 8537a29b1c
commit 494e750e91
5 changed files with 133 additions and 39 deletions

View File

@@ -10,6 +10,6 @@ export type CodeBlockNode = Node<CodeBlockNodeData, "codeBlock">;
export const codeBlockNodeDefaultData: CodeBlockNodeData = {
editable: true,
label: "",
code: `# To assign a value to the output of this block,\n# assign the value to the variable 'result'\n# The final value of 'result' will be used as the output of this block\n\nresult = 5`,
code: `# All variables will be assigned to the output of this block.\n# Like 'x = 5', 'x' will be assigned to the output of this block.\n\n`,
continueOnFailure: false,
} as const;

View File

@@ -6,6 +6,8 @@ import { AddNodeProps } from "../FlowRenderer";
import { WorkflowBlockNode } from "../nodes";
import { WorkflowBlockIcon } from "../nodes/WorkflowBlockIcon";
const enableCodeBlock = import.meta.env.VITE_ENABLE_CODE_BLOCK === "true";
const nodeLibraryItems: Array<{
nodeType: NonNullable<WorkflowBlockNode["type"]>;
icon: JSX.Element;
@@ -134,16 +136,17 @@ const nodeLibraryItems: Array<{
title: "For Loop Block",
description: "Repeats nested elements",
},
// temporarily removed
// {
// nodeType: "codeBlock",
// icon: <WorkflowBlockIcon
// workflowBlockType={WorkflowBlockTypes.Code}
// className="size-6"
// />,
// title: "Code Block",
// description: "Executes Python code",
// },
{
nodeType: "codeBlock",
icon: (
<WorkflowBlockIcon
workflowBlockType={WorkflowBlockTypes.Code}
className="size-6"
/>
),
title: "Code Block",
description: "Executes Python code",
},
{
nodeType: "fileParser",
icon: (
@@ -257,6 +260,9 @@ function WorkflowNodeLibraryPanel({ onNodeClick, first }: Props) {
) {
return null;
}
if (!enableCodeBlock && item.nodeType === "codeBlock") {
return null;
}
return (
<div
key={item.nodeType}