[Kimchi-devel] [PATCH] [Wok] Bug fix #146: Do not display Wok tab for non-admin users
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Oct 11 18:55:05 UTC 2016
The Wok tab is restricted to admin users so do not load it for non-admin
users. It implies in changing the way Wok loads the tabs as all the
children tabs may be hidden for non-admin users and consequently the
pattern tab should not be loaded as well.
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
src/wok/utils.py | 2 +-
ui/js/src/wok.main.js | 31 +++++++++++--------------------
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index 0b74fd8..52f6cea 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -97,7 +97,7 @@ def get_enabled_plugins():
def get_all_tabs():
- files = []
+ files = [os.path.join(paths.ui_dir, 'config/tab-ext.xml')]
for plugin, _ in get_enabled_plugins():
files.append(os.path.join(PluginPaths(plugin).ui_dir,
diff --git a/ui/js/src/wok.main.js b/ui/js/src/wok.main.js
index eb7fd28..3872580 100644
--- a/ui/js/src/wok.main.js
+++ b/ui/js/src/wok.main.js
@@ -33,6 +33,7 @@ wok.main = function() {
wok.popable();
var genTabs = function(tabs) {
+ var functionalTabs = [];
var tabsHtml = [];
$(tabs).each(function(i, tab) {
tab_i18n = i18n[tab] ? i18n[tab] : tab;
@@ -52,9 +53,16 @@ wok.main = function() {
'<input name="helpPath" class="sr-only" value="' + helpPath + '" type="hidden"/>',
'</li>'
);
+
+ if (functionalTabs.indexOf(functionality) == -1) {
+ functionalTabs.push(functionality)
+ }
}
});
- return tabsHtml.join('');
+
+ $('#functionalTabPanel ul').append(genFuncTabs(functionalTabs));
+ $('#tabPanel ul').append(tabsHtml.join(''));
+ return;
};
var genFuncTabs = function(tabs){
@@ -73,7 +81,6 @@ wok.main = function() {
var parseTabs = function(xmlData) {
var tabs = [];
- var functionalTabs = {};
var functionality = $(xmlData).find('functionality').text();
$(xmlData).find('tab').each(function() {
var $tab = $(this);
@@ -124,9 +131,7 @@ wok.main = function() {
var pluginI18nUrl = 'plugins/{plugin}/i18n.json';
var DEFAULT_HASH;
var buildTabs = function(callback) {
- var tabs = [];
- var functionalTabs = [];
- var wokTabs = retrieveTabs(wokConfigUrl);
+ var tabs = retrieveTabs(wokConfigUrl);
wok.listPlugins(function(plugins) {
$(plugins).each(function(i, p) {
var url = wok.substitute(pluginConfigUrl, {
@@ -140,23 +145,10 @@ wok.main = function() {
}, i18nUrl, true);
var pluginTabs = retrieveTabs(url);
if(pluginTabs.length > 0){
- var func = pluginTabs[0].functionality
- if (functionalTabs.indexOf(func) == -1) {
- functionalTabs.push(pluginTabs[0].functionality)
- }
tabs.push.apply(tabs, pluginTabs);
}
});
- //ordering of first level tab
- functionalTabs.sort();
- if(wokTabs.length > 0){
- //Adds wok to first index in list
- functionalTabs.unshift(wokTabs[0].functionality);
- //Adds Wok tabs to the list
- tabs.unshift.apply(tabs, wokTabs);
- }
-
//sort second level tab based on their ordering number
var orderedTabs = tabs.slice(0);
orderedTabs.sort(function(a, b) {
@@ -174,8 +166,7 @@ wok.main = function() {
defaultTabPath.substring(0, defaultTabPath.lastIndexOf('.'))
}
- $('#functionalTabPanel ul').append(genFuncTabs(functionalTabs));
- $('#tabPanel ul').append(genTabs(orderedTabs));
+ genTabs(orderedTabs);
wok.getHostname();
wok.logos('ul#plugins',true);
wok.logos('ul#wok-about',false);
--
2.7.4
More information about the Kimchi-devel
mailing list