From 152e23a00be69786bf17ab051e6f7fc0402113c1 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 31 Oct 2013 11:26:48 -0700 Subject: [PATCH] UI plugins: Fix side nav behavior Due to usability issues, any UI plugins that add a main section (via the addSection function) will now be shown in the 'Plugins' area by clicking on the relevant tile. This is to prevent overflow of the side nav bar caused by too many plugins being loaded. --- ui/scripts/plugins.js | 3 ++- ui/scripts/ui-custom/pluginListing.js | 8 ++++++++ ui/scripts/ui/core.js | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js index 50da509eaa8..afeae7c7eaf 100644 --- a/ui/scripts/plugins.js +++ b/ui/scripts/plugins.js @@ -51,7 +51,8 @@ }, addSection: function(section) { cloudStack.sections[section.id] = $.extend(section, { - customIcon: 'plugins/' + section.id + '/icon.png' + customIcon: 'plugins/' + section.id + '/icon.png', + isPlugin: true }); }, extend: function(obj) { diff --git a/ui/scripts/ui-custom/pluginListing.js b/ui/scripts/ui-custom/pluginListing.js index 1d4a090ff2b..e679c626526 100644 --- a/ui/scripts/ui-custom/pluginListing.js +++ b/ui/scripts/ui-custom/pluginListing.js @@ -52,6 +52,14 @@ var $browser = $('#browser .container'); $plugin.click(function() { + var $mainSection = $('#navigation ul li').filter('.' + plugin.id); + + if ($mainSection.size()) { + $mainSection.click(); + + return; + } + $browser.cloudBrowser('addPanel', { title: plugin.title, $parent: $('.panel:first'), diff --git a/ui/scripts/ui/core.js b/ui/scripts/ui/core.js index 2ae0b64a5d4..06be12b7b6b 100644 --- a/ui/scripts/ui/core.js +++ b/ui/scripts/ui/core.js @@ -61,6 +61,10 @@ ); } + if (args.isPlugin) { + $li.hide(); + } + $li.appendTo($navList); return true; @@ -84,18 +88,25 @@ return $(this).hasClass(sectionID); }); var data = args.sections[sectionID]; + var isPlugin = data.isPlugin; data.$browser = $browser; - $navItem.siblings().removeClass('active'); - $navItem.addClass('active'); // Reset browser panels - $browser.cloudBrowser('removeAllPanels'); + if (!isPlugin) { + $navItem.siblings().removeClass('active'); + $navItem.addClass('active'); + $browser.cloudBrowser('removeAllPanels'); + } + $browser.cloudBrowser('addPanel', { title: '' + _l(data.title) + '' + '', data: '', complete: function($panel, $breadcrumb) { - $breadcrumb.attr('title', _l(data.title)); + if(!isPlugin) { + $breadcrumb.attr('title', _l(data.title)); + } + data.$breadcrumb = $breadcrumb; // Hide breadcrumb if this is the home section