Skip to content

Commit

Permalink
[Ingest pipelines] Make description field optional (#65961)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored May 11, 2020
1 parent d5737a5 commit a3d3ae9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,11 @@ describe('<PipelinesCreate />', () => {
component.update();
});

expect(form.getErrorsMessages()).toEqual([
'Name is required.',
'A description is required.',
]);
expect(form.getErrorsMessages()).toEqual(['Name is required.']);
expect(find('submitButton').props().disabled).toEqual(true);

// Add required fields and verify button is enabled again
form.setInputValue('nameField.input', 'my_pipeline');
form.setInputValue('descriptionField.input', 'pipeline description');

await act(async () => {
await nextTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,8 @@ export const pipelineFormSchema: FormSchema = {
description: {
type: FIELD_TYPES.TEXTAREA,
label: i18n.translate('xpack.ingestPipelines.form.descriptionFieldLabel', {
defaultMessage: 'Description',
defaultMessage: 'Description (optional)',
}),
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.form.pipelineDescriptionRequiredError', {
defaultMessage: 'A description is required.',
})
),
},
],
},
processors: {
label: i18n.translate('xpack.ingestPipelines.form.processorsFieldLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ export const PipelineDetailsFlyout: FunctionComponent<Props> = ({
<EuiFlyoutBody>
<EuiDescriptionList>
{/* Pipeline description */}
<EuiDescriptionListTitle>
{i18n.translate('xpack.ingestPipelines.list.pipelineDetails.descriptionTitle', {
defaultMessage: 'Description',
})}
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{pipeline.description ?? ''}
</EuiDescriptionListDescription>
{pipeline.description && (
<>
<EuiDescriptionListTitle>
{i18n.translate('xpack.ingestPipelines.list.pipelineDetails.descriptionTitle', {
defaultMessage: 'Description',
})}
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>{pipeline.description}</EuiDescriptionListDescription>
</>
)}

{/* Pipeline version */}
{pipeline.version && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RouteDependencies } from '../../types';

const bodySchema = schema.object({
name: schema.string(),
description: schema.string(),
description: schema.maybe(schema.string()),
processors: schema.arrayOf(schema.recordOf(schema.string(), schema.any())),
version: schema.maybe(schema.number()),
on_failure: schema.maybe(schema.arrayOf(schema.recordOf(schema.string(), schema.any()))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default function({ getService }: FtrProviderContext) {
describe('Pipelines', function() {
describe('Create', () => {
const PIPELINE_ID = 'test_create_pipeline';
after(() => deletePipeline(PIPELINE_ID));
const REQUIRED_FIELDS_PIPELINE_ID = 'test_create_required_fields_pipeline';

after(() => {
deletePipeline(PIPELINE_ID);
deletePipeline(REQUIRED_FIELDS_PIPELINE_ID);
});

it('should create a pipeline', async () => {
const { body } = await supertest
Expand Down Expand Up @@ -52,6 +57,28 @@ export default function({ getService }: FtrProviderContext) {
});
});

it('should create a pipeline with only required fields', async () => {
const { body } = await supertest
.post(API_BASE_PATH)
.set('kbn-xsrf', 'xxx')
// Excludes description, version and on_failure processors
.send({
name: REQUIRED_FIELDS_PIPELINE_ID,
processors: [
{
script: {
source: 'ctx._type = null',
},
},
],
})
.expect(200);

expect(body).to.eql({
acknowledged: true,
});
});

it('should not allow creation of an existing pipeline', async () => {
const { body } = await supertest
.post(API_BASE_PATH)
Expand Down

0 comments on commit a3d3ae9

Please sign in to comment.