Skip to content

Commit

Permalink
feat(xo-web/tasks): ability to delete XO tasks' logs
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-f committed Sep 30, 2024
1 parent 748ed07 commit f6e6e05
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Backup] Detect invalid VDI exports that are incorrectly reported as successful by XAPI
- [Backup] Backup job sequences: configure lists of backup jobs to run in order one after the other (PRs [#7985](https://github.com/vatesfr/xen-orchestra/pull/7985), [#8014](https://github.com/vatesfr/xen-orchestra/pull/8014))
- [Pool/Network] Display the bond mode of a network [#7802](https://github.com/vatesfr/xen-orchestra/issues/7802) (PR [#8010](https://github.com/vatesfr/xen-orchestra/pull/8010))
- [Tasks] Ability to delete XO task logs

### Bug fixes

Expand Down
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ const messages = {
jobSkipped: 'Skipped',
jobSuccess: 'Successful',
allTasks: 'All',
taskDeleteLog: 'Delete task log',
taskStart: 'Start',
taskEnd: 'End',
taskDuration: 'Duration',
Expand Down
7 changes: 7 additions & 0 deletions packages/xo-web/src/common/xo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,13 @@ export const abortXoTask = async task => {
}
}

export const deleteXoTaskLog = async task => {
const response = await fetch(`./rest/v0/tasks/${task.id}`, { method: 'DELETE' })
if (!response.ok) {
throw new Error(await response.text())
}
}

// Jobs -------------------------------------------------------------

export const createJob = job => _call('job.create', { job })::tap(subscribeJobs.forceRefresh)
Expand Down
11 changes: 11 additions & 0 deletions packages/xo-web/src/xo-app/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
abortXoTask,
cancelTask,
cancelTasks,
deleteXoTaskLog,
destroyTask,
destroyTasks,
subscribePermissions,
Expand Down Expand Up @@ -240,6 +241,15 @@ const INDIVIDUAL_ACTIONS = [
},
]

const XO_TASKS_ACTIONS = [
{
handler: tasks => Promise.all(tasks.map(deleteXoTaskLog)),
icon: 'task-destroy',
label: _('taskDeleteLog'),
level: 'warning',
},
]

const XO_TASKS_INDIVIDUAL_ACTIONS = [
{
handler: task => window.open(task.href),
Expand Down Expand Up @@ -375,6 +385,7 @@ export default class Tasks extends Component {
<Row>
<Col>
<SortedTable
actions={XO_TASKS_ACTIONS}
collection={props.xoTasks}
columns={XO_TASKS_COLUMNS}
individualActions={XO_TASKS_INDIVIDUAL_ACTIONS}
Expand Down

0 comments on commit f6e6e05

Please sign in to comment.