[Kimchi-devel] [PATCH 2/4] Authorization: remove host/template tabs for non-root users

Aline Manera alinefm at linux.vnet.ibm.com
Fri Jul 18 17:40:37 UTC 2014


On 07/18/2014 08:18 AM, wenwang at linux.vnet.ibm.com wrote:
> From: Wen Wang <wenwang at linux.vnet.ibm.com>
>
> This patch removed host/template tabs from non-root users
>
> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.main.js |   21 +++++++++++++--------
>   1 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
> index 8eb4d73..54a0043 100644
> --- a/ui/js/src/kimchi.main.js
> +++ b/ui/js/src/kimchi.main.js
> @@ -23,13 +23,16 @@ kimchi.main = function() {
>           $(tabs).each(function(i, tab) {
>               var title = tab['title'];
>               var path = tab['path'];
> -            tabsHtml.push(
> -                '<li>',
> -                    '<a class="item" href="', path, '">',
> -                        title,
> -                    '</a>',
> -                '</li>'
> -            );
> +            var mode = tab['mode'];
> +            if (mode != 'none') {
> +                tabsHtml.push(
> +                    '<li>',
> +                        '<a class="item" href="', path, '">',
> +                            title,
> +                        '</a>',
> +                    '</li>'
> +                );
> +            }
>           });
>           return tabsHtml.join('');
>       };
> @@ -41,9 +44,11 @@ kimchi.main = function() {
>               var titleKey = $tab.find('title').text();
>               var title = i18n[titleKey] ? i18n[titleKey] : titleKey;
>               var path = $tab.find('path').text();

> +            var mode = kimchi.cookie.get(titleKey + 'Mode');

While loading the tabs.xml and tab-ext.xml you need to get the mode 
attribute according to role access element
For example:

var role = kimchi.cookie.get(titlekey + 'Role')

var mode = $tab.find(["role='" + role + "']').attrib("mode")


>               tabs.push({
>                   title: title,
> -                path: path
> +                path: path,
> +                mode: mode
>               });
>           });
>




More information about the Kimchi-devel mailing list