Skip to content

Commit 1a3ea28

Browse files
committed
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.
1 parent 977123b commit 1a3ea28

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
(function (cloudStack) {
22
cloudStack.plugins.testPlugin = function(plugin) {
3-
//
4-
// Plugin code goes here
5-
//
3+
plugin.ui.addSection({
4+
id: 'testPlugin',
5+
title: 'TestPlugin',
6+
preFilter: function(args) {
7+
return isAdmin();
8+
},
9+
show: function() {
10+
return $('<div>').html('Test plugin section');
11+
}
12+
});
613
};
714
}(cloudStack));

ui/scripts/plugins.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
(function($, cloudStack, require) {
2+
var pluginAPI = {
3+
addSection: function(section) {
4+
cloudStack.sections[section.id] = section;
5+
},
6+
extend: function(obj) {
7+
$.extend(true, cloudStack, obj);
8+
}
9+
};
10+
211
cloudStack.sections.plugins = {
312
title: 'Plugins',
413
show: cloudStack.uiCustom.plugins
@@ -15,11 +24,7 @@
1524

1625
// Execute plugin
1726
cloudStack.plugins[pluginID]({
18-
ui: {
19-
extend: function(obj) {
20-
$.extend(true, cloudStack, obj);
21-
}
22-
}
27+
ui: pluginAPI
2328
});
2429
});
2530
});

0 commit comments

Comments
 (0)