show all of the scripts via a button (#3295)
This commit is contained in:
@@ -95,15 +95,13 @@ function BlockCodeEditor({
|
|||||||
<div className="absolute right-[-0.5rem] top-0 flex h-[2rem] w-[2rem] items-center justify-center rounded hover:bg-slate-800">
|
<div className="absolute right-[-0.5rem] top-0 flex h-[2rem] w-[2rem] items-center justify-center rounded hover:bg-slate-800">
|
||||||
<ExitIcon
|
<ExitIcon
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (onExit) {
|
const result = onExit ? onExit() : true;
|
||||||
const result = onExit();
|
|
||||||
|
|
||||||
if (result !== false) {
|
if (result !== false) {
|
||||||
toggleScriptForNodeCallback({
|
toggleScriptForNodeCallback({
|
||||||
label: blockLabel,
|
label: blockLabel,
|
||||||
show: false,
|
show: false,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="size-5 cursor-pointer"
|
className="size-5 cursor-pointer"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { DotsHorizontalIcon } from "@radix-ui/react-icons";
|
|||||||
import { OrgWalled } from "@/components/Orgwalled";
|
import { OrgWalled } from "@/components/Orgwalled";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isDeleteable?: boolean;
|
isDeletable?: boolean;
|
||||||
isScriptable?: boolean;
|
isScriptable?: boolean;
|
||||||
showScriptText?: string;
|
showScriptText?: string;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
@@ -18,13 +18,13 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function NodeActionMenu({
|
function NodeActionMenu({
|
||||||
isDeleteable = true,
|
isDeletable = true,
|
||||||
isScriptable = false,
|
isScriptable = false,
|
||||||
showScriptText,
|
showScriptText,
|
||||||
onDelete,
|
onDelete,
|
||||||
onShowScript,
|
onShowScript,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
if (!isDeleteable && !isScriptable) {
|
if (!isDeletable && !isScriptable) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ function NodeActionMenu({
|
|||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuLabel>Block Actions</DropdownMenuLabel>
|
<DropdownMenuLabel>Block Actions</DropdownMenuLabel>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{isDeleteable && (
|
{isDeletable && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
onDelete?.();
|
onDelete?.();
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ import { KeyValueInput } from "@/components/KeyValueInput";
|
|||||||
import { OrgWalled } from "@/components/Orgwalled";
|
import { OrgWalled } from "@/components/Orgwalled";
|
||||||
import { placeholders } from "@/routes/workflows/editor/helpContent";
|
import { placeholders } from "@/routes/workflows/editor/helpContent";
|
||||||
import { NodeActionMenu } from "@/routes/workflows/editor/nodes/NodeActionMenu";
|
import { NodeActionMenu } from "@/routes/workflows/editor/nodes/NodeActionMenu";
|
||||||
|
import { useToggleScriptForNodeCallback } from "@/routes/workflows/hooks/useToggleScriptForNodeCallback";
|
||||||
import { useWorkflowSettingsStore } from "@/store/WorkflowSettingsStore";
|
import { useWorkflowSettingsStore } from "@/store/WorkflowSettingsStore";
|
||||||
import {
|
import {
|
||||||
scriptableWorkflowBlockTypes,
|
scriptableWorkflowBlockTypes,
|
||||||
type WorkflowBlockType,
|
type WorkflowBlockType,
|
||||||
} from "@/routes/workflows/types/workflowTypes";
|
} from "@/routes/workflows/types/workflowTypes";
|
||||||
// import { useToggleScriptForNodeCallback } from "@/routes/workflows/hooks/useToggleScriptForNodeCallback";
|
|
||||||
|
|
||||||
import { Flippable } from "@/components/Flippable";
|
import { Flippable } from "@/components/Flippable";
|
||||||
import { useRerender } from "@/hooks/useRerender";
|
import { useRerender } from "@/hooks/useRerender";
|
||||||
@@ -42,7 +42,6 @@ function StartNode({ id, data }: NodeProps<StartNode>) {
|
|||||||
const workflowSettingsStore = useWorkflowSettingsStore();
|
const workflowSettingsStore = useWorkflowSettingsStore();
|
||||||
const credentialGetter = useCredentialGetter();
|
const credentialGetter = useCredentialGetter();
|
||||||
const { updateNodeData } = useReactFlow();
|
const { updateNodeData } = useReactFlow();
|
||||||
// const toggleScriptForNodeCallback = useToggleScriptForNodeCallback();
|
|
||||||
const reactFlowInstance = useReactFlow();
|
const reactFlowInstance = useReactFlow();
|
||||||
|
|
||||||
const { data: availableModels } = useQuery<ModelsResponse>({
|
const { data: availableModels } = useQuery<ModelsResponse>({
|
||||||
@@ -83,6 +82,7 @@ function StartNode({ id, data }: NodeProps<StartNode>) {
|
|||||||
const blockScriptStore = useBlockScriptStore();
|
const blockScriptStore = useBlockScriptStore();
|
||||||
const script = blockScriptStore.scripts.__start_block__;
|
const script = blockScriptStore.scripts.__start_block__;
|
||||||
const rerender = useRerender({ prefix: "accordion" });
|
const rerender = useRerender({ prefix: "accordion" });
|
||||||
|
const toggleScriptForNodeCallback = useToggleScriptForNodeCallback();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFacing(data.showCode ? "back" : "front");
|
setFacing(data.showCode ? "back" : "front");
|
||||||
@@ -109,37 +109,31 @@ function StartNode({ id, data }: NodeProps<StartNode>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showAllScripts() {
|
function showAllScripts() {
|
||||||
reactFlowInstance.setNodes((nodes) => {
|
for (const node of reactFlowInstance.getNodes()) {
|
||||||
return nodes.map((node) => {
|
const label = node.data.label;
|
||||||
if (nodeIsFlippable(node)) {
|
|
||||||
return {
|
label &&
|
||||||
...node,
|
nodeIsFlippable(node) &&
|
||||||
data: {
|
typeof label === "string" &&
|
||||||
...node.data,
|
toggleScriptForNodeCallback({
|
||||||
showCode: true,
|
label,
|
||||||
},
|
show: true,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
return node;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideAllScripts() {
|
function hideAllScripts() {
|
||||||
reactFlowInstance.setNodes((nodes) => {
|
for (const node of reactFlowInstance.getNodes()) {
|
||||||
return nodes.map((node) => {
|
const label = node.data.label;
|
||||||
if (nodeIsFlippable(node)) {
|
|
||||||
return {
|
label &&
|
||||||
...node,
|
nodeIsFlippable(node) &&
|
||||||
data: {
|
typeof label === "string" &&
|
||||||
...node.data,
|
toggleScriptForNodeCallback({
|
||||||
showCode: false,
|
label,
|
||||||
},
|
show: false,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
return node;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.withWorkflowSettings) {
|
if (data.withWorkflowSettings) {
|
||||||
@@ -158,7 +152,7 @@ function StartNode({ id, data }: NodeProps<StartNode>) {
|
|||||||
<div>
|
<div>
|
||||||
<div className="rounded p-1 hover:bg-muted">
|
<div className="rounded p-1 hover:bg-muted">
|
||||||
<NodeActionMenu
|
<NodeActionMenu
|
||||||
isDeleteable={false}
|
isDeletable={false}
|
||||||
isScriptable={true}
|
isScriptable={true}
|
||||||
showScriptText="Show All Scripts"
|
showScriptText="Show All Scripts"
|
||||||
onShowScript={showAllScripts}
|
onShowScript={showAllScripts}
|
||||||
|
|||||||
Reference in New Issue
Block a user