feat(home): bulk suspend VMs (#2551)

Fixes #2547
This commit is contained in:
Olivier Lambert
2018-01-02 17:16:11 +01:00
committed by Julien Fontanet
parent 102e629e16
commit e253657770
3 changed files with 19 additions and 0 deletions

View File

@@ -1166,6 +1166,9 @@ const messages = {
restartVmModalMessage: 'Are you sure you want to restart {name}?',
stopVmModalTitle: 'Stop VM',
stopVmModalMessage: 'Are you sure you want to stop {name}?',
suspendVmsModalTitle: 'Suspend VM{vms, plural, one {} other {s}}',
suspendVmsModalMessage:
'Are you sure you want to suspend {vms, number} VM{vms, plural, one {} other {s}}?',
restartVmsModalTitle: 'Restart VM{vms, plural, one {} other {s}}',
restartVmsModalMessage:
'Are you sure you want to restart {vms, number} VM{vms, plural, one {} other {s}}?',

View File

@@ -841,6 +841,16 @@ export const stopVms = (vms, force = false) =>
export const suspendVm = vm => _call('vm.suspend', { id: resolveId(vm) })
export const suspendVms = vms =>
confirm({
title: _('suspendVmsModalTitle', { nVms: vms.length }),
body: _('suspendVmsModalMessage', { nVms: vms.length }),
}).then(
() =>
Promise.all(map(vms, vm => _call('vm.suspend', { id: resolveId(vm) }))),
noop
)
export const resumeVm = vm => _call('vm.resume', { id: resolveId(vm) })
export const recoveryStartVm = vm =>

View File

@@ -54,6 +54,7 @@ import {
stopVms,
subscribeResourceSets,
subscribeServers,
suspendVms,
} from 'xo'
import { Container, Row, Col } from 'grid'
import {
@@ -137,6 +138,11 @@ const OPTIONS = {
{ handler: copyVms, icon: 'vm-copy', tooltip: _('copyVmLabel') },
],
otherActions: [
{
handler: suspendVms,
icon: 'vm-suspend',
labelId: 'suspendVmLabel',
},
{
handler: restartVms,
icon: 'vm-force-reboot',