feat(xo-server,xo-web/tasks): disable cancel/destroy when not relevant (#3109)
* feat(xo-server,xo-web/tasks): disable cancel/destroy when not relevant Fixes #3076 * cancellable/destroyable → allowedOperations * Update index.js * Update index.js
This commit is contained in:
parent
dc8a7c46e0
commit
ec9957bd86
@ -16,6 +16,7 @@
|
||||
- [Backup NG] Ability to cancel a running backup job [#3047](https://github.com/vatesfr/xen-orchestra/issues/3047)
|
||||
- [Backup NG form] Ability to enable/disable a schedule [#3062](https://github.com/vatesfr/xen-orchestra/issues/3062)
|
||||
- New backup/health view with non-existent backup snapshots table [#3090](https://github.com/vatesfr/xen-orchestra/issues/3090)
|
||||
- Disable cancel/destroy tasks when not allowed [#3076](https://github.com/vatesfr/xen-orchestra/issues/3076)
|
||||
|
||||
### Bugs
|
||||
|
||||
|
@ -595,6 +595,7 @@ const TRANSFORMS = {
|
||||
|
||||
task (obj) {
|
||||
return {
|
||||
allowedOperations: obj.allowed_operations,
|
||||
created: toTimestamp(obj.created),
|
||||
current_operations: obj.current_operations,
|
||||
finished: toTimestamp(obj.finished),
|
||||
|
@ -10,7 +10,7 @@ import { SelectPool } from 'select-objects'
|
||||
import { connectStore, resolveIds } from 'utils'
|
||||
import { Card, CardBlock, CardHeader } from 'card'
|
||||
import { Col, Container, Row } from 'grid'
|
||||
import { flatMap, flatten, isEmpty, keys, toArray } from 'lodash'
|
||||
import { flatMap, flatten, isEmpty, keys, some, toArray } from 'lodash'
|
||||
import {
|
||||
createGetObject,
|
||||
createGetObjectsOfType,
|
||||
@ -94,14 +94,19 @@ const COLUMNS = [
|
||||
},
|
||||
]
|
||||
|
||||
const isNotCancelable = task => !task.allowedOperations.includes('cancel')
|
||||
const isNotDestroyable = task => !task.allowedOperations.includes('destroy')
|
||||
|
||||
const INDIVIDUAL_ACTIONS = [
|
||||
{
|
||||
disabled: isNotCancelable,
|
||||
handler: cancelTask,
|
||||
icon: 'task-cancel',
|
||||
label: _('cancelTask'),
|
||||
level: 'danger',
|
||||
},
|
||||
{
|
||||
disabled: isNotDestroyable,
|
||||
handler: destroyTask,
|
||||
icon: 'task-destroy',
|
||||
label: _('destroyTask'),
|
||||
@ -111,12 +116,14 @@ const INDIVIDUAL_ACTIONS = [
|
||||
|
||||
const GROUPED_ACTIONS = [
|
||||
{
|
||||
disabled: tasks => some(tasks, isNotCancelable),
|
||||
handler: cancelTasks,
|
||||
icon: 'task-cancel',
|
||||
label: _('cancelTasks'),
|
||||
level: 'danger',
|
||||
},
|
||||
{
|
||||
disabled: tasks => some(tasks, isNotDestroyable),
|
||||
handler: destroyTasks,
|
||||
icon: 'task-destroy',
|
||||
label: _('destroyTasks'),
|
||||
|
Loading…
Reference in New Issue
Block a user