Skip to content

Commit 5ea50a0

Browse files
authoredJan 17, 2025··
UX fit-n-finish updates V (opensearch-project#567)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 096bdfa commit 5ea50a0

17 files changed

+557
-447
lines changed
 

‎common/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ export enum TRANSFORM_TYPE {
571571
TEMPLATE = 'Template',
572572
}
573573
export const NO_TRANSFORMATION = 'No transformation';
574-
export const START_FROM_SCRATCH_WORKFLOW_NAME = 'Start From Scratch';
575574
export const DEFAULT_NEW_WORKFLOW_NAME = 'new_workflow';
576575
export const DEFAULT_NEW_WORKFLOW_DESCRIPTION = 'My new workflow';
577576
export const DEFAULT_NEW_WORKFLOW_STATE_TYPE = ('NOT_STARTED' as any) as typeof WORKFLOW_STATE;
@@ -592,6 +591,7 @@ export enum SORT_ORDER {
592591
DESC = 'desc',
593592
}
594593
export const MAX_DOCS = 1000;
594+
export const MAX_DOCS_TO_IMPORT = 100;
595595
export const MAX_STRING_LENGTH = 100;
596596
export const MAX_JSON_STRING_LENGTH = 10000;
597597
export const MAX_TEMPLATE_STRING_LENGTH = 10000;

‎public/pages/workflow_detail/components/edit_workflow_metadata_modal.tsx

+41-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import React, { useEffect, useState } from 'react';
7+
import { useSelector } from 'react-redux';
78
import * as yup from 'yup';
89
import { Formik, getIn, useFormikContext } from 'formik';
910
import { isEmpty } from 'lodash';
@@ -13,12 +14,12 @@ import {
1314
EuiModal,
1415
EuiModalHeader,
1516
EuiModalHeaderTitle,
16-
EuiModalBody,
1717
EuiModalFooter,
1818
EuiSmallButtonEmpty,
1919
EuiSmallButton,
2020
} from '@elastic/eui';
2121
import {
22+
FETCH_ALL_QUERY,
2223
MAX_STRING_LENGTH,
2324
Workflow,
2425
WORKFLOW_NAME_REGEXP,
@@ -32,7 +33,13 @@ import {
3233
getInitialValue,
3334
} from '../../../utils';
3435
import { TextField } from '../workflow_inputs/input_fields';
35-
import { getWorkflow, updateWorkflow, useAppDispatch } from '../../../store';
36+
import {
37+
AppState,
38+
getWorkflow,
39+
searchWorkflows,
40+
updateWorkflow,
41+
useAppDispatch,
42+
} from '../../../store';
3643

3744
interface EditWorkflowMetadataModalProps {
3845
workflow?: Workflow;
@@ -47,6 +54,7 @@ export function EditWorkflowMetadataModal(
4754
const dispatch = useAppDispatch();
4855
const dataSourceId = getDataSourceId();
4956
const { values } = useFormikContext<WorkflowFormValues>();
57+
const { workflows } = useSelector((state: AppState) => state.workflows);
5058

5159
// sub-form values/schema
5260
const metadataFormValues = {
@@ -64,6 +72,17 @@ export function EditWorkflowMetadataModal(
6472
WORKFLOW_NAME_REGEXP.test(name) === false
6573
);
6674
})
75+
.test(
76+
'workflowName',
77+
'This workflow name is already in use. Use a different name',
78+
(name) => {
79+
return !(
80+
Object.values(workflows)
81+
.map((workflow) => workflow.name)
82+
.includes(name || '') && name !== props.workflow?.name
83+
);
84+
}
85+
)
6786
.required('Required') as yup.Schema,
6887
desription: yup
6988
.string()
@@ -83,6 +102,17 @@ export function EditWorkflowMetadataModal(
83102
// button updating state
84103
const [isUpdating, setIsUpdating] = useState<boolean>(false);
85104

105+
// On initial render: fetch all workflows. Used for preventing users from updating name
106+
// to an existing workflow
107+
useEffect(() => {
108+
dispatch(
109+
searchWorkflows({
110+
apiBody: FETCH_ALL_QUERY,
111+
dataSourceId,
112+
})
113+
);
114+
}, []);
115+
86116
// if saving, take the updated name/description (along with any other unsaved form values)
87117
// and execute the update.
88118
async function onSave() {
@@ -162,34 +192,36 @@ export function EditWorkflowMetadataModal(
162192
return (
163193
<EuiModal
164194
maxWidth={false}
165-
style={{ width: '50vw' }}
195+
style={{ width: '30vw' }}
166196
onClose={() => props.setIsModalOpen(false)}
167197
>
168198
<EuiModalHeader>
169199
<EuiModalHeaderTitle>
170-
<p>Update workflow metadata</p>
200+
<p>Workflow settings</p>
171201
</EuiModalHeaderTitle>
172202
</EuiModalHeader>
173-
<EuiModalBody>
203+
<EuiFlexItem style={{ paddingLeft: '24px', paddingRight: '24px' }}>
174204
<EuiFlexGroup direction="column">
175205
<EuiFlexItem>
176206
<TextField
177-
label="Workflow name"
207+
label="Name"
178208
fullWidth={false}
179209
fieldPath={`name`}
180210
showError={true}
181211
/>
182212
</EuiFlexItem>
183213
<EuiFlexItem>
184214
<TextField
185-
label="Workflow description"
186-
fullWidth={true}
215+
label="Description - optional"
216+
fullWidth={false}
187217
fieldPath={`description`}
188218
showError={true}
219+
placeholder="Provide a description for identifying this workflow."
220+
textArea={true}
189221
/>
190222
</EuiFlexItem>
191223
</EuiFlexGroup>
192-
</EuiModalBody>
224+
</EuiFlexItem>
193225
<EuiModalFooter>
194226
<EuiSmallButtonEmpty
195227
onClick={() => props.setIsModalOpen(false)}

‎public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx

+32-20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
EuiText,
1414
EuiCodeBlock,
1515
EuiSmallButtonEmpty,
16+
EuiEmptyPrompt,
1617
} from '@elastic/eui';
1718
import {
1819
MapEntry,
@@ -103,11 +104,11 @@ export function SourceData(props: SourceDataProps) {
103104
<EuiFlexGroup direction="row" justifyContent="spaceBetween">
104105
<EuiFlexItem grow={false}>
105106
<EuiText size="s">
106-
<h3>Import data</h3>
107+
<h3>Import sample data</h3>
107108
</EuiText>
108109
</EuiFlexItem>
109-
{docsPopulated && (
110-
<EuiFlexItem grow={false}>
110+
<EuiFlexItem grow={false}>
111+
{docsPopulated ? (
111112
<EuiSmallButtonEmpty
112113
onClick={() => setIsEditModalOpen(true)}
113114
data-testid="editSourceDataButton"
@@ -116,8 +117,19 @@ export function SourceData(props: SourceDataProps) {
116117
>
117118
Edit
118119
</EuiSmallButtonEmpty>
119-
</EuiFlexItem>
120-
)}
120+
) : (
121+
<EuiSmallButton
122+
fill={false}
123+
style={{ width: '75px' }}
124+
onClick={() => setIsEditModalOpen(true)}
125+
data-testid="selectDataToImportButton"
126+
iconType="plus"
127+
iconSide="left"
128+
>
129+
{`Import`}
130+
</EuiSmallButton>
131+
)}
132+
</EuiFlexItem>
121133
</EuiFlexGroup>
122134
</EuiFlexItem>
123135
{props.lastIngested !== undefined && (
@@ -127,21 +139,7 @@ export function SourceData(props: SourceDataProps) {
127139
</EuiText>
128140
</EuiFlexItem>
129141
)}
130-
131-
{!docsPopulated && (
132-
<EuiFlexItem grow={false}>
133-
<EuiSmallButton
134-
fill={false}
135-
style={{ width: '100px' }}
136-
onClick={() => setIsEditModalOpen(true)}
137-
data-testid="selectDataToImportButton"
138-
>
139-
{`Select data`}
140-
</EuiSmallButton>
141-
</EuiFlexItem>
142-
)}
143-
144-
{docsPopulated && (
142+
{docsPopulated ? (
145143
<>
146144
<EuiSpacer size="s" />
147145
<EuiFlexItem grow={true}>
@@ -157,6 +155,20 @@ export function SourceData(props: SourceDataProps) {
157155
</EuiCodeBlock>
158156
</EuiFlexItem>
159157
</>
158+
) : (
159+
<EuiEmptyPrompt
160+
iconType="document"
161+
title={<h2>No data imported</h2>}
162+
titleSize="s"
163+
body={
164+
<>
165+
<EuiText size="s">
166+
Import a sample of your data to begin configuring your
167+
ingestion flow.
168+
</EuiText>
169+
</>
170+
}
171+
/>
160172
)}
161173
</EuiFlexGroup>
162174
</>

0 commit comments

Comments
 (0)
Please sign in to comment.