diff --git a/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx index 290ade3504551..d2134837c15e5 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx @@ -18,7 +18,7 @@ import { } from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/components'; import { documentationService } from '../../../services/documentation'; import { StepProps } from '../types'; -import { schemas } from '../template_form_schemas'; +import { schemas, nameConfig, nameConfigWithoutValidations } from '../template_form_schemas'; // Create or Form components with partial props that are common to all instances const UseField = getUseField({ component: Field }); @@ -131,6 +131,7 @@ export const StepLogistics: React.FunctionComponent = ({ ['data-test-subj']: name.testSubject, euiFieldProps: { disabled: isEditing }, }} + config={isEditing ? nameConfigWithoutValidations : nameConfig} /> {/* Index patterns */} diff --git a/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx index 5f3e28ddffb8e..ed2616cc64e38 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx @@ -12,6 +12,7 @@ import { FormSchema, FIELD_TYPES, VALIDATION_TYPES, + FieldConfig, } from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; import { @@ -34,70 +35,71 @@ const { const { toInt } = fieldFormatters; const indexPatternInvalidCharacters = INVALID_INDEX_PATTERN_CHARS.join(' '); -export const schemas: Record = { - logistics: { - name: { - type: FIELD_TYPES.TEXT, - label: i18n.translate('xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel', { - defaultMessage: 'Name', +export const nameConfig: FieldConfig = { + type: FIELD_TYPES.TEXT, + label: i18n.translate('xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel', { + defaultMessage: 'Name', + }), + validations: [ + { + validator: emptyField( + i18n.translate('xpack.idxMgmt.templateValidation.templateNameRequiredError', { + defaultMessage: 'A template name is required.', + }) + ), + }, + { + validator: containsCharsField({ + chars: ' ', + message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameSpacesError', { + defaultMessage: 'Spaces are not allowed in a template name.', + }), }), - validations: [ - { - validator: emptyField( - i18n.translate('xpack.idxMgmt.templateValidation.templateNameRequiredError', { - defaultMessage: 'A template name is required.', - }) - ), - }, - { - validator: containsCharsField({ - chars: ' ', - message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameSpacesError', { - defaultMessage: 'Spaces are not allowed in a template name.', - }), - }), - }, - { - validator: startsWithField({ - char: '_', - message: i18n.translate( - 'xpack.idxMgmt.templateValidation.templateNameUnderscoreError', - { - defaultMessage: 'A template name must not start with an underscore.', - } - ), - }), - }, - { - validator: startsWithField({ - char: '.', - message: i18n.translate('xpack.idxMgmt.templateValidation.templateNamePeriodError', { - defaultMessage: 'A template name must not start with a period.', - }), - }), - }, - { - validator: containsCharsField({ - chars: INVALID_TEMPLATE_NAME_CHARS, - message: ({ charsFound }) => - i18n.translate( - 'xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError', - { - defaultMessage: 'A template name must not contain the character "{invalidChar}"', - values: { invalidChar: charsFound[0] }, - } - ), + }, + { + validator: startsWithField({ + char: '_', + message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameUnderscoreError', { + defaultMessage: 'A template name must not start with an underscore.', + }), + }), + }, + { + validator: startsWithField({ + char: '.', + message: i18n.translate('xpack.idxMgmt.templateValidation.templateNamePeriodError', { + defaultMessage: 'A template name must not start with a period.', + }), + }), + }, + { + validator: containsCharsField({ + chars: INVALID_TEMPLATE_NAME_CHARS, + message: ({ charsFound }) => + i18n.translate('xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError', { + defaultMessage: 'A template name must not contain the character "{invalidChar}"', + values: { invalidChar: charsFound[0] }, }), - }, - { - validator: lowerCaseStringField( - i18n.translate('xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError', { - defaultMessage: 'The template name must be in lowercase.', - }) - ), - }, - ], + }), }, + { + validator: lowerCaseStringField( + i18n.translate('xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError', { + defaultMessage: 'The template name must be in lowercase.', + }) + ), + }, + ], +}; + +export const nameConfigWithoutValidations: FieldConfig = { + ...nameConfig, + validations: [], +}; + +export const schemas: Record = { + logistics: { + name: nameConfig, indexPatterns: { type: FIELD_TYPES.COMBO_BOX, defaultValue: [],