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

Feature: Add Ability to Select a Search Pipeline in Comparison Tool #352

Merged
merged 13 commits into from
Jan 26, 2024
Prev Previous commit
Next Next commit
Update test coverages
Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>
  • Loading branch information
nung22 committed Dec 19, 2023
commit a7fba795f88bdf5fd49e04fc2903a605e49449f4
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ describe('Flyout component', () => {
wrapper.find('EuiCodeEditor').prop('onChange')?.({ target: { value: '' } });
wrapper.find('EuiSelect').prop('onChange')?.({ target: {} });
wrapper.find('EuiSelect').prop('onBlur')?.({ target: {} });
wrapper.find('EuiComboBox').prop('onChange')?.({ target: { selectedOptions: [] } });
wrapper.find('EuiComboBox').prop('onChange')?.({
target: { selectedOptions: [{ label: '_none' }] },
});
});
expect(setQueryString).toHaveBeenCalledTimes(1);
expect(setSelectedIndex).toHaveBeenCalledTimes(1);
expect(setPipeline).toHaveBeenCalledTimes(2);
expect(setQueryError).toHaveBeenCalledTimes(3);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ export const SearchConfig: FunctionComponent<SearchConfigProps> = ({
};

// Sort search pipelines based off of each individual pipeline name.
const sortedPipelines = [...Object.keys(pipelines)].sort((a, b) => a.localeCompare(b));
sortedPipelines.push('_none');
const sortedPipelines = [...Object.keys(pipelines)]
.sort((a, b) => a.localeCompare(b))
.map((searchPipeline) => ({
label: searchPipeline,
}));
// Add the '_none' option to the pipeline dropdown (runs the index without a pipeline).
sortedPipelines.push({ label: '_none' });

// On select index for ComboBox
const onChangePipeline = (selectedOptions: string | any[]) => {
if (selectedOptions.length === 0) {
setPipeline('');
} else {
setPipeline(selectedOptions[0].label);
}
setPipeline(selectedOptions[0]?.label || '');
};

// Select index on blur
Expand Down Expand Up @@ -131,17 +132,13 @@ export const SearchConfig: FunctionComponent<SearchConfigProps> = ({
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow fullWidth label="Pipeline" helpText="Optional">
{
<EuiComboBox
placeholder=""
singleSelection={{ asPlainText: true }}
options={sortedPipelines.map((searchPipeline) => ({
label: searchPipeline,
}))}
selectedOptions={pipeline ? [{ label: pipeline }] : []}
onChange={onChangePipeline}
/>
}
<EuiComboBox
placeholder=""
singleSelection={{ asPlainText: true }}
options={sortedPipelines}
selectedOptions={pipeline ? [{ label: pipeline }] : []}
onChange={onChangePipeline}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down