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.
This commit is contained in:
Brian Federle 2012-12-20 13:27:37 -08:00
parent 977123be36
commit 1a3ea28243
2 changed files with 20 additions and 8 deletions

View File

@ -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 $('<div>').html('Test plugin section');
}
});
};
}(cloudStack));

View File

@ -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
});
});
});