1
1
import clsx from "clsx" ;
2
- import React from "react" ;
2
+ import React , { FC } from "react" ;
3
3
import { FaBars } from "react-icons/fa" ;
4
4
import type { Edge , Node } from "reactflow" ;
5
5
6
- import type { DisplayProps } from "./Sidebar" ;
7
6
import Sidebar from "./Sidebar" ;
8
7
import type { createNodeType , updateNodeType } from "../../hooks/useWorkflow" ;
9
8
import { findParents } from "../../services/graph-utils" ;
@@ -12,6 +11,7 @@ import {
12
11
getNodeBlockDefinitionFromNode ,
13
12
getNodeBlockDefinitions ,
14
13
} from "../../services/workflow/node-block-definitions" ;
14
+ import { useLayoutStore } from "../../stores/layoutStore" ;
15
15
import type { WorkflowEdge , WorkflowNode } from "../../types/workflow" ;
16
16
import WorkflowSidebarInput from "../../ui/WorkflowSidebarInput" ;
17
17
import PrimaryButton from "../PrimaryButton" ;
@@ -24,29 +24,21 @@ type WorkflowControls = {
24
24
updateNode : updateNodeType ;
25
25
} ;
26
26
27
- type WorkflowSidebarProps = DisplayProps & {
28
- controls : WorkflowControls ;
29
- } ;
30
-
31
- // Wrapper HOC to curry the createNode function
32
- export const getWorkflowSidebar = ( controls : WorkflowControls ) => {
33
- const WorkflowSidebarHOC = ( { show, setShow } : DisplayProps ) => (
34
- < WorkflowSidebar show = { show } setShow = { setShow } controls = { controls } />
35
- ) ;
36
- WorkflowSidebarHOC . displayName = "WorkflowSidebarHOC" ;
37
- return WorkflowSidebarHOC ;
38
- } ;
39
-
40
- const WorkflowSidebar = ( { show, setShow, controls } : WorkflowSidebarProps ) => {
27
+ const WorkflowSidebar : FC < WorkflowControls > = ( controls ) => {
41
28
const [ tab , setTab ] = React . useState < "inspect" | "create" > ( "inspect" ) ;
29
+ const { layout, setLayout } = useLayoutStore ( ) ;
30
+
31
+ const setShow = ( show : boolean ) => {
32
+ setLayout ( { showRightSidebar : show } ) ;
33
+ } ;
42
34
43
35
return (
44
- < Sidebar show = { show } setShow = { setShow } side = "right" >
36
+ < Sidebar show = { layout . showRightSidebar } setShow = { setShow } side = "right" >
45
37
< div className = "text-color-primary mx-2 flex h-screen flex-col gap-2" >
46
38
< div className = "flex flex-row items-center gap-1" >
47
39
< button
48
40
className = "neutral-button-primary rounded-md border-none transition-all"
49
- onClick = { ( ) => setShow ( ! show ) }
41
+ onClick = { ( ) => setShow ( ! layout . showRightSidebar ) }
50
42
>
51
43
< FaBars size = "15" className = "z-20 mr-2" />
52
44
</ button >
@@ -95,6 +87,7 @@ const InspectSection = ({ selectedNode, updateNode, nodes, edges }: InspectSecti
95
87
const definition = getNodeBlockDefinitionFromNode ( selectedNode ) ;
96
88
97
89
const handleValueChange = ( name : string , value : string ) => {
90
+ console . log ( "handleValueChange" , name , value ) ;
98
91
const updatedNode = { ...selectedNode } ;
99
92
updatedNode . data . block . input [ name ] = value ;
100
93
updateNode ( updatedNode ) ;
@@ -105,12 +98,10 @@ const InspectSection = ({ selectedNode, updateNode, nodes, edges }: InspectSecti
105
98
if ( definition == undefined ) return [ ] ;
106
99
107
100
const outputFields = definition . output_fields ;
108
- return outputFields . map ( ( outputField ) => {
109
- return {
110
- key : `{{${ ancestorNode . id } .${ outputField . name } }}` ,
111
- value : `${ definition . type } .${ outputField . name } ` ,
112
- } ;
113
- } ) ;
101
+ return outputFields . map ( ( outputField ) => ( {
102
+ key : `{{${ ancestorNode . id } .${ outputField . name } }}` ,
103
+ value : `${ definition . type } .${ outputField . name } ` ,
104
+ } ) ) ;
114
105
} ) ;
115
106
116
107
const handleAutocompleteClick = ( inputField : IOField , field : { key : string ; value : string } ) => {
0 commit comments