diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx
index c5c5de20c1a82..073de7e8dd23b 100644
--- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx
+++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.test.tsx
@@ -450,8 +450,6 @@ describe('', () => {
testBed = await setup(httpSetup);
});
testBed.component.update();
-
- const { actions } = testBed;
});
it('setting index pattern to logs-*-* should set the index mode to logsdb', async () => {
diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts
index 7f0b6c2ce41d5..7c02608d4e3f7 100644
--- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts
+++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts
@@ -371,6 +371,7 @@ export type TestSubjects =
| 'priorityField.input'
| 'dataStreamField.input'
| 'indexModeField'
+ | 'indexModeCallout'
| 'dataRetentionToggle.input'
| 'allowAutoCreateField.input'
| 'pageTitle'
diff --git a/x-pack/plugins/index_management/common/lib/template_serialization.test.ts b/x-pack/plugins/index_management/common/lib/template_serialization.test.ts
index 8f9f73c334a9f..cb86de2660fd3 100644
--- a/x-pack/plugins/index_management/common/lib/template_serialization.test.ts
+++ b/x-pack/plugins/index_management/common/lib/template_serialization.test.ts
@@ -6,7 +6,8 @@
*/
import { deserializeTemplate, serializeTemplate } from './template_serialization';
-import { TemplateDeserialized, TemplateSerialized } from '../types';
+import { TemplateDeserialized, TemplateSerialized, IndexMode } from '../types';
+import { STANDARD_INDEX_MODE, LOGSDB_INDEX_MODE, TIME_SERIES_MODE } from '../constants';
const defaultSerializedTemplate: TemplateSerialized = {
template: {},
@@ -17,6 +18,7 @@ const defaultSerializedTemplate: TemplateSerialized = {
const defaultDeserializedTemplate: TemplateDeserialized = {
name: 'my_template',
indexPatterns: ['test'],
+ indexMode: STANDARD_INDEX_MODE,
_kbnMeta: {
type: 'default',
hasDatastream: true,
@@ -26,12 +28,13 @@ const defaultDeserializedTemplate: TemplateDeserialized = {
const allowAutoCreateRadioOptions = ['NO_OVERWRITE', 'TRUE', 'FALSE'];
const allowAutoCreateSerializedValues = [undefined, true, false];
+const indexModeValues = [STANDARD_INDEX_MODE, LOGSDB_INDEX_MODE, TIME_SERIES_MODE, undefined];
describe('Template serialization', () => {
describe('serialization of allow_auto_create parameter', () => {
describe('deserializeTemplate()', () => {
allowAutoCreateSerializedValues.forEach((value, index) => {
- test(`correctly deserializes ${value} value`, () => {
+ test(`correctly deserializes ${value} allow_auto_create value`, () => {
expect(
deserializeTemplate({
...defaultSerializedTemplate,
@@ -41,11 +44,29 @@ describe('Template serialization', () => {
).toHaveProperty('allowAutoCreate', allowAutoCreateRadioOptions[index]);
});
});
+
+ indexModeValues.forEach((value) => {
+ test(`correctly deserializes ${value} index mode settings value`, () => {
+ expect(
+ deserializeTemplate({
+ ...defaultSerializedTemplate,
+ name: 'my_template',
+ template: {
+ settings: {
+ index: {
+ mode: value,
+ },
+ },
+ },
+ })
+ ).toHaveProperty('indexMode', value ?? STANDARD_INDEX_MODE);
+ });
+ });
});
describe('serializeTemplate()', () => {
allowAutoCreateRadioOptions.forEach((option, index) => {
- test(`correctly serializes ${option} radio option`, () => {
+ test(`correctly serializes ${option} allowAutoCreate radio option`, () => {
expect(
serializeTemplate({
...defaultDeserializedTemplate,
@@ -54,6 +75,18 @@ describe('Template serialization', () => {
).toHaveProperty('allow_auto_create', allowAutoCreateSerializedValues[index]);
});
});
+
+ // Only use the first three values (omit undefined)
+ indexModeValues.slice(0, 3).forEach((value) => {
+ test(`correctly serializes ${value} indexMode option`, () => {
+ expect(
+ serializeTemplate({
+ ...defaultDeserializedTemplate,
+ indexMode: value as IndexMode,
+ })
+ ).toHaveProperty('template.settings.index.mode', value);
+ });
+ });
});
});
});
diff --git a/x-pack/plugins/index_management/common/lib/template_serialization.ts b/x-pack/plugins/index_management/common/lib/template_serialization.ts
index 8812880cb7caa..999023704559c 100644
--- a/x-pack/plugins/index_management/common/lib/template_serialization.ts
+++ b/x-pack/plugins/index_management/common/lib/template_serialization.ts
@@ -11,6 +11,7 @@ import {
TemplateSerialized,
TemplateListItem,
TemplateType,
+ IndexMode,
} from '../types';
import { deserializeESLifecycle } from './data_stream_utils';
import {
@@ -90,11 +91,10 @@ export function deserializeTemplate(
const ilmPolicyName = settings?.index?.lifecycle?.name;
- const indexMode =
- settings?.index?.mode ??
+ const indexMode = (settings?.index?.mode ??
(indexPatterns.some((pattern) => pattern === 'logs-*-*')
? LOGSDB_INDEX_MODE
- : STANDARD_INDEX_MODE);
+ : STANDARD_INDEX_MODE)) as IndexMode;
const deserializedTemplate: TemplateDeserialized = {
name,
diff --git a/x-pack/plugins/index_management/common/types/index.ts b/x-pack/plugins/index_management/common/types/index.ts
index ef2e8a389c079..7ec100bc1d366 100644
--- a/x-pack/plugins/index_management/common/types/index.ts
+++ b/x-pack/plugins/index_management/common/types/index.ts
@@ -19,6 +19,7 @@ export type {
DataStream,
DataStreamIndex,
DataRetention,
+ IndexMode,
} from './data_streams';
export * from './component_templates';
diff --git a/x-pack/plugins/index_management/common/types/templates.ts b/x-pack/plugins/index_management/common/types/templates.ts
index ac1d42cc5ae22..ab4614200c0b5 100644
--- a/x-pack/plugins/index_management/common/types/templates.ts
+++ b/x-pack/plugins/index_management/common/types/templates.ts
@@ -5,7 +5,7 @@
* 2.0.
*/
-import { DataRetention, DataStream } from './data_streams';
+import { DataRetention, DataStream, IndexMode } from './data_streams';
import { IndexSettings } from './indices';
import { Aliases } from './aliases';
import { Mappings } from './mappings';
@@ -51,7 +51,7 @@ export interface TemplateDeserialized {
priority?: number; // Composable template only
allowAutoCreate: string;
order?: number; // Legacy template only
- indexMode: string;
+ indexMode: IndexMode;
ilmPolicy?: {
name: string;
};
diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_wizard/component_template_form/component_template_form.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_wizard/component_template_form/component_template_form.tsx
index 683bd56c614c5..ca791311d2408 100644
--- a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_wizard/component_template_form/component_template_form.tsx
+++ b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_wizard/component_template_form/component_template_form.tsx
@@ -258,10 +258,7 @@ export const ComponentTemplateForm = ({
-
+
diff --git a/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings.tsx b/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings.tsx
index 53bcf20e2d866..d963962b0431a 100644
--- a/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings.tsx
+++ b/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings.tsx
@@ -26,7 +26,7 @@ import { Forms } from '../../../../../shared_imports';
import { useJsonStep } from './use_json_step';
import { documentationService } from '../../../mappings_editor/shared_imports';
import { indexModeLabels } from '../../../../lib/index_mode_labels';
-import { IndexMode } from '../../../../../../common/types/data_streams';
+import { IndexMode } from '../../../../../../common/types';
interface Props {
onChange: (content: Forms.Content) => void;
diff --git a/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings_container.tsx b/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings_container.tsx
index 362e6f474dd48..5566b8dedd554 100644
--- a/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings_container.tsx
+++ b/x-pack/plugins/index_management/public/application/components/shared/components/wizard_steps/step_settings_container.tsx
@@ -8,12 +8,14 @@
import React from 'react';
import { Forms } from '../../../../../shared_imports';
+import { TemplateDeserialized } from '../../../../../../common';
+import { WizardContent } from '../../../template_form/template_form';
import { CommonWizardSteps } from './types';
import { StepSettings } from './step_settings';
interface Props {
esDocsBase: string;
- getTemplateData: (wizardContent: WizardContent) => TemplateDeserialized;
+ getTemplateData?: (wizardContent: WizardContent) => TemplateDeserialized;
}
export const StepSettingsContainer = React.memo(({ esDocsBase, getTemplateData }: Props) => {
@@ -22,16 +24,20 @@ export const StepSettingsContainer = React.memo(({ esDocsBase, getTemplateData }
);
const { getData } = Forms.useMultiContentContext();
- const wizardContent = getData();
- // Build the current template object, providing the wizard content data
- const template = getTemplateData(wizardContent);
+ let indexMode;
+ if (getTemplateData) {
+ const wizardContent = getData();
+ // Build the current template object, providing the wizard content data
+ const template = getTemplateData(wizardContent);
+ indexMode = template.indexMode;
+ }
return (
);
});
diff --git a/x-pack/plugins/index_management/public/application/components/template_form/template_form.tsx b/x-pack/plugins/index_management/public/application/components/template_form/template_form.tsx
index b1d1c8c192200..53b53a6ebdeee 100644
--- a/x-pack/plugins/index_management/public/application/components/template_form/template_form.tsx
+++ b/x-pack/plugins/index_management/public/application/components/template_form/template_form.tsx
@@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { EuiSpacer, EuiButton, EuiPageHeader } from '@elastic/eui';
import { ScopedHistory } from '@kbn/core/public';
-import { allowAutoCreateRadioIds } from '../../../../common/constants';
+import { allowAutoCreateRadioIds, STANDARD_INDEX_MODE } from '../../../../common/constants';
import { TemplateDeserialized } from '../../../../common';
import { serializers, Forms, GlobalFlyout } from '../../../shared_imports';
import {
@@ -118,6 +118,7 @@ export const TemplateForm = ({
name: '',
indexPatterns: [],
dataStream: {},
+ indexMode: STANDARD_INDEX_MODE,
template: {},
_kbnMeta: {
type: 'default',
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 fc3525d4f77af..2621f3ec483c1 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
@@ -27,10 +27,7 @@ import { getLifecycleValue } from '../../../../../lib/data_streams';
import { TemplateDeserialized } from '../../../../../../../common';
import { ILM_PAGES_POLICY_EDIT } from '../../../../../constants';
import { useIlmLocator } from '../../../../../services/use_ilm_locator';
-import {
- allowAutoCreateRadioIds,
- STANDARD_INDEX_MODE,
-} from '../../../../../../../common/constants';
+import { allowAutoCreateRadioIds } from '../../../../../../../common/constants';
import { indexModeLabels } from '../../../../../lib/index_mode_labels';
interface Props {
@@ -62,7 +59,6 @@ export const TabSummary: React.FunctionComponent = ({ templateDetails })
_meta,
_kbnMeta: { isLegacy, hasDatastream },
allowAutoCreate,
- template,
} = templateDetails;
const numIndexPatterns = indexPatterns.length;
@@ -235,7 +231,7 @@ export const TabSummary: React.FunctionComponent = ({ templateDetails })
/>
- {indexModeLabels[template?.settings?.index?.mode ?? STANDARD_INDEX_MODE]}
+ {indexModeLabels[indexMode]}
{/* Allow auto create */}
diff --git a/x-pack/plugins/index_management/test/fixtures/template.ts b/x-pack/plugins/index_management/test/fixtures/template.ts
index fb6a3a9011b9f..09895b550dc18 100644
--- a/x-pack/plugins/index_management/test/fixtures/template.ts
+++ b/x-pack/plugins/index_management/test/fixtures/template.ts
@@ -68,7 +68,7 @@ export const getTemplate = ({
order = getRandomNumber(),
indexPatterns = [],
template: { settings, aliases, mappings } = {},
- indexMode,
+ indexMode = 'standard',
dataStream,
composedOf,
ignoreMissingComponentTemplates,