Skip to content

Commit dec20a8

Browse files
[7.x] System index templates can't be edited (#55229) (#56417)
1 parent 107976d commit dec20a8

File tree

2 files changed

+65
-62
lines changed

2 files changed

+65
-62
lines changed

x-pack/legacy/plugins/index_management/public/app/components/template_form/steps/step_logistics.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/components';
1919
import { documentationService } from '../../../services/documentation';
2020
import { StepProps } from '../types';
21-
import { schemas } from '../template_form_schemas';
21+
import { schemas, nameConfig, nameConfigWithoutValidations } from '../template_form_schemas';
2222

2323
// Create or Form components with partial props that are common to all instances
2424
const UseField = getUseField({ component: Field });
@@ -131,6 +131,7 @@ export const StepLogistics: React.FunctionComponent<StepProps> = ({
131131
['data-test-subj']: name.testSubject,
132132
euiFieldProps: { disabled: isEditing },
133133
}}
134+
config={isEditing ? nameConfigWithoutValidations : nameConfig}
134135
/>
135136
</FormRow>
136137
{/* Index patterns */}

x-pack/legacy/plugins/index_management/public/app/components/template_form/template_form_schemas.tsx

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
FormSchema,
1313
FIELD_TYPES,
1414
VALIDATION_TYPES,
15+
FieldConfig,
1516
} from '../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib';
1617

1718
import {
@@ -34,70 +35,71 @@ const {
3435
const { toInt } = fieldFormatters;
3536
const indexPatternInvalidCharacters = INVALID_INDEX_PATTERN_CHARS.join(' ');
3637

37-
export const schemas: Record<string, FormSchema> = {
38-
logistics: {
39-
name: {
40-
type: FIELD_TYPES.TEXT,
41-
label: i18n.translate('xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel', {
42-
defaultMessage: 'Name',
38+
export const nameConfig: FieldConfig = {
39+
type: FIELD_TYPES.TEXT,
40+
label: i18n.translate('xpack.idxMgmt.templateForm.stepLogistics.fieldNameLabel', {
41+
defaultMessage: 'Name',
42+
}),
43+
validations: [
44+
{
45+
validator: emptyField(
46+
i18n.translate('xpack.idxMgmt.templateValidation.templateNameRequiredError', {
47+
defaultMessage: 'A template name is required.',
48+
})
49+
),
50+
},
51+
{
52+
validator: containsCharsField({
53+
chars: ' ',
54+
message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameSpacesError', {
55+
defaultMessage: 'Spaces are not allowed in a template name.',
56+
}),
4357
}),
44-
validations: [
45-
{
46-
validator: emptyField(
47-
i18n.translate('xpack.idxMgmt.templateValidation.templateNameRequiredError', {
48-
defaultMessage: 'A template name is required.',
49-
})
50-
),
51-
},
52-
{
53-
validator: containsCharsField({
54-
chars: ' ',
55-
message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameSpacesError', {
56-
defaultMessage: 'Spaces are not allowed in a template name.',
57-
}),
58-
}),
59-
},
60-
{
61-
validator: startsWithField({
62-
char: '_',
63-
message: i18n.translate(
64-
'xpack.idxMgmt.templateValidation.templateNameUnderscoreError',
65-
{
66-
defaultMessage: 'A template name must not start with an underscore.',
67-
}
68-
),
69-
}),
70-
},
71-
{
72-
validator: startsWithField({
73-
char: '.',
74-
message: i18n.translate('xpack.idxMgmt.templateValidation.templateNamePeriodError', {
75-
defaultMessage: 'A template name must not start with a period.',
76-
}),
77-
}),
78-
},
79-
{
80-
validator: containsCharsField({
81-
chars: INVALID_TEMPLATE_NAME_CHARS,
82-
message: ({ charsFound }) =>
83-
i18n.translate(
84-
'xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError',
85-
{
86-
defaultMessage: 'A template name must not contain the character "{invalidChar}"',
87-
values: { invalidChar: charsFound[0] },
88-
}
89-
),
58+
},
59+
{
60+
validator: startsWithField({
61+
char: '_',
62+
message: i18n.translate('xpack.idxMgmt.templateValidation.templateNameUnderscoreError', {
63+
defaultMessage: 'A template name must not start with an underscore.',
64+
}),
65+
}),
66+
},
67+
{
68+
validator: startsWithField({
69+
char: '.',
70+
message: i18n.translate('xpack.idxMgmt.templateValidation.templateNamePeriodError', {
71+
defaultMessage: 'A template name must not start with a period.',
72+
}),
73+
}),
74+
},
75+
{
76+
validator: containsCharsField({
77+
chars: INVALID_TEMPLATE_NAME_CHARS,
78+
message: ({ charsFound }) =>
79+
i18n.translate('xpack.idxMgmt.templateValidation.templateNameInvalidaCharacterError', {
80+
defaultMessage: 'A template name must not contain the character "{invalidChar}"',
81+
values: { invalidChar: charsFound[0] },
9082
}),
91-
},
92-
{
93-
validator: lowerCaseStringField(
94-
i18n.translate('xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError', {
95-
defaultMessage: 'The template name must be in lowercase.',
96-
})
97-
),
98-
},
99-
],
83+
}),
10084
},
85+
{
86+
validator: lowerCaseStringField(
87+
i18n.translate('xpack.idxMgmt.templateValidation.templateNameLowerCaseRequiredError', {
88+
defaultMessage: 'The template name must be in lowercase.',
89+
})
90+
),
91+
},
92+
],
93+
};
94+
95+
export const nameConfigWithoutValidations: FieldConfig = {
96+
...nameConfig,
97+
validations: [],
98+
};
99+
100+
export const schemas: Record<string, FormSchema> = {
101+
logistics: {
102+
name: nameConfig,
101103
indexPatterns: {
102104
type: FIELD_TYPES.COMBO_BOX,
103105
defaultValue: [],

0 commit comments

Comments
 (0)