From 1a3ea282437d17d2ecd7b3b5feb4dac30adc290b Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 20 Dec 2012 13:27:37 -0800 Subject: [PATCH] UI plugins API: addSection method Adds 'addSection' method to UI plugins, which will add a new top-level section. It follows the same syntax used by the existing sections in the UI. --- ui/plugins/testPlugin/testPlugin.js | 13 ++++++++++--- ui/scripts/plugins.js | 15 ++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/plugins/testPlugin/testPlugin.js b/ui/plugins/testPlugin/testPlugin.js index 453992442c2..abb4813b092 100644 --- a/ui/plugins/testPlugin/testPlugin.js +++ b/ui/plugins/testPlugin/testPlugin.js @@ -1,7 +1,14 @@ (function (cloudStack) { cloudStack.plugins.testPlugin = function(plugin) { - // - // Plugin code goes here - // + plugin.ui.addSection({ + id: 'testPlugin', + title: 'TestPlugin', + preFilter: function(args) { + return isAdmin(); + }, + show: function() { + return $('
').html('Test plugin section'); + } + }); }; }(cloudStack)); \ No newline at end of file diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js index 250d507d9e1..5cc3185db07 100644 --- a/ui/scripts/plugins.js +++ b/ui/scripts/plugins.js @@ -1,4 +1,13 @@ (function($, cloudStack, require) { + var pluginAPI = { + addSection: function(section) { + cloudStack.sections[section.id] = section; + }, + extend: function(obj) { + $.extend(true, cloudStack, obj); + } + }; + cloudStack.sections.plugins = { title: 'Plugins', show: cloudStack.uiCustom.plugins @@ -15,11 +24,7 @@ // Execute plugin cloudStack.plugins[pluginID]({ - ui: { - extend: function(obj) { - $.extend(true, cloudStack, obj); - } - } + ui: pluginAPI }); }); });