enable code view for taskv2 block (#3443)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { Flippable } from "@/components/Flippable";
|
||||||
import { HelpTooltip } from "@/components/HelpTooltip";
|
import { HelpTooltip } from "@/components/HelpTooltip";
|
||||||
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
|
import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";
|
||||||
import {
|
import {
|
||||||
@@ -10,7 +12,6 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Handle, NodeProps, Position, useReactFlow } from "@xyflow/react";
|
import { Handle, NodeProps, Position, useReactFlow } from "@xyflow/react";
|
||||||
import { useState } from "react";
|
|
||||||
import { helpTooltips, placeholders } from "../../helpContent";
|
import { helpTooltips, placeholders } from "../../helpContent";
|
||||||
import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow";
|
import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow";
|
||||||
import { MAX_STEPS_DEFAULT, type Taskv2Node } from "./types";
|
import { MAX_STEPS_DEFAULT, type Taskv2Node } from "./types";
|
||||||
@@ -22,6 +23,8 @@ import { useParams } from "react-router-dom";
|
|||||||
import { statusIsRunningOrQueued } from "@/routes/tasks/types";
|
import { statusIsRunningOrQueued } from "@/routes/tasks/types";
|
||||||
import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";
|
import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";
|
||||||
import { useRerender } from "@/hooks/useRerender";
|
import { useRerender } from "@/hooks/useRerender";
|
||||||
|
import { BlockCodeEditor } from "@/routes/workflows/components/BlockCodeEditor";
|
||||||
|
import { useBlockScriptStore } from "@/store/BlockScriptStore";
|
||||||
|
|
||||||
function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
||||||
const { editable, label } = data;
|
const { editable, label } = data;
|
||||||
@@ -34,6 +37,9 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
|||||||
const thisBlockIsPlaying =
|
const thisBlockIsPlaying =
|
||||||
workflowRunIsRunningOrQueued && thisBlockIsTargetted;
|
workflowRunIsRunningOrQueued && thisBlockIsTargetted;
|
||||||
const { updateNodeData } = useReactFlow();
|
const { updateNodeData } = useReactFlow();
|
||||||
|
const [facing, setFacing] = useState<"front" | "back">("front");
|
||||||
|
const blockScriptStore = useBlockScriptStore();
|
||||||
|
const script = blockScriptStore.scripts[label];
|
||||||
const isFirstWorkflowBlock = useIsFirstBlockInWorkflow({ id });
|
const isFirstWorkflowBlock = useIsFirstBlockInWorkflow({ id });
|
||||||
const rerender = useRerender({ prefix: "accordian" });
|
const rerender = useRerender({ prefix: "accordian" });
|
||||||
|
|
||||||
@@ -54,7 +60,12 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
|||||||
updateNodeData(id, { [key]: value });
|
updateNodeData(id, { [key]: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setFacing(data.showCode ? "back" : "front");
|
||||||
|
}, [data.showCode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Flippable facing={facing} preserveFrontsideHeight={true}>
|
||||||
<div>
|
<div>
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
@@ -141,7 +152,9 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
|||||||
/>
|
/>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Label className="text-xs text-slate-300">Max Steps</Label>
|
<Label className="text-xs text-slate-300">
|
||||||
|
Max Steps
|
||||||
|
</Label>
|
||||||
<HelpTooltip content={helpTooltips[type]["maxSteps"]} />
|
<HelpTooltip content={helpTooltips[type]["maxSteps"]} />
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
@@ -199,6 +212,9 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
|
|||||||
<NodeTabs blockLabel={label} />
|
<NodeTabs blockLabel={label} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<BlockCodeEditor blockLabel={label} blockType="task_v2" script={script} />
|
||||||
|
</Flippable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ export const scriptableWorkflowBlockTypes: Set<WorkflowBlockType> = new Set([
|
|||||||
"login",
|
"login",
|
||||||
"navigation",
|
"navigation",
|
||||||
"task",
|
"task",
|
||||||
|
"task_v2",
|
||||||
"validation",
|
"validation",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user