[Ingest pipelines] Make description field optional (#65961)

This commit is contained in:
Alison Goryachev 2020-05-11 10:05:27 -04:00 committed by GitHub
parent d5737a54c2
commit a3d3ae9661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 25 deletions

View file

@ -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();

View file

@ -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', {

View file

@ -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 && (

View file

@ -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()))),

View file

@ -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
@ -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)