Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial logic to generate ReactFlow workspace #160

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/component_types/other/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export class Results extends BaseComponent {
this.type = COMPONENT_CLASS.RESULTS;
this.label = 'Results';
this.description = 'OpenSearch results';
this.inputs = [{ id: 'input', label: 'Input', acceptMultiple: false }];
}
}
1 change: 1 addition & 0 deletions public/component_types/transformer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './ml_transformer';
export * from './text_embedding_transformer';
export * from './sparse_encoder_transformer';
export * from './results_transformer';
Expand Down
14 changes: 10 additions & 4 deletions public/pages/workflow_detail/workspace/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import {
ReactFlowComponent,
ReactFlowEdge,
Workflow,
WorkflowConfig,
} from '../../../../common';
import {
IngestGroupComponent,
SearchGroupComponent,
WorkspaceComponent,
} from './workspace_components';
import { DeletableEdge } from './workspace_edge';
import { uiConfigToWorkspaceFlow } from '../../../utils';

// styling
import 'reactflow/dist/style.css';
Expand Down Expand Up @@ -107,12 +109,15 @@ export function Workspace(props: WorkspaceProps) {
[setEdges]
);

// Initialization. Set the nodes and edges to an existing workflow state,
// Initialization. Generate the nodes and edges based on the workflow config.
useEffect(() => {
const workflow = { ...props.workflow };
if (workflow?.ui_metadata?.workspace_flow) {
setNodes(workflow.ui_metadata.workspace_flow.nodes);
setEdges(workflow.ui_metadata.workspace_flow.edges);
if (workflow?.ui_metadata?.config) {
const proposedWorkspaceFlow = uiConfigToWorkspaceFlow(
workflow.ui_metadata?.config as WorkflowConfig
);
setNodes(proposedWorkspaceFlow.nodes);
setEdges(proposedWorkspaceFlow.edges);
}
}, [props.workflow]);

Expand Down Expand Up @@ -141,6 +146,7 @@ export function Workspace(props: WorkspaceProps) {
onConnect={onConnect}
className="reactflow-workspace"
fitView
minZoom={0.2}
edgesUpdatable={!props.readonly}
edgesFocusable={!props.readonly}
nodesDraggable={!props.readonly}
Expand Down
Loading
Loading