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] 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)
|
- [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)
|
- 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
|
### Bugs
|
||||||
|
|
||||||
|
@ -595,6 +595,7 @@ const TRANSFORMS = {
|
|||||||
|
|
||||||
task (obj) {
|
task (obj) {
|
||||||
return {
|
return {
|
||||||
|
allowedOperations: obj.allowed_operations,
|
||||||
created: toTimestamp(obj.created),
|
created: toTimestamp(obj.created),
|
||||||
current_operations: obj.current_operations,
|
current_operations: obj.current_operations,
|
||||||
finished: toTimestamp(obj.finished),
|
finished: toTimestamp(obj.finished),
|
||||||
|
@ -10,7 +10,7 @@ import { SelectPool } from 'select-objects'
|
|||||||
import { connectStore, resolveIds } from 'utils'
|
import { connectStore, resolveIds } from 'utils'
|
||||||
import { Card, CardBlock, CardHeader } from 'card'
|
import { Card, CardBlock, CardHeader } from 'card'
|
||||||
import { Col, Container, Row } from 'grid'
|
import { Col, Container, Row } from 'grid'
|
||||||
import { flatMap, flatten, isEmpty, keys, toArray } from 'lodash'
|
import { flatMap, flatten, isEmpty, keys, some, toArray } from 'lodash'
|
||||||
import {
|
import {
|
||||||
createGetObject,
|
createGetObject,
|
||||||
createGetObjectsOfType,
|
createGetObjectsOfType,
|
||||||
@ -94,14 +94,19 @@ const COLUMNS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const isNotCancelable = task => !task.allowedOperations.includes('cancel')
|
||||||
|
const isNotDestroyable = task => !task.allowedOperations.includes('destroy')
|
||||||
|
|
||||||
const INDIVIDUAL_ACTIONS = [
|
const INDIVIDUAL_ACTIONS = [
|
||||||
{
|
{
|
||||||
|
disabled: isNotCancelable,
|
||||||
handler: cancelTask,
|
handler: cancelTask,
|
||||||
icon: 'task-cancel',
|
icon: 'task-cancel',
|
||||||
label: _('cancelTask'),
|
label: _('cancelTask'),
|
||||||
level: 'danger',
|
level: 'danger',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
disabled: isNotDestroyable,
|
||||||
handler: destroyTask,
|
handler: destroyTask,
|
||||||
icon: 'task-destroy',
|
icon: 'task-destroy',
|
||||||
label: _('destroyTask'),
|
label: _('destroyTask'),
|
||||||
@ -111,12 +116,14 @@ const INDIVIDUAL_ACTIONS = [
|
|||||||
|
|
||||||
const GROUPED_ACTIONS = [
|
const GROUPED_ACTIONS = [
|
||||||
{
|
{
|
||||||
|
disabled: tasks => some(tasks, isNotCancelable),
|
||||||
handler: cancelTasks,
|
handler: cancelTasks,
|
||||||
icon: 'task-cancel',
|
icon: 'task-cancel',
|
||||||
label: _('cancelTasks'),
|
label: _('cancelTasks'),
|
||||||
level: 'danger',
|
level: 'danger',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
disabled: tasks => some(tasks, isNotDestroyable),
|
||||||
handler: destroyTasks,
|
handler: destroyTasks,
|
||||||
icon: 'task-destroy',
|
icon: 'task-destroy',
|
||||||
label: _('destroyTasks'),
|
label: _('destroyTasks'),
|
||||||
|
Loading…
Reference in New Issue
Block a user