From 6470606d654cfe2cd213257441007d5ab86aa294 Mon Sep 17 00:00:00 2001 From: "Francois (fge)" Date: Thu, 28 Oct 2021 13:17:56 +0000 Subject: [PATCH] [FIX] web: Command Menu with custom icon Before this commit, if you create a new app with a custom icon with studio and you open the command palette with the namespace "/", then you will have an error message. We have this error because the home_menu does not support custom menu icons. closes odoo/odoo#79158 X-original-commit: c5f5b1de07ee6b8b09ae1821c4c0debc0d09f55e Signed-off-by: Aaron Bohy (aab) --- .../src/core/commands/command_palette.scss | 11 +++++++++++ .../src/core/commands/command_palette.xml | 5 ++++- .../src/webclient/menus/menu_providers.js | 17 ++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/core/commands/command_palette.scss b/addons/web/static/src/core/commands/command_palette.scss index 3225f4015a7..93c5d5df4dd 100644 --- a/addons/web/static/src/core/commands/command_palette.scss +++ b/addons/web/static/src/core/commands/command_palette.scss @@ -90,8 +90,19 @@ } .o_app_icon { + position: relative; border-radius: 4%; height: 1.8em; + width: 1.8em; + + &> i.fa { + text-align: center; + position: absolute; + top: 25%; + left: 0; + bottom: auto; + right: 0; + } } } } diff --git a/addons/web/static/src/core/commands/command_palette.xml b/addons/web/static/src/core/commands/command_palette.xml index 2fba31da594..e79c5654735 100644 --- a/addons/web/static/src/core/commands/command_palette.xml +++ b/addons/web/static/src/core/commands/command_palette.xml @@ -56,7 +56,10 @@
- + +
+ +
diff --git a/addons/web/static/src/webclient/menus/menu_providers.js b/addons/web/static/src/webclient/menus/menu_providers.js index d43f7c45882..3a4e3789f1e 100644 --- a/addons/web/static/src/webclient/menus/menu_providers.js +++ b/addons/web/static/src/webclient/menus/menu_providers.js @@ -41,10 +41,15 @@ commandProviderRegistry.add("menu", { } apps.forEach((menu) => { - const prefix = "data:image/png;base64,"; - const webIconData = menu.webIconData.startsWith(prefix) - ? menu.webIconData - : prefix + menu.webIconData.replace(/\s/g, ""); + const props = {}; + if (menu.webIconData) { + const prefix = "data:image/png;base64,"; + props.webIconData = menu.webIconData.startsWith(prefix) + ? menu.webIconData + : prefix + menu.webIconData.replace(/\s/g, ""); + } else { + props.webIcon = menu.webIcon; + } result.push({ Component: AppIconCommand, action() { @@ -52,9 +57,7 @@ commandProviderRegistry.add("menu", { }, category: "apps", name: menu.label, - props: { - webIconData: webIconData, - }, + props, }); });