mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
WebUI: add method for disabling item in user dropdown menu
AD user can do only several things. One of those which are not allowed is to reset password to itself. Therefore we need to be able to turn of a item in dropdown menu. In our case 'Password reset' item. Function which disable menu item and detach the listener on click from the item specified by its name was added. Part of: https://pagure.io/freeipa/issue/3242 Reviewed-By: Petr Vobornik <pvoborni@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
1dcdcd12f4
commit
2992e3c5d4
@ -68,6 +68,16 @@ define([
|
||||
|
||||
facet_changing: false,
|
||||
|
||||
/**
|
||||
* Listeners for user menu items
|
||||
*/
|
||||
on_profile_listener: null,
|
||||
on_passwd_reset_listener: null,
|
||||
on_logout_listener: null,
|
||||
on_item_select_listener: null,
|
||||
on_configuration_listerer: null,
|
||||
on_about_listener: null,
|
||||
|
||||
/**
|
||||
* Currently displayed facet
|
||||
*
|
||||
@ -109,12 +119,7 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
on(this.app_widget.menu_widget, 'item-select', this.on_menu_click.bind(this));
|
||||
on(this.app_widget, 'profile-click', this.on_profile.bind(this));
|
||||
on(this.app_widget, 'logout-click', this.on_logout.bind(this));
|
||||
on(this.app_widget, 'password-reset-click', this.on_password_reset.bind(this));
|
||||
on(this.app_widget, 'configuration-click', this.on_configuration.bind(this));
|
||||
on(this.app_widget, 'about-click', this.on_about.bind(this));
|
||||
this.register_user_menu_listeners();
|
||||
|
||||
on(this.router, 'facet-show', this.on_facet_show.bind(this));
|
||||
on(this.router, 'facet-change', this.on_facet_change.bind(this));
|
||||
@ -133,6 +138,31 @@ define([
|
||||
IPA.opened_dialogs.start_handling(this);
|
||||
},
|
||||
|
||||
register_user_menu_listeners: function() {
|
||||
this.on_profile_listener = on(this.app_widget, 'profile-click',
|
||||
this.on_profile.bind(this));
|
||||
this.on_passwd_reset_listener = on(this.app_widget,
|
||||
'password-reset-click', this.on_password_reset.bind(this));
|
||||
this.on_logout_listener = on(this.app_widget, 'logout-click',
|
||||
this.on_logout.bind(this));
|
||||
this.on_item_select_listener = on(this.app_widget.menu_widget,
|
||||
'item-select', this.on_menu_click.bind(this));
|
||||
this.on_configuration_listerer = on(this.app_widget,
|
||||
'configuration-click', this.on_configuration.bind(this));
|
||||
this.on_about_listener = on(this.app_widget,
|
||||
'about-click', this.on_about.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Turns off one item in user dropdown menu and remove its listener.
|
||||
* @param {string} name of the user menu item which should be disabled
|
||||
* @param {Object} listener disable this listener
|
||||
*/
|
||||
disable_user_menu_item: function(name, listener) {
|
||||
this.app_widget.disable_user_menu_item(name);
|
||||
listener.remove();
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets:
|
||||
* * metadata
|
||||
|
@ -222,6 +222,10 @@ define(['dojo/_base/declare',
|
||||
}
|
||||
},
|
||||
|
||||
disable_user_menu_item: function(name) {
|
||||
this.user_menu.disable_item(name);
|
||||
},
|
||||
|
||||
on_menu_item_click: function(item) {
|
||||
this.collapse_menu();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user