Skip to content

Commit 69c3406

Browse files
authored
Move exposed configs in the advanced transform modals (opensearch-project#466)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 809c006 commit 69c3406

File tree

6 files changed

+77
-147
lines changed

6 files changed

+77
-147
lines changed

public/pages/workflow_detail/workflow_detail.test.tsx

+12-25
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ describe('WorkflowDetail Page with create ingestion option', () => {
7878
} = renderWithRouter(workflowId, workflowName, type);
7979

8080
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
81-
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(
82-
0
83-
);
84-
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
85-
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
8681
expect(getAllByText('Inspector').length).toBeGreaterThan(0);
8782
expect(getAllByText('Preview').length).toBeGreaterThan(0);
8883
expect(
@@ -188,27 +183,19 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
188183
jest.clearAllMocks();
189184
});
190185
test(`renders the WorkflowDetail page with skip ingestion option`, async () => {
191-
const {
192-
container,
193-
getByTestId,
194-
getAllByText,
195-
getAllByTestId,
196-
} = renderWithRouter(workflowId, workflowName, WORKFLOW_TYPE.HYBRID_SEARCH);
197-
198-
// "Create an ingest pipeline" option should be selected by default
199-
const createIngestRadio = container.querySelector('#create');
200-
expect(createIngestRadio).toBeChecked();
186+
const { getByTestId, getAllByText, getAllByTestId } = renderWithRouter(
187+
workflowId,
188+
workflowName,
189+
WORKFLOW_TYPE.HYBRID_SEARCH
190+
);
201191

202-
// "Skip ingestion pipeline" option should be unselected by default
203-
const skipIngestRadio = container.querySelector('#skip');
204-
expect(skipIngestRadio).not.toBeChecked();
192+
// Defining a new ingest pipeline & index is enabled by default
193+
const enabledCheckbox = getByTestId('checkbox-ingest.enabled');
194+
expect(enabledCheckbox).toBeChecked();
205195

206-
// Selected "Skip ingestion pipeline"
207-
userEvent.click(skipIngestRadio!);
208-
await waitFor(() => {
209-
expect(createIngestRadio).not.toBeChecked();
210-
});
211-
expect(skipIngestRadio).toBeChecked();
196+
// Skipping ingest pipeline and navigating to search
197+
userEvent.click(enabledCheckbox);
198+
await waitFor(() => {});
212199
const searchPipelineButton = getByTestId('searchPipelineButton');
213200
userEvent.click(searchPipelineButton);
214201

@@ -255,7 +242,7 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
255242
userEvent.click(searchPipelineBackButton);
256243

257244
await waitFor(() => {
258-
expect(skipIngestRadio).toBeChecked();
245+
expect(enabledCheckbox).not.toBeChecked();
259246
});
260247
});
261248
});

public/pages/workflow_detail/workflow_inputs/config_field_list.tsx

-9
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ export function ConfigFieldList(props: ConfigFieldListProps) {
6363
<BooleanField
6464
label={camelCaseToTitleString(field.id)}
6565
fieldPath={fieldPath}
66-
enabledOption={{
67-
id: `${fieldPath}_true`,
68-
label: 'True',
69-
}}
70-
disabledOption={{
71-
id: `${fieldPath}_false`,
72-
label: 'False',
73-
}}
74-
showLabel={true}
7566
/>
7667
<EuiSpacer size={CONFIG_FIELD_SPACER_SIZE} />
7768
</EuiFlexItem>

public/pages/workflow_detail/workflow_inputs/input_fields/boolean_field.tsx

+29-39
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,17 @@
66
import React from 'react';
77
import { Field, FieldProps } from 'formik';
88
import {
9-
EuiCompressedFormRow,
10-
EuiCompressedRadioGroup,
11-
EuiLink,
12-
EuiRadioGroupOption,
9+
EuiCompressedCheckbox,
10+
EuiFlexGroup,
11+
EuiFlexItem,
12+
EuiIconTip,
1313
EuiText,
1414
} from '@elastic/eui';
15-
import { camelCaseToTitleString } from '../../../../utils';
1615

1716
interface BooleanFieldProps {
1817
fieldPath: string; // the full path in string-form to the field (e.g., 'ingest.enrich.processors.text_embedding_processor.inputField')
19-
enabledOption: EuiRadioGroupOption;
20-
disabledOption: EuiRadioGroupOption;
21-
label?: string;
22-
helpLink?: string;
18+
label: string;
2319
helpText?: string;
24-
showLabel?: boolean;
2520
}
2621

2722
/**
@@ -32,37 +27,32 @@ export function BooleanField(props: BooleanFieldProps) {
3227
<Field name={props.fieldPath}>
3328
{({ field, form }: FieldProps) => {
3429
return (
35-
<EuiCompressedFormRow
36-
key={props.fieldPath}
30+
<EuiCompressedCheckbox
31+
data-testid={`checkbox-${field.name}`}
32+
id={`checkbox-${field.name}`}
3733
label={
38-
props.showLabel &&
39-
(props.label || camelCaseToTitleString(field.name))
34+
<>
35+
<EuiFlexGroup direction="row">
36+
<EuiFlexItem grow={false}>
37+
<EuiText size="s">{props.label}</EuiText>
38+
</EuiFlexItem>
39+
{props.helpText && (
40+
<EuiFlexItem
41+
grow={false}
42+
style={{ marginLeft: '-8px', marginTop: '10px' }}
43+
>
44+
<EuiIconTip content={props.helpText} position="right" />
45+
</EuiFlexItem>
46+
)}
47+
</EuiFlexGroup>
48+
</>
4049
}
41-
labelAppend={
42-
props.helpLink ? (
43-
<EuiText size="xs">
44-
<EuiLink href={props.helpLink} target="_blank">
45-
Learn more
46-
</EuiLink>
47-
</EuiText>
48-
) : undefined
49-
}
50-
helpText={props.helpText || undefined}
51-
isInvalid={false}
52-
>
53-
<EuiCompressedRadioGroup
54-
options={[props.enabledOption, props.disabledOption]}
55-
idSelected={
56-
field.value === undefined || field.value === true
57-
? props.enabledOption.id
58-
: props.disabledOption.id
59-
}
60-
onChange={(id) => {
61-
form.setFieldValue(field.name, !field.value);
62-
form.setFieldTouched(field.name, true);
63-
}}
64-
/>
65-
</EuiCompressedFormRow>
50+
checked={field.value === undefined || field.value === true}
51+
onChange={() => {
52+
form.setFieldValue(field.name, !field.value);
53+
form.setFieldTouched(field.name, true);
54+
}}
55+
/>
6656
);
6757
}}
6858
</Field>

public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
EuiIconTip,
3030
EuiCompressedSwitch,
3131
EuiCallOut,
32+
EuiAccordion,
3233
} from '@elastic/eui';
3334
import {
3435
IConfigField,
@@ -37,7 +38,6 @@ import {
3738
InputTransformFormValues,
3839
InputTransformSchema,
3940
JSONPATH_ROOT_SELECTOR,
40-
ML_INFERENCE_RESPONSE_DOCS_LINK,
4141
MapArrayFormValue,
4242
ModelInterface,
4343
PROCESSOR_CONTEXT,
@@ -331,16 +331,6 @@ export function InputTransformModal(props: InputTransformModalProps) {
331331
<BooleanField
332332
label={'One-to-one'}
333333
fieldPath={'one_to_one'}
334-
enabledOption={{
335-
id: `one_to_one_true`,
336-
label: 'True',
337-
}}
338-
disabledOption={{
339-
id: `one_to_one_false`,
340-
label: 'False',
341-
}}
342-
showLabel={true}
343-
helpLink={ML_INFERENCE_RESPONSE_DOCS_LINK}
344334
helpText="Run inference for each document separately"
345335
/>
346336
);
@@ -544,6 +534,21 @@ export function InputTransformModal(props: InputTransformModalProps) {
544534
</EuiFlexGroup>
545535
<EuiSpacer size="s" />
546536
{InputMap}
537+
{props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE && (
538+
<>
539+
<EuiSpacer size="s" />
540+
<EuiAccordion
541+
id={`advancedSettingsInputTransform${props.config.id}`}
542+
buttonContent="Advanced settings"
543+
paddingSize="none"
544+
>
545+
<EuiSpacer size="s" />
546+
<EuiFlexItem style={{ marginLeft: '4px' }}>
547+
{OneToOneConfig}
548+
</EuiFlexItem>
549+
</EuiAccordion>
550+
</>
551+
)}
547552
</>
548553
</EuiFlexItem>
549554
<EuiFlexItem>
@@ -573,12 +578,6 @@ export function InputTransformModal(props: InputTransformModalProps) {
573578
<EuiSpacer size="s" />
574579
</>
575580
)}
576-
{props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE && (
577-
<>
578-
{OneToOneConfig}
579-
<EuiSpacer size="s" />
580-
</>
581-
)}
582581
{FetchButton}
583582
</>
584583
</EuiFlexItem>

public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/output_transform_modal.tsx

+18-25
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ import {
2727
EuiCodeBlock,
2828
EuiCallOut,
2929
EuiIconTip,
30+
EuiAccordion,
3031
} from '@elastic/eui';
3132
import {
3233
IConfigField,
3334
IProcessorConfig,
3435
IngestPipelineConfig,
3536
JSONPATH_ROOT_SELECTOR,
36-
ML_INFERENCE_DOCS_LINK,
37-
ML_INFERENCE_RESPONSE_DOCS_LINK,
3837
MapArrayFormValue,
3938
ModelInterface,
4039
OutputTransformFormValues,
@@ -254,22 +253,8 @@ root object selector "${JSONPATH_ROOT_SELECTOR}"`}
254253

255254
const FullResponsePathConfig = (
256255
<BooleanField
257-
label={'Full response path'}
256+
label={'Full Response Path'}
258257
fieldPath={'full_response_path'}
259-
enabledOption={{
260-
id: `full_response_path_true`,
261-
label: 'True',
262-
}}
263-
disabledOption={{
264-
id: `full_response_path_false`,
265-
label: 'False',
266-
}}
267-
showLabel={true}
268-
helpLink={
269-
props.context === PROCESSOR_CONTEXT.INGEST
270-
? ML_INFERENCE_DOCS_LINK
271-
: ML_INFERENCE_RESPONSE_DOCS_LINK
272-
}
273258
helpText="Parse the full model output"
274259
/>
275260
);
@@ -474,6 +459,22 @@ root object selector "${JSONPATH_ROOT_SELECTOR}"`}
474459
</EuiFlexGroup>
475460
<EuiSpacer size="s" />
476461
{OutputMap}
462+
{(props.context === PROCESSOR_CONTEXT.INGEST ||
463+
props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE) && (
464+
<>
465+
<EuiSpacer size="s" />
466+
<EuiAccordion
467+
id={`advancedSettingsOutputTransform${props.config.id}`}
468+
buttonContent="Advanced settings"
469+
paddingSize="none"
470+
>
471+
<EuiSpacer size="s" />
472+
<EuiFlexItem style={{ marginLeft: '4px' }}>
473+
{FullResponsePathConfig}
474+
</EuiFlexItem>
475+
</EuiAccordion>
476+
</>
477+
)}
477478
</>
478479
</EuiFlexItem>
479480
<EuiFlexItem>
@@ -508,14 +509,6 @@ root object selector "${JSONPATH_ROOT_SELECTOR}"`}
508509
<EuiSpacer size="s" />
509510
</>
510511
)}
511-
{(props.context === PROCESSOR_CONTEXT.INGEST ||
512-
props.context ===
513-
PROCESSOR_CONTEXT.SEARCH_RESPONSE) && (
514-
<>
515-
{FullResponsePathConfig}
516-
<EuiSpacer size="s" />
517-
</>
518-
)}
519512
{FetchButton}
520513
</>
521514
</EuiFlexItem>

public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx

+2-32
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ interface WorkflowInputsProps {
8282
setUnsavedSearchProcessors: (unsavedSearchProcessors: boolean) => void;
8383
}
8484

85-
enum INGEST_OPTION {
86-
CREATE = 'create',
87-
SKIP = 'skip',
88-
}
89-
9085
/**
9186
* The workflow inputs component containing the multi-step flow to create ingest
9287
* and search flows for a particular workflow.
@@ -692,33 +687,8 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
692687
<>
693688
<BooleanField
694689
fieldPath="ingest.enabled"
695-
enabledOption={{
696-
id: INGEST_OPTION.CREATE,
697-
label: (
698-
<EuiFlexGroup direction="column" gutterSize="none">
699-
<EuiText color="default">
700-
Create an ingest pipeline
701-
</EuiText>
702-
<EuiText size="xs" color="subdued">
703-
Configure and ingest data into an index.
704-
</EuiText>
705-
</EuiFlexGroup>
706-
),
707-
}}
708-
disabledOption={{
709-
id: INGEST_OPTION.SKIP,
710-
label: (
711-
<EuiFlexGroup direction="column" gutterSize="none">
712-
<EuiText color="default">
713-
Skip ingestion pipeline
714-
</EuiText>
715-
<EuiText size="xs" color="subdued">
716-
Use an existing index with data ingested.
717-
</EuiText>
718-
</EuiFlexGroup>
719-
),
720-
}}
721-
showLabel={false}
690+
label="Enabled"
691+
helpText="Create a new ingest pipeline and index"
722692
/>
723693
</>
724694
)}

0 commit comments

Comments
 (0)