feat(VM/Snapshots): add grouped deletion to the SortedTable (#2597)

Fixes #2595
This commit is contained in:
badrAZ 2018-01-29 17:15:11 +01:00 committed by Pierre Donias
parent ed3ecc6f4e
commit 5ecc31b977
3 changed files with 30 additions and 1 deletions

View File

@ -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',

View File

@ -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({

View File

@ -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 {
<SortedTable
collection={snapshots}
columns={COLUMNS}
groupedActions={GROUPED_ACTIONS}
individualActions={INDIVIDUAL_ACTIONS}
/>
</Col>