From 96165dfadcffe6dc07b70e1774557197f9326426 Mon Sep 17 00:00:00 2001 From: Xuesong Luo Date: Mon, 9 Jan 2023 10:00:38 +0800 Subject: [PATCH] Minor wording change after review Signed-off-by: Xuesong Luo --- public/pages/Indices/utils/helpers.ts | 11 ++--- .../SplitIndexForm/SplitIndexForm.tsx | 5 +-- .../container/SplitIndex/SplitIndex.tsx | 38 +++++++++------- .../__snapshots__/SplitIndex.test.tsx.snap | 45 ++++++++++--------- 4 files changed, 55 insertions(+), 44 deletions(-) diff --git a/public/pages/Indices/utils/helpers.ts b/public/pages/Indices/utils/helpers.ts index 4021ca50f..b387a000e 100644 --- a/public/pages/Indices/utils/helpers.ts +++ b/public/pages/Indices/utils/helpers.ts @@ -132,8 +132,8 @@ export async function getAlias(props: { aliasName?: string; commonService: Commo } export async function splitIndex(props: { - sourceIndex: String; - targetIndex: String; + sourceIndex: string; + targetIndex: string; settingsPayload: Required["settings"]; commonService: CommonService; coreServices: CoreStart; @@ -188,17 +188,18 @@ export async function splitIndex(props: { ** For example, if the source index has 3 primary shards, then all the valid value are 3,6,12,24,…,768. */ export function getSplitShardOptions(sourceShards: number) { + const MAX_SHARDS_NUMBER = 1024; const shardsSelectOptions = []; if (sourceShards == 1) { - for (let i = 2; i <= 1024; i++) { + for (let i = 2; i <= MAX_SHARDS_NUMBER; i++) { shardsSelectOptions.push({ label: i.toString(), }); } } else { - const SHARDS_HARD_LIMIT = 1024 / 2; + const SHARDS_HARD_LIMIT = MAX_SHARDS_NUMBER / 2; let shardsLimit = sourceShards; - for (let i = 1; shardsLimit <= SHARDS_HARD_LIMIT; i++) { + while (shardsLimit <= SHARDS_HARD_LIMIT) { shardsLimit = shardsLimit * 2; shardsSelectOptions.push({ label: shardsLimit.toString(), diff --git a/public/pages/SplitIndex/components/SplitIndexForm/SplitIndexForm.tsx b/public/pages/SplitIndex/components/SplitIndexForm/SplitIndexForm.tsx index 0caf5cb5b..0fb7c21a9 100644 --- a/public/pages/SplitIndex/components/SplitIndexForm/SplitIndexForm.tsx +++ b/public/pages/SplitIndex/components/SplitIndexForm/SplitIndexForm.tsx @@ -4,11 +4,10 @@ */ import React, { Component } from "react"; import { EuiSpacer, EuiLink, EuiFlexItem, EuiFlexGroup, EuiButton, EuiButtonEmpty } from "@elastic/eui"; -import FormGenerator, { IField, IFormGeneratorRef } from "../../../../components/FormGenerator"; +import FormGenerator, { IField, IFormGeneratorRef, IFieldComponentProps } from "../../../../components/FormGenerator"; import { IndexItem } from "../../../../../models/interfaces"; import IndexDetail from "../../../../containers/IndexDetail"; import ContentPanel from "../../../../components/ContentPanel/ContentPanel"; -import { IFieldComponentProps } from "../../../../components/FormGenerator"; import AliasSelect, { AliasSelectProps } from "../../../CreateIndex/components/AliasSelect"; import EuiToolTipWrapper from "../../../../components/EuiToolTipWrapper"; import { INDEX_NAMING_PATTERN, INDEX_NAMING_MESSAGE, INDEX_SETTINGS_URL, REPLICA_NUMBER_MESSAGE } from "../../../../utils/constants"; @@ -193,7 +192,7 @@ export default class SplitIndexForm extends Component label: "Specify advanced index settings", helpText: ( <> - Specify a comma-delimited list of settings. + Specify a comma-delimited list of settings.  View index settings diff --git a/public/pages/SplitIndex/container/SplitIndex/SplitIndex.tsx b/public/pages/SplitIndex/container/SplitIndex/SplitIndex.tsx index e59995511..26c89dc98 100644 --- a/public/pages/SplitIndex/container/SplitIndex/SplitIndex.tsx +++ b/public/pages/SplitIndex/container/SplitIndex/SplitIndex.tsx @@ -2,8 +2,8 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ -import React, { Component } from "react"; -import { EuiCallOut, EuiSpacer, EuiTitle, EuiButton, EuiLink, EuiText } from "@elastic/eui"; +import React, { Component, useContext } from "react"; +import { EuiCallOut, EuiSpacer, EuiTitle, EuiButton, EuiLink, EuiFormRow } from "@elastic/eui"; import { get } from "lodash"; import { CatIndex } from "../../../../../server/models/interfaces"; @@ -24,7 +24,6 @@ import { import { CommonService, ServicesContext } from "../../../../services"; import { CoreStart } from "opensearch-dashboards/public"; -import { useContext } from "react"; import { CoreServicesContext } from "../../../../components/core_services"; import { BREADCRUMBS, ROUTES } from "../../../../utils/constants"; @@ -57,10 +56,10 @@ export class SplitIndex extends Component { isSourceIndexReady = async () => { const source = queryString.parse(this.props.location.search) as { source: string }; - let sourceIndex; + let sourceIndex: CatIndex; try { sourceIndex = await getSingleIndice({ - indexName: source.source as string, + indexName: source.source, commonService: this.props.commonService, coreServices: this.props.coreService, }); @@ -134,7 +133,7 @@ export class SplitIndex extends Component { ); } - if (sourceSettings && (!blocksWriteValue || (blocksWriteValue !== "true" && blocksWriteValue !== true))) { + if (sourceSettings && blocksWriteValue !== "true" && blocksWriteValue !== true) { const flat = true; const blocksWriteSetting = { "index.blocks.write": "true" }; reasons.push( @@ -200,18 +199,27 @@ export class SplitIndex extends Component { const { sourceIndex, splitIndexFlyoutVisible, reasons, shardsSelectOptions } = this.state; return (
- +

Split index

- -

- Split an existing read-only index into a new index with more primary shards .    - - Learn more. - -

-
+ + Split an existing read-only index into a new index with more primary shards.  + + Learn more. + +
+ } + > + <> + diff --git a/public/pages/SplitIndex/container/SplitIndex/__snapshots__/SplitIndex.test.tsx.snap b/public/pages/SplitIndex/container/SplitIndex/__snapshots__/SplitIndex.test.tsx.snap index bbffc907b..3cb959820 100644 --- a/public/pages/SplitIndex/container/SplitIndex/__snapshots__/SplitIndex.test.tsx.snap +++ b/public/pages/SplitIndex/container/SplitIndex/__snapshots__/SplitIndex.test.tsx.snap @@ -7,36 +7,39 @@ HTMLCollection [ style="padding: 0px 50px;" >

Split index

-

- Split an existing read-only index into a new index with more primary shards .    - - Learn more. - EuiIconMock - + Split an existing read-only index into a new index with more primary shards.  + - (opens in a new tab or window) - - -

+ Learn more. + EuiIconMock + + (opens in a new tab or window) + + +
+