fix(xo-web/home/vm): show error toaster when deleting VMs failed (#6323)
This commit is contained in:
parent
9ccb5f8aa9
commit
11e09e1f87
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||||
|
|
||||||
|
- [Home/VM] Show error when deleting VMs failed (PR [#6323](https://github.com/vatesfr/xen-orchestra/pull/6323))
|
||||||
|
|
||||||
### Packages to release
|
### Packages to release
|
||||||
|
|
||||||
> When modifying a package, add it here with its release type.
|
> When modifying a package, add it here with its release type.
|
||||||
@ -28,5 +30,6 @@
|
|||||||
<!--packages-start-->
|
<!--packages-start-->
|
||||||
|
|
||||||
- @vates/async-each major
|
- @vates/async-each major
|
||||||
|
- xo-web patch
|
||||||
|
|
||||||
<!--packages-end-->
|
<!--packages-end-->
|
||||||
|
@ -1728,8 +1728,9 @@ const messages = {
|
|||||||
blockedStartVmsModalMessage: 'Forbidden operation start for {nVms, number} vm{nVms, plural, one {} other {s}}.',
|
blockedStartVmsModalMessage: 'Forbidden operation start for {nVms, number} vm{nVms, plural, one {} other {s}}.',
|
||||||
startVmsModalMessage: 'Are you sure you want to start {vms, number} VM{vms, plural, one {} other {s}}?',
|
startVmsModalMessage: 'Are you sure you want to start {vms, number} VM{vms, plural, one {} other {s}}?',
|
||||||
failedVmsErrorMessage:
|
failedVmsErrorMessage:
|
||||||
'{nVms, number} vm{nVms, plural, one {} other {s}} are failed. Please see your logs to get more information',
|
'{nVms, number} VM{nVms, plural, one {} other {s}} failed. Please check logs for more information',
|
||||||
failedVmsErrorTitle: 'Start failed',
|
failedVmsErrorTitle: 'Start failed',
|
||||||
|
failedDeleteErrorTitle: 'Delete failed',
|
||||||
stopHostsModalTitle: 'Stop Host{nHosts, plural, one {} other {s}}',
|
stopHostsModalTitle: 'Stop Host{nHosts, plural, one {} other {s}}',
|
||||||
stopHostsModalMessage: 'Are you sure you want to stop {nHosts, number} Host{nHosts, plural, one {} other {s}}?',
|
stopHostsModalMessage: 'Are you sure you want to stop {nHosts, number} Host{nHosts, plural, one {} other {s}}?',
|
||||||
stopVmsModalTitle: 'Stop VM{vms, plural, one {} other {s}}',
|
stopVmsModalTitle: 'Stop VM{vms, plural, one {} other {s}}',
|
||||||
|
@ -1626,15 +1626,32 @@ export const deleteVm = (vm, retryWithForce = true) =>
|
|||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
|
|
||||||
export const deleteVms = vms =>
|
export const deleteVms = async vms => {
|
||||||
confirm({
|
if (vms.length === 1) {
|
||||||
|
return deleteVm(vms[0])
|
||||||
|
}
|
||||||
|
await confirm({
|
||||||
title: _('deleteVmsModalTitle', { vms: vms.length }),
|
title: _('deleteVmsModalTitle', { vms: vms.length }),
|
||||||
body: _('deleteVmsModalMessage', { vms: vms.length }),
|
body: _('deleteVmsModalMessage', { vms: vms.length }),
|
||||||
strongConfirm: vms.length > 1 && {
|
strongConfirm: vms.length > 1 && {
|
||||||
messageId: 'deleteVmsConfirmText',
|
messageId: 'deleteVmsConfirmText',
|
||||||
values: { nVms: vms.length },
|
values: { nVms: vms.length },
|
||||||
},
|
},
|
||||||
}).then(() => Promise.all(map(vms, vmId => _call('vm.delete', { id: resolveId(vmId) }))), noop)
|
}).catch(noop)
|
||||||
|
|
||||||
|
let nErrors = 0
|
||||||
|
await Promise.all(
|
||||||
|
map(vms, vmId =>
|
||||||
|
_call('vm.delete', { id: resolveId(vmId) }).catch(() => {
|
||||||
|
nErrors++
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (nErrors > 0) {
|
||||||
|
error(_('failedDeleteErrorTitle'), _('failedVmsErrorMessage', { nVms: nErrors }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const importBackup = ({ remote, file, sr }) => _call('vm.importBackup', resolveIds({ remote, file, sr }))
|
export const importBackup = ({ remote, file, sr }) => _call('vm.importBackup', resolveIds({ remote, file, sr }))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user