From f6e6e052efdaf095f23423a6084421fdc15f0256 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Mon, 30 Sep 2024 11:33:42 +0200 Subject: [PATCH] feat(xo-web/tasks): ability to delete XO tasks' logs Related to https://team.vates.fr/vates/pl/s7eb6mkpj7bzpqmwh89apu3eio --- CHANGELOG.md | 1 + packages/xo-web/src/common/intl/messages.js | 1 + packages/xo-web/src/common/xo/index.js | 7 +++++++ packages/xo-web/src/xo-app/tasks/index.js | 11 +++++++++++ 4 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d03e5dff1..ad38240ff03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/xo-web/src/common/intl/messages.js b/packages/xo-web/src/common/intl/messages.js index c785e2b6f37..799da66ca21 100644 --- a/packages/xo-web/src/common/intl/messages.js +++ b/packages/xo-web/src/common/intl/messages.js @@ -485,6 +485,7 @@ const messages = { jobSkipped: 'Skipped', jobSuccess: 'Successful', allTasks: 'All', + taskDeleteLog: 'Delete task log', taskStart: 'Start', taskEnd: 'End', taskDuration: 'Duration', diff --git a/packages/xo-web/src/common/xo/index.js b/packages/xo-web/src/common/xo/index.js index a78e5f29b35..459963ee176 100644 --- a/packages/xo-web/src/common/xo/index.js +++ b/packages/xo-web/src/common/xo/index.js @@ -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) diff --git a/packages/xo-web/src/xo-app/tasks/index.js b/packages/xo-web/src/xo-app/tasks/index.js index 7bcab12025b..3f4a256a8a7 100644 --- a/packages/xo-web/src/xo-app/tasks/index.js +++ b/packages/xo-web/src/xo-app/tasks/index.js @@ -25,6 +25,7 @@ import { abortXoTask, cancelTask, cancelTasks, + deleteXoTaskLog, destroyTask, destroyTasks, subscribePermissions, @@ -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), @@ -375,6 +385,7 @@ export default class Tasks extends Component {