From 9ff032558ec4a402f8902ad59517144e1678b569 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:55:08 +1100 Subject: [PATCH] [8.17] [Index Management] Fix schema for index templates (#203552) (#203724) # Backport This will backport the following commits from `main` to `8.17`: - [[Index Management] Fix schema for index templates (#203552)](https://github.com/elastic/kibana/pull/203552) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com> --- .../common/types/templates.ts | 2 +- .../template_form/steps/step_review.tsx | 22 +++++++++++-------- .../template_details/tabs/tab_summary.tsx | 22 +++++++++++-------- .../routes/api/templates/validate_schemas.ts | 2 +- .../index_management/lib/templates.helpers.ts | 1 - 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/index_management/common/types/templates.ts b/x-pack/plugins/index_management/common/types/templates.ts index ab4614200c0b5..ffcc27ed08971 100644 --- a/x-pack/plugins/index_management/common/types/templates.ts +++ b/x-pack/plugins/index_management/common/types/templates.ts @@ -51,7 +51,7 @@ export interface TemplateDeserialized { priority?: number; // Composable template only allowAutoCreate: string; order?: number; // Legacy template only - indexMode: IndexMode; + indexMode?: IndexMode; ilmPolicy?: { name: string; }; diff --git a/x-pack/plugins/index_management/public/application/components/template_form/steps/step_review.tsx b/x-pack/plugins/index_management/public/application/components/template_form/steps/step_review.tsx index 593655da62fef..4e1901538cb93 100644 --- a/x-pack/plugins/index_management/public/application/components/template_form/steps/step_review.tsx +++ b/x-pack/plugins/index_management/public/application/components/template_form/steps/step_review.tsx @@ -271,15 +271,19 @@ export const StepReview: React.FunctionComponent = React.memo( {/* Index mode */} - - - - - {indexModeLabels[indexMode]} - + {indexMode && ( + <> + + + + + {indexModeLabels[indexMode]} + + + )} {/* Mappings */} diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_summary.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_summary.tsx index 2621f3ec483c1..f9c90e1b944e6 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_summary.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_details/tabs/tab_summary.tsx @@ -224,15 +224,19 @@ export const TabSummary: React.FunctionComponent = ({ templateDetails }) )} {/* Index mode */} - - - - - {indexModeLabels[indexMode]} - + {indexMode && ( + <> + + + + + {indexModeLabels[indexMode]} + + + )} {/* Allow auto create */} {isLegacy !== true && diff --git a/x-pack/plugins/index_management/server/routes/api/templates/validate_schemas.ts b/x-pack/plugins/index_management/server/routes/api/templates/validate_schemas.ts index cfd9c1d18e610..5bea0c36067c0 100644 --- a/x-pack/plugins/index_management/server/routes/api/templates/validate_schemas.ts +++ b/x-pack/plugins/index_management/server/routes/api/templates/validate_schemas.ts @@ -13,7 +13,7 @@ export const templateSchema = schema.object({ version: schema.maybe(schema.number()), order: schema.maybe(schema.number()), priority: schema.maybe(schema.number()), - indexMode: schema.string(), + indexMode: schema.maybe(schema.string()), // Not present for legacy templates allowAutoCreate: schema.maybe(schema.string()), template: schema.maybe( diff --git a/x-pack/test/api_integration/apis/management/index_management/lib/templates.helpers.ts b/x-pack/test/api_integration/apis/management/index_management/lib/templates.helpers.ts index a342df2d6287e..ea1e9a2d83bb1 100644 --- a/x-pack/test/api_integration/apis/management/index_management/lib/templates.helpers.ts +++ b/x-pack/test/api_integration/apis/management/index_management/lib/templates.helpers.ts @@ -59,7 +59,6 @@ export function templatesHelpers(getService: FtrProviderContext['getService']) { name, indexPatterns, version: 1, - indexMode: 'standard', template: { ...getTemplateMock(isMappingsSourceFieldEnabled) }, _kbnMeta: { isLegacy,