From ec486c1013b9a96a304f9d2eb62fe1e0f1014999 Mon Sep 17 00:00:00 2001 From: Aleksandr Tuliakov Date: Tue, 25 Feb 2025 17:40:27 +0300 Subject: [PATCH 1/2] Add target index settings to rollup Signed-off-by: Aleksandr Tuliakov --- models/interfaces.ts | 2 +- .../JobNameAndIndices/JobNameAndIndices.tsx | 14 +++- .../RollupIndices/RollupIndices.tsx | 69 +++++++++++++++++++ .../containers/CreateRollup/CreateRollup.tsx | 9 ++- .../CreateRollupForm/CreateRollupForm.tsx | 19 ++++- .../CreateRollupStep4/CreateRollupStep4.tsx | 3 +- .../GeneralInformation/GeneralInformation.tsx | 35 +++++++--- .../RollupDetails/RollupDetails.tsx | 13 ++-- 8 files changed, 140 insertions(+), 24 deletions(-) diff --git a/models/interfaces.ts b/models/interfaces.ts index 062dd49e8..73260bb3b 100644 --- a/models/interfaces.ts +++ b/models/interfaces.ts @@ -7,7 +7,6 @@ import { long } from "@opensearch-project/opensearch/api/types"; import { ActionType } from "../public/pages/VisualCreatePolicy/utils/constants"; -import { IndicesUpdateMode } from "../public/utils/constants"; export interface ManagedIndexMetaData { index: string; @@ -490,6 +489,7 @@ export interface Rollup { schema_version: number; source_index: string; target_index: string; + target_index_settings: Map | null; roles: string[]; } diff --git a/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx b/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx index b00024394..d2c2b6637 100644 --- a/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx +++ b/public/pages/CreateRollup/components/JobNameAndIndices/JobNameAndIndices.tsx @@ -5,15 +5,17 @@ import React, { Component } from "react"; import { EuiFlexGrid, EuiSpacer, EuiFlexItem, EuiText, EuiFlexGroup, EuiHorizontalRule, EuiPanel, EuiTitle } from "@elastic/eui"; -import { ContentPanel, ContentPanelActions } from "../../../../components/ContentPanel"; +import { ContentPanelActions } from "../../../../components/ContentPanel"; import { ModalConsumer } from "../../../../components/Modal"; import { IndexItem } from "../../../../../models/interfaces"; +import { getOrderedJson } from "../../../../../utils/helper"; interface JobNameAndIndicesProps { rollupId: string; description: string; sourceIndex: { label: string; value?: IndexItem }[]; targetIndex: { label: string; value?: IndexItem }[]; + targetIndexSettings: Pick | null; onChangeStep: (step: number) => void; } @@ -23,7 +25,7 @@ export default class JobNameAndIndices extends Component } render() { - const { rollupId, description, onChangeStep, sourceIndex, targetIndex } = this.props; + const { rollupId, description, onChangeStep, sourceIndex, targetIndex, targetIndexSettings } = this.props; return ( @@ -72,6 +74,14 @@ export default class JobNameAndIndices extends Component
{targetIndex[0].label}
+ {targetIndexSettings && ( + + +
Target index Settings
+
{JSON.stringify(getOrderedJson(targetIndexSettings || {}), null, 2)}
+
+
+ )}
Description
diff --git a/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx b/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx index 795480c36..085d3ca27 100644 --- a/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx +++ b/public/pages/CreateRollup/components/RollupIndices/RollupIndices.tsx @@ -22,6 +22,9 @@ import { IndexItem } from "../../../../../models/interfaces"; import IndexService from "../../../../services/IndexService"; import { CoreServicesContext } from "../../../../components/core_services"; import { wildcardOption } from "../../../../utils/helpers"; +import AdvancedSettings from "../../../../components/AdvancedSettings"; +import flat from "flat"; +import { INDEX_SETTINGS_URL } from "../../../../utils/constants"; interface RollupIndicesProps { indexService: IndexService; @@ -29,8 +32,11 @@ interface RollupIndicesProps { sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; onChangeSourceIndex: (options: EuiComboBoxOptionOption[]) => void; onChangeTargetIndex: (options: EuiComboBoxOptionOption[]) => void; + onChangeTargetIndexSettings: (settings: Pick | null) => void; hasAggregation: boolean; } @@ -124,8 +130,11 @@ export default class RollupIndices extends Component + + + {"Optional. The target index settings will be apply only if target index will be created during the rollup."} + { + + Learn more + + } +
+ } + > + { + if (Object.keys(val).length === 0) { + onChangeTargetIndexSettings(null); + } else { + onChangeTargetIndexSettings(val); + } + }} + accordionProps={{ + initialIsOpen: false, + id: "accordionForCreateRollupTargetIndexSettings", + buttonContent:

Target index settings

, + }} + editorProps={{ + disabled: false, + width: "100%", + formatValue: flat, + }} + rowProps={{ + fullWidth: true, + label: "Specify advanced index settings", + helpText: ( + <> +

+ Specify a comma-delimited list of settings.{" "} + + View index settings + +

+

+ All the settings will be handled in flat structure.{" "} + + Learn more + +

+ + ), + }} + /> +
); } diff --git a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx index 04b58d5cf..b0c9e907d 100644 --- a/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx +++ b/public/pages/CreateRollup/containers/CreateRollup/CreateRollup.tsx @@ -3,8 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { ChangeEvent, Component, useContext } from "react"; -import { EuiSpacer, EuiTitle, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui"; +import React, { ChangeEvent, Component } from "react"; +import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui"; import { RouteComponentProps } from "react-router-dom"; import { RollupService } from "../../../../services"; import ConfigureRollup from "../../components/ConfigureRollup"; @@ -12,7 +12,7 @@ import RollupIndices from "../../components/RollupIndices"; import CreateRollupSteps from "../../components/CreateRollupSteps"; import IndexService from "../../../../services/IndexService"; import { IndexItem } from "../../../../../models/interfaces"; -import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; +import { DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext"; interface CreateRollupProps extends RouteComponentProps, DataSourceMenuProperties { rollupService: RollupService; @@ -27,10 +27,13 @@ interface CreateRollupProps extends RouteComponentProps, DataSourceMenuPropertie sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; onChangeName: (e: ChangeEvent) => void; onChangeDescription: (value: ChangeEvent) => void; onChangeSourceIndex: (options: EuiComboBoxOptionOption[]) => void; onChangeTargetIndex: (options: EuiComboBoxOptionOption[]) => void; + onChangeTargetIndexSettings: (settings: Pick | null) => void; currentStep: number; hasAggregation: boolean; useNewUX: boolean; diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx index 0d90bf29f..00cfa18fd 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx +++ b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx @@ -5,7 +5,7 @@ import React, { ChangeEvent, Component, useContext } from "react"; import { EuiSmallButton, EuiSmallButtonEmpty, EuiComboBoxOptionOption, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; -import { RouteComponentProps, useHistory } from "react-router-dom"; +import { RouteComponentProps } from "react-router-dom"; import moment from "moment"; import { RollupService } from "../../../../services"; import { BREADCRUMBS, ROUTES } from "../../../../utils/constants"; @@ -24,7 +24,6 @@ import { CoreServicesContext } from "../../../../components/core_services"; import { DataSourceMenuContext, DataSourceMenuProperties, - DataSourceMenuReadOnlyContext, DataSourceMenuReadOnlyProperties, } from "../../../../services/DataSourceMenuContext"; import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; @@ -53,6 +52,8 @@ interface CreateRollupFormState { sourceIndexError: string; targetIndex: { label: string; value?: IndexItem }[]; targetIndexError: string; + targetIndexSettings: Pick | null; + targetIndexSettingsError: string; mappings: any; allMappings: FieldItem[][]; @@ -115,6 +116,8 @@ export class CreateRollupForm extends Component | null): void => { + let newJSON = this.state.rollupJSON; + newJSON.rollup.target_index_settings = settings; + this.setState({ targetIndexSettings: settings, rollupJSON: newJSON }); + }; + onChangeIntervalType = (intervalType: string): void => { this.setState({ intervalType, timeunit: "h" }); }; @@ -573,6 +582,8 @@ export class CreateRollupForm extends Component | null; timestamp: EuiComboBoxOptionOption[]; intervalType: string; diff --git a/public/pages/RollupDetails/components/GeneralInformation/GeneralInformation.tsx b/public/pages/RollupDetails/components/GeneralInformation/GeneralInformation.tsx index a3ea869e6..7909d91f3 100644 --- a/public/pages/RollupDetails/components/GeneralInformation/GeneralInformation.tsx +++ b/public/pages/RollupDetails/components/GeneralInformation/GeneralInformation.tsx @@ -5,7 +5,7 @@ import React, { Component } from "react"; import { EuiFlexGrid, EuiSpacer, EuiFlexItem, EuiText, EuiFlexGroup, EuiHorizontalRule, EuiPanel, EuiTitle } from "@elastic/eui"; -import { ContentPanel, ContentPanelActions } from "../../../../components/ContentPanel"; +import { ContentPanelActions } from "../../../../components/ContentPanel"; import { ModalConsumer } from "../../../../components/Modal"; interface GeneralInformationProps { @@ -13,6 +13,7 @@ interface GeneralInformationProps { description: string; sourceIndex: string; targetIndex: string; + targetIndexSettings: string | null; scheduleText: string; pageSize: number; lastUpdated: string; @@ -26,11 +27,23 @@ export default class GeneralInformation extends Component
- {infoItems.map((item) => ( - - -
{item.term}
-
{item.value}
-
-
- ))} + {infoItems + .filter((v) => v.value != null) + .map((item) => ( + + +
{item.term}
+
{item.value}
+
+
+ ))}
diff --git a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx index 3be1e4f03..0a50de582 100644 --- a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx +++ b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx @@ -29,15 +29,16 @@ import { getErrorMessage } from "../../../../utils/helpers"; import GeneralInformation from "../../components/GeneralInformation/GeneralInformation"; import RollupStatus from "../../components/RollupStatus/RollupStatus"; import AggregationAndMetricsSettings from "../../components/AggregationAndMetricsSettings/AggregationAndMetricsSettings"; -import { parseTimeunit, buildIntervalScheduleText, buildCronScheduleText } from "../../../CreateRollup/utils/helpers"; +import { buildIntervalScheduleText, buildCronScheduleText } from "../../../CreateRollup/utils/helpers"; import { DimensionItem, MetricItem, RollupDimensionItem, RollupMetadata, RollupMetricItem } from "../../../../../models/interfaces"; import { renderTime } from "../../../Rollups/utils/helpers"; import DeleteModal from "../../../Rollups/components/DeleteModal"; import { CoreServicesContext } from "../../../../components/core_services"; import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; -import { TopNavControlButtonData, TopNavControlTextData, TopNavControlIconData } from "../../../../../../../src/plugins/navigation/public"; +import { TopNavControlButtonData, TopNavControlIconData } from "../../../../../../../src/plugins/navigation/public"; import _ from "lodash"; +import { getOrderedJson } from "../../../../../utils/helper"; interface RollupDetailsProps extends RouteComponentProps { rollupService: RollupService; @@ -48,6 +49,7 @@ interface RollupDetailsState { description: string; sourceIndex: string; targetIndex: string; + targetIndexSettings: Map | null; rollupJSON: any; continuousJob: string; continuousDefinition: string; @@ -88,6 +90,7 @@ export class RollupDetails extends Component Date: Tue, 25 Feb 2025 18:35:32 +0300 Subject: [PATCH 2/2] Fix jest tests Signed-off-by: Aleksandr Tuliakov --- .../CreateRollupForm.test.tsx.snap | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/__snapshots__/CreateRollupForm.test.tsx.snap b/public/pages/CreateRollup/containers/CreateRollupForm/__snapshots__/CreateRollupForm.test.tsx.snap index 512f4e071..fd7f254f2 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/__snapshots__/CreateRollupForm.test.tsx.snap +++ b/public/pages/CreateRollup/containers/CreateRollupForm/__snapshots__/CreateRollupForm.test.tsx.snap @@ -519,6 +519,262 @@ exports[` spec renders the component 1`] = ` +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+

+ Specify a comma-delimited list of settings. + + + View index settings + EuiIconMock + + (opens in a new tab or window) + + +

+

+ All the settings will be handled in flat structure. + + + Learn more + EuiIconMock + + (opens in a new tab or window) + + +

+
+ +
+ +
+