Merge "feat: Add Unrescue feature to nova instance actions"
This commit is contained in:
37
src/pages/compute/containers/Instance/actions/Unrescue.jsx
Normal file
37
src/pages/compute/containers/Instance/actions/Unrescue.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { ConfirmAction } from 'src/containers/Action';
|
||||
import globalServerStore from 'src/stores/nova/instance';
|
||||
import { isNotLockedOrAdmin, checkStatus } from 'resources/nova/instance';
|
||||
|
||||
export default class UnRescueInstanceAction extends ConfirmAction {
|
||||
get id() {
|
||||
return 'unrescue';
|
||||
}
|
||||
|
||||
get title() {
|
||||
return t('Unrescue');
|
||||
}
|
||||
|
||||
get buttonText() {
|
||||
return t('Unrescue');
|
||||
}
|
||||
|
||||
get isAsyncAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
allowedCheckFunc = (item) => {
|
||||
if (!item) {
|
||||
return true;
|
||||
}
|
||||
// Allow Unrescue only if instance is rescue and not locked
|
||||
return (
|
||||
isNotLockedOrAdmin(item, this.isAdminPage) &&
|
||||
checkStatus(['rescue'], item)
|
||||
);
|
||||
};
|
||||
|
||||
onSubmit = (item) => {
|
||||
const { id } = item || this.item;
|
||||
return globalServerStore.unrescue({ id });
|
||||
};
|
||||
}
|
@@ -49,6 +49,7 @@ import ConfirmResize from './ConfirmResize';
|
||||
import RevertResize from './RevertResize';
|
||||
import ModifyTags from './ModifyTags';
|
||||
import Rescue from './Rescue';
|
||||
import Unrescue from './Unrescue';
|
||||
|
||||
const statusActions = [
|
||||
StartAction,
|
||||
@@ -64,6 +65,7 @@ const statusActions = [
|
||||
Shelve,
|
||||
Unshelve,
|
||||
Rescue,
|
||||
Unrescue,
|
||||
];
|
||||
|
||||
const resourceActions = [
|
||||
|
@@ -356,6 +356,14 @@ export class ServerStore extends Base {
|
||||
return this.client.action(id, rescue);
|
||||
}
|
||||
|
||||
@action
|
||||
async unrescue({ id }) {
|
||||
const body = {
|
||||
unrescue: null,
|
||||
};
|
||||
return this.operation({ body, id });
|
||||
}
|
||||
|
||||
@action
|
||||
async softReboot({ id }) {
|
||||
const body = {
|
||||
|
Reference in New Issue
Block a user