diff --git a/src/common/intl/messages.js b/src/common/intl/messages.js index fcf23ba71..2bbb4be3a 100644 --- a/src/common/intl/messages.js +++ b/src/common/intl/messages.js @@ -816,6 +816,7 @@ const messages = { tipCreateSnapshotLabel: 'Just click on the snapshot button to create one!', revertSnapshot: 'Revert VM to this snapshot', deleteSnapshot: 'Remove this snapshot', + deleteSnapshots: 'Remove selected snapshots', copySnapshot: 'Create a VM from this snapshot', exportSnapshot: 'Export this snapshot', snapshotDate: 'Creation date', @@ -919,7 +920,8 @@ const messages = { usersStatePanel: 'Users', srStatePanel: 'Storage state', ofUsage: '{usage} (of {total})', - ofCpusUsage: '{nVcpus, number} vCPU{nVcpus, plural, one {} other {s}} (of {nCpus, number} CPU{nCpus, plural, one {} other {s}})', + ofCpusUsage: + '{nVcpus, number} vCPU{nVcpus, plural, one {} other {s}} (of {nCpus, number} CPU{nCpus, plural, one {} other {s}})', noSrs: 'No storage', srName: 'Name', srPool: 'Pool', @@ -1232,6 +1234,9 @@ const messages = { 'Are you sure you want to delete {nVifs, number} VIF{nVifs, plural, one {} other {s}}?', deleteSnapshotModalTitle: 'Delete snapshot', deleteSnapshotModalMessage: 'Are you sure you want to delete this snapshot?', + deleteSnapshotsModalTitle: 'Delete snapshot{nVms, plural, one {} other {s}}', + deleteSnapshotsModalMessage: + 'Are you sure you want to delete {nVms, number} snapshot{nVms, plural, one {} other {s}}?', revertVmModalMessage: 'Are you sure you want to revert this VM to the snapshot state? This operation is irreversible.', revertVmModalSnapshotBefore: 'Snapshot before', diff --git a/src/common/xo/index.js b/src/common/xo/index.js index 14d950ce6..a3e291694 100644 --- a/src/common/xo/index.js +++ b/src/common/xo/index.js @@ -969,6 +969,20 @@ export const deleteSnapshot = vm => noop ) +export const deleteSnapshots = vms => + confirm({ + title: _('deleteSnapshotsModalTitle', { nVms: vms.length }), + body: _('deleteSnapshotsModalMessage', { nVms: vms.length }), + }).then( + () => + Promise.all( + map(vms, vm => + _call('vm.delete', { id: resolveId(vm), delete_disks: true }) + ) + ), + noop + ) + import MigrateVmModalBody from './migrate-vm-modal' // eslint-disable-line import/first export const migrateVm = (vm, host) => confirm({ diff --git a/src/xo-app/vm/tab-snapshots.js b/src/xo-app/vm/tab-snapshots.js index 23ef89a7f..da357fced 100644 --- a/src/xo-app/vm/tab-snapshots.js +++ b/src/xo-app/vm/tab-snapshots.js @@ -13,6 +13,7 @@ import { createGetObjectsOfType } from 'selectors' import { copyVm, deleteSnapshot, + deleteSnapshots, exportVm, editVm, revertSnapshot, @@ -66,6 +67,14 @@ const COLUMNS = [ }, ] +const GROUPED_ACTIONS = [ + { + handler: deleteSnapshots, + icon: 'delete', + label: _('deleteSnapshots'), + }, +] + const INDIVIDUAL_ACTIONS = [ { handler: copyVm, @@ -131,6 +140,7 @@ export default class TabSnapshot extends Component {