Skip to content

Commit aae59b6

Browse files
committed
Improve displayed state when workflow is provisioned; make workspace readonly
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 8bf8897 commit aae59b6

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

public/pages/workflow_detail/component_details/component_details.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55

66
import React from 'react';
77
import { EuiPanel } from '@elastic/eui';
8-
import { ReactFlowComponent } from '../../../../common';
8+
import { ReactFlowComponent, Workflow } from '../../../../common';
99
import { ComponentInputs } from './component_inputs';
1010
import { EmptyComponentInputs } from './empty_component_inputs';
11+
import { ProvisionedComponentInputs } from './provisioned_component_inputs';
1112

1213
// styling
1314
import '../workspace/workspace-styles.scss';
1415

1516
interface ComponentDetailsProps {
17+
workflow: Workflow | undefined;
1618
onFormChange: () => void;
19+
isDeprovisionable: boolean;
1720
selectedComponent?: ReactFlowComponent;
1821
}
1922

@@ -25,14 +28,16 @@ interface ComponentDetailsProps {
2528
export function ComponentDetails(props: ComponentDetailsProps) {
2629
return (
2730
<EuiPanel paddingSize="m">
28-
{props.selectedComponent ? (
31+
{props.isDeprovisionable ? (
32+
<ProvisionedComponentInputs />
33+
) : props.selectedComponent ? (
2934
<ComponentInputs
3035
selectedComponent={props.selectedComponent}
3136
onFormChange={props.onFormChange}
3237
/>
33-
) : (
38+
) : props.workflow ? (
3439
<EmptyComponentInputs />
35-
)}
40+
) : undefined}
3641
</EuiPanel>
3742
);
3843
}

public/pages/workflow_detail/component_details/empty_component_inputs.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import React from 'react';
77
import { EuiEmptyPrompt, EuiText } from '@elastic/eui';
88

9+
// Simple prompt to display when no components are selected.
910
export function EmptyComponentInputs() {
1011
return (
1112
<EuiEmptyPrompt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import React from 'react';
7+
import { EuiEmptyPrompt, EuiText } from '@elastic/eui';
8+
9+
// Simple prompt to display when the workflow is provisioned.
10+
export function ProvisionedComponentInputs() {
11+
return (
12+
<EuiEmptyPrompt
13+
iconType="bell"
14+
title={<h2>The workflow has been provisioned</h2>}
15+
titleSize="s"
16+
body={
17+
<>
18+
<EuiText>Please deprovision first to continue editing.</EuiText>
19+
</>
20+
}
21+
/>
22+
);
23+
}

public/pages/workflow_detail/workspace/resizable_workspace.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
DEFAULT_NEW_WORKFLOW_DESCRIPTION,
3535
USE_CASE,
3636
WORKFLOW_STATE,
37+
processNodes,
3738
reduceToTemplate,
3839
} from '../../../../common';
3940
import {
@@ -104,16 +105,20 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
104105
>();
105106

106107
// Save/provision/deprovision button state
107-
const isSaveable = isFirstSave ? true : isDirty;
108+
const isSaveable =
109+
props.workflow !== undefined && (isFirstSave ? true : isDirty);
108110
const isProvisionable =
111+
props.workflow !== undefined &&
109112
!isDirty &&
110113
!props.isNewWorkflow &&
111114
formValidOnSubmit &&
112115
flowValidOnSubmit &&
113116
props.workflow?.state === WORKFLOW_STATE.NOT_STARTED;
114117
const isDeprovisionable =
118+
props.workflow !== undefined &&
115119
!props.isNewWorkflow &&
116120
props.workflow?.state !== WORKFLOW_STATE.NOT_STARTED;
121+
const readonly = props.workflow === undefined || isDeprovisionable;
117122

118123
// Loading state
119124
const [isProvisioning, setIsProvisioning] = useState<boolean>(false);
@@ -377,7 +382,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
377382
</EuiButton>,
378383
<EuiButton
379384
fill={false}
380-
disabled={!isSaveable || isLoadingGlobal}
385+
disabled={!isSaveable || isLoadingGlobal || isDeprovisionable}
381386
isLoading={isSaving}
382387
// TODO: if props.isNewWorkflow is true, clear the workflow cache if saving is successful.
383388
onClick={() => {
@@ -458,6 +463,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
458463
<Workspace
459464
id="ingest"
460465
workflow={workflow}
466+
readonly={readonly}
461467
onNodesChange={onNodesChange}
462468
onSelectionChange={onSelectionChange}
463469
/>
@@ -481,7 +487,9 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
481487
>
482488
<EuiFlexItem>
483489
<ComponentDetails
490+
workflow={props.workflow}
484491
selectedComponent={selectedComponent}
492+
isDeprovisionable={isDeprovisionable}
485493
onFormChange={onFormChange}
486494
/>
487495
</EuiFlexItem>

public/pages/workflow_detail/workspace/workspace.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import './workspace_edge/deletable-edge-styles.scss';
3838

3939
interface WorkspaceProps {
4040
workflow?: Workflow;
41+
readonly: boolean;
4142
onNodesChange: (nodes: ReactFlowComponent[]) => void;
4243
id: string;
4344
// TODO: make more typesafe
@@ -134,6 +135,14 @@ export function Workspace(props: WorkspaceProps) {
134135
onConnect={onConnect}
135136
className="reactflow-workspace"
136137
fitView
138+
edgesUpdatable={!props.readonly}
139+
edgesFocusable={!props.readonly}
140+
nodesDraggable={!props.readonly}
141+
nodesConnectable={!props.readonly}
142+
nodesFocusable={!props.readonly}
143+
draggable={!props.readonly}
144+
panOnDrag={!props.readonly}
145+
elementsSelectable={!props.readonly}
137146
>
138147
<Controls
139148
showFitView={false}

0 commit comments

Comments
 (0)