From ac00a94b6627b91de4fc9ff59cbbd5e65148b268 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 8 Oct 2024 21:32:24 +0300 Subject: [PATCH] Fix adding plugins to the toolbar (don't add separator to empty list) --- apps/common/main/lib/controller/Plugins.js | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index d07bd2a9c6..2a86d452b2 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -450,28 +450,29 @@ define([ rank = 1.5; rank_plugins++; } - if (new_rank!==rank && rank>-1 && rank_plugins>0) { - _group.appendTo(me.$toolbarPanelPlugins); - $('
').appendTo(me.$toolbarPanelPlugins); - _group = $('
'); - rank_plugins = 0; - } else { - _group.appendTo(me.$toolbarPanelPlugins); - $('').appendTo(me.$toolbarPanelPlugins); - _group = $('
'); - } var btn = me.viewPlugins.createPluginButton(model); if (btn) { + if (new_rank!==rank && rank>-1 && rank_plugins>0) { + _group.appendTo(me.$toolbarPanelPlugins); + $('
').appendTo(me.$toolbarPanelPlugins); + _group = $('
'); + rank_plugins = 0; + } else if (rank_plugins>0) { + _group.appendTo(me.$toolbarPanelPlugins); + $('').appendTo(me.$toolbarPanelPlugins); + _group = $('
'); + } + var $slot = $('').appendTo(_group); btn.render($slot); rank_plugins++; + rank = new_rank; } if (new_rank === 1 && !isBackground) { _group = me.addBackgroundPluginsButton(_group); isBackground = true; } - rank = new_rank; }); _group.appendTo(me.$toolbarPanelPlugins); if (me.backgroundPlugins.length > 0) { @@ -972,6 +973,9 @@ define([ }); pluginStore.reset(arr); this.appOptions.canPlugins = !pluginStore.isEmpty(); + me.newInstalledBackgroundPlugins = _.filter(me.newInstalledBackgroundPlugins, function(item){ + return !!pluginStore.findWhere({guid: item.guid}); + }) } } else if (!uiCustomize){ @@ -1299,7 +1303,7 @@ define([ onModalClose: function () { var plugins = this.newInstalledBackgroundPlugins; - if (plugins && plugins.length > 0) { + if (plugins && plugins.length > 0 && this.viewPlugins.backgroundBtn && this.viewPlugins.backgroundBtn.isVisible()) { var text = plugins.length > 1 ? this.textPluginsSuccessfullyInstalled : Common.Utils.String.format(this.textPluginSuccessfullyInstalled, plugins[0].name); if (this.backgroundPluginsTip && this.backgroundPluginsTip.isVisible()) {