Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export interface DeleteAction extends Action {
delete: {};
}

export interface StopReplicationAction extends Action {
stop_replication: {};
}

export interface RolloverAction extends Action {
rollover: {
min_size?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from "react";
import { StopReplicationAction, UIAction } from "../../../../../models/interfaces";
import { makeId } from "../../../../utils/helpers";
import { ActionType } from "../../utils/constants";

export class StopReplicationUIAction implements UIAction<StopReplicationAction> {
id: string;
action: StopReplicationAction;
type = ActionType.StopReplication;

constructor(action: StopReplicationAction, id: string = makeId()) {
this.action = action;
this.id = id;
}

content = () => `Stop replication`;

clone = (action: StopReplicationAction) => new StopReplicationUIAction(action, this.id);

isValid = () => true;

render = (action: UIAction<StopReplicationAction>, onChangeAction: (action: UIAction<StopReplicationAction>) => void) => {
return <div />;
};

toAction = () => this.action;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import RolloverUIAction from "./RolloverUIAction";
import RollupUIAction from "./RollupUIAction";
import ShrinkUIAction from "./ShrinkUIAction";
import SnapshotUIAction from "./SnapshotUIAction";
import { StopReplicationUIAction } from "./StopReplicationUIAction";

export {
AliasUIAction,
Expand All @@ -35,4 +36,5 @@ export {
RollupUIAction,
ShrinkUIAction,
SnapshotUIAction,
StopReplicationUIAction,
};
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ exports[`<CreateAction /> spec renders the component 1`] = `
>
Snapshot
</option>
<option
value="stop_replication"
>
Stop Replication
</option>
</select>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
Expand Down
7 changes: 6 additions & 1 deletion public/pages/VisualCreatePolicy/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { AliasAction, AllocationAction } from "../../../../models/interfaces";
import { AliasAction, AllocationAction, StopReplicationAction } from "../../../../models/interfaces";

export enum ActionType {
Alias = "alias",
Expand All @@ -21,6 +21,7 @@ export enum ActionType {
Rollup = "rollup",
Shrink = "shrink",
Snapshot = "snapshot",
StopReplication = "stop_replication",
}

export const DEFAULT_POLICY = {
Expand Down Expand Up @@ -194,6 +195,9 @@ export const DEFAULT_SNAPSHOT = {
snapshot: "example-snapshot",
},
};
export const DEFAULT_STOP_REPLICATION: StopReplicationAction = {
stop_replication: {},
};

export const actions = [
DEFAULT_ALIAS,
Expand All @@ -211,6 +215,7 @@ export const actions = [
DEFAULT_ROLLUP,
DEFAULT_SHRINK,
DEFAULT_SNAPSHOT,
DEFAULT_STOP_REPLICATION,
];

export const ISM_TEMPLATE_INPUT_MAX_WIDTH = "400px";
4 changes: 2 additions & 2 deletions public/pages/VisualCreatePolicy/utils/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class DummyUIAction implements UIAction<DummyAction> {
}

test("action repository usage", () => {
expect(actionRepoSingleton.getAllActionTypes().length).toBe(15);
actionRepoSingleton.registerAction("dummy", DummyUIAction, DEFAULT_DUMMY);
expect(actionRepoSingleton.getAllActionTypes().length).toBe(16);
actionRepoSingleton.registerAction("dummy", DummyUIAction, DEFAULT_DUMMY);
expect(actionRepoSingleton.getAllActionTypes().length).toBe(17);
expect(actionRepoSingleton.getUIAction("dummy") instanceof DummyUIAction).toBe(true);
expect(actionRepoSingleton.getUIActionFromData(DEFAULT_DUMMY) instanceof DummyUIAction).toBe(true);
});
Expand Down
5 changes: 5 additions & 0 deletions public/pages/VisualCreatePolicy/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DEFAULT_ROLLUP,
DEFAULT_SHRINK,
DEFAULT_SNAPSHOT,
DEFAULT_STOP_REPLICATION,
} from "./constants";
import {
AliasUIAction,
Expand All @@ -38,6 +39,7 @@ import {
RollupUIAction,
ShrinkUIAction,
SnapshotUIAction,
StopReplicationUIAction,
} from "../components/UIActions";

export const getConditionContent = (transition: Transition): string => {
Expand Down Expand Up @@ -99,6 +101,8 @@ export const getUIAction = (actionType: string): UIAction<any> => {
return new ShrinkUIAction(DEFAULT_SHRINK);
case ActionType.Snapshot:
return new SnapshotUIAction(DEFAULT_SNAPSHOT);
case ActionType.StopReplication:
return new StopReplicationUIAction(DEFAULT_STOP_REPLICATION);
default:
throw new Error(`Action type [${actionType}] not supported`);
}
Expand Down Expand Up @@ -139,6 +143,7 @@ class ActionRepository {
rollup: [RollupUIAction, DEFAULT_ROLLUP],
shrink: [ShrinkUIAction, DEFAULT_SHRINK],
snapshot: [SnapshotUIAction, DEFAULT_SNAPSHOT],
stop_replication: [StopReplicationUIAction, DEFAULT_STOP_REPLICATION],
};

getAllActionTypes = () => {
Expand Down