
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> The 'WoK User Activity Log' tab isn't available when running as regular (non-root) user. But, at the same time, it is acting as the default URL when opening WoK. This patch redirects the default URL when logged as a regular user as follows: - if no plug-ins are installed, a warning message is displayed. - if at least one plug-in is installed, the default URL is redirected to the first plug-in. Considering the existing WoK plug-ins at the time this patch was created, it will be redirected to Gingerbase Dashboard. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- ui/js/src/wok.main.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ui/js/src/wok.main.js b/ui/js/src/wok.main.js index 4b36400..260951c 100644 --- a/ui/js/src/wok.main.js +++ b/ui/js/src/wok.main.js @@ -209,9 +209,30 @@ wok.main = function() { * and clear location.hash to jump to home page. */ var tab = $('#tabPanel a[href="' + url + '"]'); - if (tab.length === 0 && url != 'wok-empty.html') { - location.hash = '#'; - return; + if (tab.length === 0) { + if (url === "tabs/settings.html") { + /* + * This scenario means that the WoK tab isn't avaiable for the + * current user (probably because it's a regular non-sudo user). + * If there are other tabs to fall back to, redirect to them. Otherwise, + * if running WoK without plug-ins, put an informative message. + */ + if ($('#tabPanel a').length === 0) { + var warning_msg = "Unable to access WoK User Activity Log feature as a non-root user.<br>No plugins installed currently. You can download the available plugins <a href='https://github.com/kimchi-project/kimchi'>Kimchi</a> and <a href='https://github.com/kimchi-project/ginger'>Ginger</a> from Github." + $('#main').html(warning_msg).addClass('noPluginMessage'); + } else { + location.hash = '#' + $('#tabPanel a').attr('href'); + var lastIndex = location.hash.lastIndexOf(".html"); + if (lastIndex != -1) { + location.hash = location.hash.substring(0, lastIndex); + } + } + return; + } + if (url != 'wok-empty.html') { + location.hash = '#'; + return; + } } //Remove the tab arrow indicator for no plugin if (url == 'wok-empty.html') { -- 2.7.4