@@ -7,6 +7,9 @@ import { ScriptEditor } from '../components/ScriptEditor';
77import { NodeEditor } from '../components/NodeEditor' ;
88import { DocViewer } from '../components/DocViewer' ;
99import WebhookView from '../components/WebhookView' ;
10+ import Routes from './Routes' ;
11+ import { ScriptData , Activity , Step } from '../types' ;
12+ import { SidebarProps } from '../components/Sidebar' ;
1013
1114export type TabType = 'edit' | 'documentation' | 'webhook' ;
1215
@@ -19,12 +22,14 @@ export interface AppShellProps {
1922 setActiveTab : ( t : TabType ) => void ;
2023 // editor state and handlers (kept generic to avoid tight coupling in this step)
2124 state : any ;
22- script : any ;
25+ selectedNode ?: Activity | Step | null ;
26+ script : ScriptData ;
2327 isValid : boolean ;
24- validationErrors : any [ ] ;
28+ validationErrors : string [ ] ;
2529 selections : any ;
2630 selectedLocation : any ;
2731 selectedBayObj : any ;
32+ parentActivityForAdd ?: any ;
2833 onLoadScript : ( ) => void ;
2934 onDownloadScript : ( ) => void ;
3035 onLocationSelect : ( l : any ) => void ;
@@ -46,14 +51,17 @@ export const AppShell: React.FC<AppShellProps> = (props) => {
4651 selections,
4752 selectedLocation,
4853 selectedBayObj,
54+ parentActivityForAdd,
4955 onLoadScript,
5056 onDownloadScript,
5157 onLocationSelect,
5258 onBaySelect,
5359 dispatch
5460 } = props ;
5561
56- const selectedNode = ( ( ) => {
62+ // Prefer a hydrated selected node object from the top-level App when available
63+ const effectiveSelectedNode = ( ( ) => {
64+ if ( props . selectedNode !== undefined ) return props . selectedNode ;
5765 try { return ( state && state . selectedRef && state . selectedRef . kind !== 'script' ) ? state . selectedRef : null ; } catch { return null ; }
5866 } ) ( ) ;
5967
@@ -69,75 +77,24 @@ export const AppShell: React.FC<AppShellProps> = (props) => {
6977 onTabChange = { setActiveTab }
7078 />
7179
72- { activeTab === 'edit' ? (
73- < div className = "tree-flex" >
74- < DialogManager
75- // dialog props are expected to be provided via dispatch or parent
76- showActivityDialog = { false }
77- showStepDialog = { false }
78- onCloseActivityDialog = { ( ) => { } }
79- onCloseStepDialog = { ( ) => { } }
80- onAddActivity = { ( ) => { } }
81- onAddStep = { ( ) => { } }
82- parentActivityForAdd = { undefined }
83- />
84- < Sidebar
85- script = { script }
86- selectedRef = { state . selectedRef }
87- selectedNode = { selectedNode }
88- isValid = { isValid }
89- validationErrors = { validationErrors }
90- selectedFacilityId = { selectedFacilityId }
91- selectedLocationId = { selectedLocation ?. id || null }
92- persistedLocationId = { selections ?. locationId || null }
93- selectedBayId = { selectedBayObj ?. id || null }
94- persistedBayId = { selections ?. bayId || null }
95- selectedBayObj = { selectedBayObj }
96- onLoadScript = { onLoadScript }
97- onDownloadScript = { onDownloadScript }
98- onLocationSelect = { onLocationSelect }
99- onBaySelect = { onBaySelect }
100- onCloneSelected = { ( ) => dispatch ( { type : 'CLONE_SELECTED' } ) }
101- onShowActivityDialog = { ( ) => { } }
102- onShowStepDialog = { ( ) => { } }
103- onSelectScript = { ( ) => dispatch ( { type : 'SELECT_SCRIPT' } ) }
104- onSelectActivity = { ( activityId : string ) => dispatch ( { type : 'SELECT_ACTIVITY' , activityId } ) }
105- onSelectStep = { ( activityId : string , stepId : string ) => dispatch ( { type : 'SELECT_STEP' , activityId, stepId } ) }
106- onDeleteActivity = { ( id : string ) => dispatch ( { type : 'DELETE_ACTIVITY' , activityId : id } ) }
107- onDeleteStep = { ( activityId : string , stepId : string ) => dispatch ( { type : 'DELETE_STEP' , activityId, stepId } ) }
108- parentActivityForAdd = { undefined }
109- />
110-
111- < div className = "tree-main" >
112- { state . selectedRef ?. kind === 'script' ? (
113- < >
114- < h2 > Script Configuration</ h2 >
115- < ScriptEditor
116- script = { script }
117- onChange = { ( s : any ) => dispatch ( { type : 'LOAD_SCRIPT' , script : s } ) }
118- />
119- < pre > { JSON . stringify ( script , null , 2 ) } </ pre >
120- </ >
121- ) : selectedNode ? (
122- < NodeEditor
123- node = { selectedNode }
124- onUpdateActivity = { ( activityId : string , patch : any ) => dispatch ( { type : 'UPDATE_ACTIVITY' , activityId, patch } ) }
125- onUpdateStep = { ( stepId : string , patch : any ) => dispatch ( { type : 'UPDATE_STEP' , stepId, patch } ) }
126- />
127- ) : (
128- < div className = "empty-node-editor" > Select a node to edit its details.</ div >
129- ) }
130- </ div >
131- </ div >
132- ) : activeTab === 'documentation' ? (
133- < div className = "documentation-flex" >
134- < DocViewer />
135- </ div >
136- ) : activeTab === 'webhook' ? (
137- < div className = "documentation-flex" >
138- < WebhookView selectedBayDbId = { selectedBayObj ?. dbId ?? null } />
139- </ div >
140- ) : null }
80+ < Routes
81+ activeTab = { activeTab }
82+ state = { state }
83+ selectedNode = { effectiveSelectedNode ?? null }
84+ script = { script }
85+ isValid = { isValid }
86+ validationErrors = { validationErrors }
87+ selections = { selections }
88+ selectedFacilityId = { selectedFacilityId }
89+ parentActivityForAdd = { parentActivityForAdd }
90+ selectedLocation = { selectedLocation }
91+ selectedBayObj = { selectedBayObj }
92+ onLoadScript = { onLoadScript }
93+ onDownloadScript = { onDownloadScript }
94+ onLocationSelect = { onLocationSelect }
95+ onBaySelect = { onBaySelect }
96+ dispatch = { dispatch }
97+ />
14198 </ div >
14299 ) ;
143100} ;
0 commit comments