-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds UI actions for all the supported ISM actions (#49)
* Adds UI actions for all the supported ISM actions Signed-off-by: Drew Baugher <[email protected]> * Moves ActionType to constants Signed-off-by: Drew Baugher <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,210 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
public/pages/VisualCreatePolicy/components/UIActions/AllocationUIAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import React from "react"; | ||
import { AllocationAction, UIAction } from "../../../../../models/interfaces"; | ||
import { makeId } from "../../../../utils/helpers"; | ||
import { ActionType } from "../../utils/constants"; | ||
|
||
export default class AllocationUIAction implements UIAction<AllocationAction> { | ||
id: string; | ||
action: AllocationAction; | ||
type = ActionType.Allocation; | ||
|
||
constructor(action: AllocationAction, id: string = makeId()) { | ||
this.action = action; | ||
this.id = id; | ||
} | ||
|
||
content = () => `Allocation`; | ||
|
||
clone = (action: AllocationAction = this.action) => new AllocationUIAction(action, this.id); | ||
|
||
render = (action: UIAction<AllocationAction>, onChangeAction: (action: UIAction<AllocationAction>) => void) => { | ||
return <div />; | ||
}; | ||
|
||
toAction = () => this.action; | ||
} |
36 changes: 36 additions & 0 deletions
36
public/pages/VisualCreatePolicy/components/UIActions/CloseUIAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import React from "react"; | ||
import { CloseAction, UIAction } from "../../../../../models/interfaces"; | ||
import { makeId } from "../../../../utils/helpers"; | ||
import { ActionType } from "../../utils/constants"; | ||
|
||
export default class CloseUIAction implements UIAction<CloseAction> { | ||
id: string; | ||
action: CloseAction; | ||
type = ActionType.Close; | ||
|
||
constructor(action: CloseAction, id: string = makeId()) { | ||
this.action = action; | ||
this.id = id; | ||
} | ||
|
||
content = () => `Close`; | ||
|
||
clone = (action: CloseAction) => new CloseUIAction(action, this.id); | ||
|
||
render = (action: UIAction<CloseAction>, onChangeAction: (action: UIAction<CloseAction>) => void) => { | ||
return <div />; | ||
}; | ||
|
||
toAction = () => this.action; | ||
} |
36 changes: 36 additions & 0 deletions
36
public/pages/VisualCreatePolicy/components/UIActions/DeleteUIAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import React from "react"; | ||
import { DeleteAction, UIAction } from "../../../../../models/interfaces"; | ||
import { makeId } from "../../../../utils/helpers"; | ||
import { ActionType } from "../../utils/constants"; | ||
|
||
export default class DeleteUIAction implements UIAction<DeleteAction> { | ||
id: string; | ||
action: DeleteAction; | ||
type = ActionType.Delete; | ||
|
||
constructor(action: DeleteAction, id: string = makeId()) { | ||
this.action = action; | ||
this.id = id; | ||
} | ||
|
||
content = () => `Delete`; | ||
|
||
clone = (action: DeleteAction) => new DeleteUIAction(action, this.id); | ||
|
||
render = (action: UIAction<DeleteAction>, onChangeAction: (action: UIAction<DeleteAction>) => void) => { | ||
return <div />; | ||
}; | ||
|
||
toAction = () => this.action; | ||
} |
59 changes: 59 additions & 0 deletions
59
public/pages/VisualCreatePolicy/components/UIActions/ForceMergeUIAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import React, { ChangeEvent } from "react"; | ||
import { EuiFormRow, EuiFieldNumber } from "@elastic/eui"; | ||
import EuiFormCustomLabel from "../EuiFormCustomLabel"; | ||
import { ForceMergeAction, UIAction } from "../../../../../models/interfaces"; | ||
import { makeId } from "../../../../utils/helpers"; | ||
import { ActionType } from "../../utils/constants"; | ||
|
||
export default class ForceMergeUIAction implements UIAction<ForceMergeAction> { | ||
id: string; | ||
action: ForceMergeAction; | ||
type = ActionType.ForceMerge; | ||
|
||
constructor(action: ForceMergeAction, id: string = makeId()) { | ||
this.action = action; | ||
this.id = id; | ||
} | ||
|
||
content = () => `Force merge to ${this.action.force_merge.max_num_segments} segments`; | ||
|
||
clone = (action: ForceMergeAction) => new ForceMergeUIAction(action, this.id); | ||
|
||
render = (action: UIAction<ForceMergeAction>, onChangeAction: (action: UIAction<ForceMergeAction>) => void) => { | ||
return ( | ||
<> | ||
<EuiFormCustomLabel title="Max num segments" helpText="The number of segments to merge to." /> | ||
<EuiFormRow isInvalid={false} error={null}> | ||
<EuiFieldNumber | ||
value={(action.action as ForceMergeAction).force_merge.max_num_segments} | ||
style={{ textTransform: "capitalize" }} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => { | ||
const maxNumSegments = e.target.valueAsNumber; | ||
onChangeAction( | ||
this.clone({ | ||
force_merge: { | ||
max_num_segments: maxNumSegments, | ||
}, | ||
}) | ||
); | ||
}} | ||
data-test-subj="action-render-force-merge" | ||
/> | ||
</EuiFormRow> | ||
</> | ||
); | ||
}; | ||
|
||
toAction = () => this.action; | ||
} |
57 changes: 57 additions & 0 deletions
57
public/pages/VisualCreatePolicy/components/UIActions/IndexPriorityUIAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import React, { ChangeEvent } from "react"; | ||
import { EuiFormRow, EuiFieldNumber } from "@elastic/eui"; | ||
import EuiFormCustomLabel from "../EuiFormCustomLabel"; | ||
import { IndexPriorityAction, UIAction } from "../../../../../models/interfaces"; | ||
import { makeId } from "../../../../utils/helpers"; | ||
import { ActionType } from "../../utils/constants"; | ||
|
||
export default class IndexPriorityUIAction implements UIAction<IndexPriorityAction> { | ||
id: string; | ||
action: IndexPriorityAction; | ||
type = ActionType.IndexPriority; | ||
|
||
constructor(action: IndexPriorityAction, id: string = makeId()) { | ||
this.action = action; | ||
this.id = id; | ||
} | ||
|
||
content = () => `Set index priority to ${this.action.index_priority.priority}`; | ||
|
||
clone = (action: IndexPriorityAction) => new IndexPriorityUIAction(action, this.id); | ||
|
||
render = (action: UIAction<IndexPriorityAction>, onChangeAction: (action: UIAction<IndexPriorityAction>) => void) => { | ||
return ( | ||
<> | ||
<EuiFormCustomLabel title="Priority" helpText="Higher priority indices are recovered first when possible." /> | ||
<EuiFormRow isInvalid={false} error={null}> | ||
<EuiFieldNumber | ||
value={(action.action as IndexPriorityAction).index_priority.priority} | ||
style={{ textTransform: "capitalize" }} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => { | ||
const priority = e.target.valueAsNumber; | ||
onChangeAction( | ||
this.clone({ | ||
index_priority: { priority }, | ||
}) | ||
); | ||
}} | ||
data-test-subj="action-render-index-priority" | ||
/> | ||
</EuiFormRow> | ||
</> | ||
); | ||
}; | ||
|
||
toAction = () => this.action; | ||
} |
Oops, something went wrong.