diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-25 16:54:26 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-05-04 13:52:55 +0200 |
commit | 17b25bd263edaae70d5dae5fb035f5c28f9bb0cd (patch) | |
tree | 064cf11dafc8f56c40f797e2ccf89af685a7720e /app/helpers | |
parent | 82eeb72c8c03727540b902d40e7e657d0a5ecb4c (diff) | |
download | gitlab-ce-17b25bd263edaae70d5dae5fb035f5c28f9bb0cd.tar.gz |
Make the user dropdown reusable
We will reuse the the dropdown, but exclude some menu items based on
permissions.
So moving the menu to a partial, and adding checks for each menu item here.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/users_helper.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 01af68088df..517268175e6 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -23,9 +23,31 @@ module UsersHelper profile_tabs.include?(tab) end + def current_user_menu_items + @current_user_menu_items ||= get_current_user_menu_items + end + + def current_user_menu?(item) + current_user_menu_items.include?(item) + end + private def get_profile_tabs [:activity, :groups, :contributed, :projects, :snippets] end + + def get_current_user_menu_items + items = [:help, :sign_out] + + if can?(current_user, :read_user, current_user) + items << :profile + end + + if can?(current_user, :update_user, current_user) + items << :settings + end + + items + end end |