diff --git a/public/pages/workflow_detail/resizable_workspace.tsx b/public/pages/workflow_detail/resizable_workspace.tsx index 08a2eedb..e1676233 100644 --- a/public/pages/workflow_detail/resizable_workspace.tsx +++ b/public/pages/workflow_detail/resizable_workspace.tsx @@ -240,7 +240,10 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) { style={{ height: '100%' }} > - + diff --git a/public/pages/workflow_detail/workspace/workspace.tsx b/public/pages/workflow_detail/workspace/workspace.tsx index 59534a29..7b30afca 100644 --- a/public/pages/workflow_detail/workspace/workspace.tsx +++ b/public/pages/workflow_detail/workspace/workspace.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useRef, useCallback, useEffect } from 'react'; +import React, { useRef, useCallback, useEffect, useState } from 'react'; import ReactFlow, { Controls, Background, @@ -13,9 +13,16 @@ import ReactFlow, { BackgroundVariant, MarkerType, } from 'reactflow'; -import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; +import { + EuiFlexItem, + EuiFlexGroup, + EuiTitle, + EuiFilterGroup, + EuiFilterButton, + EuiCodeEditor, +} from '@elastic/eui'; import { setDirty, useAppDispatch } from '../../../store'; -import { IComponentData, WorkflowConfig } from '../../../../common'; +import { IComponentData, Workflow, WorkflowConfig } from '../../../../common'; import { IngestGroupComponent, SearchGroupComponent, @@ -31,6 +38,7 @@ import './workspace-styles.scss'; import './workspace_edge/deletable-edge-styles.scss'; interface WorkspaceProps { + workflow?: Workflow; uiConfig?: WorkflowConfig; } @@ -44,6 +52,22 @@ const edgeTypes = { customEdge: DeletableEdge }; export function Workspace(props: WorkspaceProps) { const dispatch = useAppDispatch(); + // Visual/JSON toggle states + const [visualSelected, setVisualSelected] = useState(true); + function toggleSelection(): void { + setVisualSelected(!visualSelected); + } + + // JSON state + const [provisionTemplate, setProvisionTemplate] = useState(''); + useEffect(() => { + if (props.workflow?.workflows.provision) { + const templateAsObj = props.workflow?.workflows.provision as {}; + const templateAsStr = JSON.stringify(templateAsObj, undefined, 2); + setProvisionTemplate(templateAsStr); + } + }, [props.workflow]); + // ReactFlow state const reactFlowWrapper = useRef(null); const [nodes, setNodes, onNodesChange] = useNodesState([]); @@ -88,46 +112,92 @@ export function Workspace(props: WorkspaceProps) { gutterSize="none" justifyContent="spaceBetween" > - + {/** * We have these wrapper divs & reactFlowWrapper ref to control and calculate the * ReactFlow bounds when calculating node positioning. */} + + + + + Preview + + + + + toggleSelection()} + > + Visual + + toggleSelection()} + > + JSON + + + + + - - - + + + + ) : ( + - + )}