From 696f4dc7535ff3c0f93acd29e407deb96e9af64c Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 9 Aug 2022 12:53:27 +0000 Subject: [PATCH] [IMP] web_editor: prevent crash with wrongly defined commands The Powerbox crashed whenever a command was wrongly defined. That's a bit too brutal so this sets defaults instead. closes odoo/odoo#97794 Signed-off-by: David Monjoie (dmo) --- .../js/editor/odoo-editor/src/powerbox/Powerbox.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js index ff6af2443fa..1c9ea2ca532 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js @@ -89,6 +89,18 @@ export class Powerbox { * @param {Array<{name: string, priority: number}} [categories=this.categories] */ open(commands=this.commands, categories=this.categories) { + commands = (commands || []).map(command => ({ + ...command, + category: command.category || '', + name: command.name || '', + priority: command.priority || 0, + description: command.description || '', + callback: command.callback || (() => {}), + })); + categories = (categories || []).map(category => ({ + name: category.name || '', + priority: category.priority || 0, + })); const order = (a, b) => b.priority - a.priority || a.name.localeCompare(b.name); if (this.onOpen) { this.onOpen();