Skip to content

Commit f0195f1

Browse files
Support create / provision / deprovision from editor page (#123) (#124)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> (cherry picked from commit 37bbbfa) Co-authored-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 8184c39 commit f0195f1

19 files changed

+497
-161
lines changed

common/constants.ts

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { WORKFLOW_STATE } from './interfaces';
7+
68
export const PLUGIN_ID = 'flow-framework';
79

810
/**
@@ -35,6 +37,8 @@ export const GET_WORKFLOW_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}`;
3537
export const SEARCH_WORKFLOWS_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/search`;
3638
export const GET_WORKFLOW_STATE_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/state`;
3739
export const CREATE_WORKFLOW_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/create`;
40+
export const PROVISION_WORKFLOW_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/provision`;
41+
export const DEPROVISION_WORKFLOW_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/deprovision`;
3842
export const DELETE_WORKFLOW_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/delete`;
3943
export const GET_PRESET_WORKFLOWS_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH}/presets`;
4044

@@ -49,5 +53,13 @@ export const NEW_WORKFLOW_ID_URL = 'new';
4953
export const START_FROM_SCRATCH_WORKFLOW_NAME = 'Start From Scratch';
5054
export const DEFAULT_NEW_WORKFLOW_NAME = 'new_workflow';
5155
export const DEFAULT_NEW_WORKFLOW_DESCRIPTION = 'My new workflow';
56+
export const DEFAULT_NEW_WORKFLOW_STATE = WORKFLOW_STATE.NOT_STARTED;
57+
export const DEFAULT_NEW_WORKFLOW_STATE_TYPE = ('NOT_STARTED' as any) as typeof WORKFLOW_STATE;
5258
export const DATE_FORMAT_PATTERN = 'MM/DD/YY hh:mm A';
5359
export const EMPTY_FIELD_STRING = '--';
60+
export const FETCH_ALL_QUERY_BODY = {
61+
query: {
62+
match_all: {},
63+
},
64+
size: 1000,
65+
};

public/pages/workflow_detail/component_details/component_details.tsx

+11-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import React from 'react';
7-
import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui';
7+
import { EuiPanel } from '@elastic/eui';
88
import { ReactFlowComponent } from '../../../../common';
99
import { ComponentInputs } from './component_inputs';
1010
import { EmptyComponentInputs } from './empty_component_inputs';
@@ -24,23 +24,15 @@ interface ComponentDetailsProps {
2424
*/
2525
export function ComponentDetails(props: ComponentDetailsProps) {
2626
return (
27-
<EuiFlexGroup
28-
direction="column"
29-
gutterSize="none"
30-
className="workspace-panel"
31-
>
32-
<EuiFlexItem>
33-
<EuiPanel paddingSize="m">
34-
{props.selectedComponent ? (
35-
<ComponentInputs
36-
selectedComponent={props.selectedComponent}
37-
onFormChange={props.onFormChange}
38-
/>
39-
) : (
40-
<EmptyComponentInputs />
41-
)}
42-
</EuiPanel>
43-
</EuiFlexItem>
44-
</EuiFlexGroup>
27+
<EuiPanel paddingSize="m">
28+
{props.selectedComponent ? (
29+
<ComponentInputs
30+
selectedComponent={props.selectedComponent}
31+
onFormChange={props.onFormChange}
32+
/>
33+
) : (
34+
<EmptyComponentInputs />
35+
)}
36+
</EuiPanel>
4537
);
4638
}

public/pages/workflow_detail/components/header.tsx

+43-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44
*/
55

66
import React from 'react';
7-
import { EuiPageHeader, EuiButton, EuiLoadingSpinner } from '@elastic/eui';
8-
import { DEFAULT_NEW_WORKFLOW_NAME, Workflow } from '../../../../common';
7+
import {
8+
EuiPageHeader,
9+
EuiButton,
10+
EuiLoadingSpinner,
11+
EuiFlexGroup,
12+
EuiFlexItem,
13+
EuiText,
14+
} from '@elastic/eui';
15+
import {
16+
DEFAULT_NEW_WORKFLOW_NAME,
17+
DEFAULT_NEW_WORKFLOW_STATE,
18+
Workflow,
19+
} from '../../../../common';
920

1021
interface WorkflowDetailHeaderProps {
1122
tabs: any[];
@@ -14,20 +25,42 @@ interface WorkflowDetailHeaderProps {
1425
}
1526

1627
export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
28+
function getTitle() {
29+
return props.workflow ? (
30+
props.workflow.name
31+
) : props.isNewWorkflow && !props.workflow ? (
32+
DEFAULT_NEW_WORKFLOW_NAME
33+
) : (
34+
<EuiLoadingSpinner size="xl" />
35+
);
36+
}
37+
38+
function getState() {
39+
return props.workflow?.state
40+
? props.workflow.state
41+
: props.isNewWorkflow
42+
? DEFAULT_NEW_WORKFLOW_STATE
43+
: null;
44+
}
45+
1746
return (
1847
<EuiPageHeader
1948
pageTitle={
20-
props.workflow ? (
21-
props.workflow.name
22-
) : props.isNewWorkflow && !props.workflow ? (
23-
DEFAULT_NEW_WORKFLOW_NAME
24-
) : (
25-
<EuiLoadingSpinner size="xl" />
26-
)
49+
<EuiFlexGroup direction="row" alignItems="flexEnd" gutterSize="m">
50+
<EuiFlexItem grow={false}>{getTitle()}</EuiFlexItem>
51+
<EuiFlexItem grow={false} style={{ marginBottom: '10px' }}>
52+
<EuiText size="m">{getState()}</EuiText>
53+
</EuiFlexItem>
54+
</EuiFlexGroup>
2755
}
2856
rightSideItems={[
2957
// TODO: finalize if this is needed
30-
<EuiButton fill={false} color="danger" onClick={() => {}}>
58+
<EuiButton
59+
fill={false}
60+
color="danger"
61+
style={{ marginTop: '8px' }}
62+
onClick={() => {}}
63+
>
3164
Delete
3265
</EuiButton>,
3366
]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.workflow-detail {
2+
overflow: hidden;
3+
}

public/pages/workflow_detail/workflow_detail.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,31 @@
55

66
import React, { useEffect, useState } from 'react';
77
import { RouteComponentProps, useLocation } from 'react-router-dom';
8-
import { useDispatch, useSelector } from 'react-redux';
8+
import { useSelector } from 'react-redux';
99
import { ReactFlowProvider } from 'reactflow';
1010
import queryString from 'query-string';
1111
import { EuiPage, EuiPageBody } from '@elastic/eui';
1212
import { BREADCRUMBS } from '../../utils';
1313
import { getCore } from '../../services';
1414
import { WorkflowDetailHeader } from './components';
15-
import { AppState, searchModels, searchWorkflows } from '../../store';
15+
import {
16+
AppState,
17+
searchModels,
18+
searchWorkflows,
19+
useAppDispatch,
20+
} from '../../store';
1621
import { ResizableWorkspace } from './workspace';
1722
import { Launches } from './launches';
1823
import { Prototype } from './prototype';
1924
import {
2025
DEFAULT_NEW_WORKFLOW_NAME,
26+
FETCH_ALL_QUERY_BODY,
2127
NEW_WORKFLOW_ID_URL,
2228
} from '../../../common';
2329

30+
// styling
31+
import './workflow-detail-styles.scss';
32+
2433
export interface WorkflowDetailRouterProps {
2534
workflowId: string;
2635
}
@@ -53,7 +62,7 @@ function replaceActiveTab(activeTab: string, props: WorkflowDetailProps) {
5362
*/
5463

5564
export function WorkflowDetail(props: WorkflowDetailProps) {
56-
const dispatch = useDispatch();
65+
const dispatch = useAppDispatch();
5766
const { workflows, cachedWorkflow } = useSelector(
5867
(state: AppState) => state.workflows
5968
);
@@ -101,9 +110,9 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
101110
useEffect(() => {
102111
if (!isNewWorkflow) {
103112
// TODO: can optimize to only fetch a single workflow
104-
dispatch(searchWorkflows({ query: { match_all: {} } }));
113+
dispatch(searchWorkflows(FETCH_ALL_QUERY_BODY));
105114
}
106-
dispatch(searchModels({ query: { match_all: {} } }));
115+
dispatch(searchModels(FETCH_ALL_QUERY_BODY));
107116
}, []);
108117

109118
const tabs = [
@@ -139,7 +148,7 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
139148
return (
140149
<ReactFlowProvider>
141150
<EuiPage>
142-
<EuiPageBody style={{ overflow: 'hidden' }}>
151+
<EuiPageBody className="workflow-detail">
143152
<WorkflowDetailHeader
144153
workflow={workflow}
145154
isNewWorkflow={isNewWorkflow}

0 commit comments

Comments
 (0)