diff --git a/models/interfaces.ts b/models/interfaces.ts index 062dd49e8..06e497404 100644 --- a/models/interfaces.ts +++ b/models/interfaces.ts @@ -428,6 +428,13 @@ export interface SnapshotAction extends Action { }; } +export interface ConvertIndexToRemoteAction extends Action { + convert_index_to_remote: { + repository: string; + snapshot: string; + }; +} + export interface IndexPriorityAction extends Action { index_priority: { priority?: number; diff --git a/public/pages/Aliases/containers/Aliases/Aliases.test.tsx b/public/pages/Aliases/containers/Aliases/Aliases.test.tsx index 95f124449..fab423d4f 100644 --- a/public/pages/Aliases/containers/Aliases/Aliases.test.tsx +++ b/public/pages/Aliases/containers/Aliases/Aliases.test.tsx @@ -228,7 +228,7 @@ describe(" spec", () => { userEvent.type(getByPlaceholderText("Specify alias name"), testAliasId); userEvent.click(getByTestId("createAliasButton")); await waitFor(() => { - expect(browserServicesMock.commonService.apiCaller).toBeCalledTimes(17); + expect(browserServicesMock.commonService.apiCaller).toBeCalledTimes(15); expect(browserServicesMock.commonService.apiCaller).toBeCalledWith({ data: { index: ["1"], diff --git a/public/pages/VisualCreatePolicy/components/UIActions/ConvertIndexToRemoteUIAction.tsx b/public/pages/VisualCreatePolicy/components/UIActions/ConvertIndexToRemoteUIAction.tsx new file mode 100644 index 000000000..519a7138d --- /dev/null +++ b/public/pages/VisualCreatePolicy/components/UIActions/ConvertIndexToRemoteUIAction.tsx @@ -0,0 +1,82 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { ChangeEvent } from "react"; +import { EuiCompressedFormRow, EuiCompressedFieldText, EuiSpacer } from "@elastic/eui"; +import { ConvertIndexToRemoteAction, UIAction } from "../../../../../models/interfaces"; +import { makeId } from "../../../../utils/helpers"; +import { ActionType } from "../../utils/constants"; +import EuiFormCustomLabel from "../EuiFormCustomLabel"; + +export default class ConvertIndexToRemoteUIAction implements UIAction { + id: string; + action: ConvertIndexToRemoteAction; + type = ActionType.ConvertIndexToRemote; + + constructor(action: ConvertIndexToRemoteAction, id: string = makeId()) { + this.action = action; + this.id = id; + } + + content = () => `Convert Index To Remote`; + + clone = (action: ConvertIndexToRemoteAction) => new ConvertIndexToRemoteUIAction(action, this.id); + + isValid = () => { + return !!this.action.convert_index_to_remote.snapshot && !!this.action.convert_index_to_remote.repository; + }; + + render = (action: UIAction, onChangeAction: (action: UIAction) => void) => { + return ( + <> + + + ) => { + const repository = e.target.value; + onChangeAction( + this.clone({ + convert_index_to_remote: { + ...action.action.convert_index_to_remote, + repository, + }, + }) + ); + }} + data-test-subj="action-render-convert-index-to-remote-repository" + /> + + + + + ) => { + const snapshot = e.target.value; + onChangeAction( + this.clone({ + convert_index_to_remote: { + ...action.action.convert_index_to_remote, + snapshot, + }, + }) + ); + }} + data-test-subj="action-render-convert-index-to-remote-snapshot" + /> + + + ); + }; + + toAction = () => this.action; +} diff --git a/public/pages/VisualCreatePolicy/components/UIActions/index.ts b/public/pages/VisualCreatePolicy/components/UIActions/index.ts index 53db9ec57..c9095bf6e 100644 --- a/public/pages/VisualCreatePolicy/components/UIActions/index.ts +++ b/public/pages/VisualCreatePolicy/components/UIActions/index.ts @@ -6,6 +6,7 @@ import AliasUIAction from "./AliasUIAction/AliasUIAction"; import AllocationUIAction from "./AllocationUIAction"; import CloseUIAction from "./CloseUIAction"; +import ConvertIndexToRemoteUIAction from "./ConvertIndexToRemoteUIAction"; import DeleteUIAction from "./DeleteUIAction"; import ForceMergeUIAction from "./ForceMergeUIAction"; import IndexPriorityUIAction from "./IndexPriorityUIAction"; @@ -23,6 +24,7 @@ export { AliasUIAction, AllocationUIAction, CloseUIAction, + ConvertIndexToRemoteUIAction, DeleteUIAction, ForceMergeUIAction, IndexPriorityUIAction, diff --git a/public/pages/VisualCreatePolicy/containers/CreateAction/__snapshots__/CreateAction.test.tsx.snap b/public/pages/VisualCreatePolicy/containers/CreateAction/__snapshots__/CreateAction.test.tsx.snap index 5931d370c..37ec3f971 100644 --- a/public/pages/VisualCreatePolicy/containers/CreateAction/__snapshots__/CreateAction.test.tsx.snap +++ b/public/pages/VisualCreatePolicy/containers/CreateAction/__snapshots__/CreateAction.test.tsx.snap @@ -110,6 +110,11 @@ exports[` spec renders the component 1`] = ` > Close +