2017-03-23 04:43:34 -04:00
|
|
|
module UsersHelper
|
|
|
|
def user_link(user)
|
|
|
|
link_to(user.name, user_path(user),
|
|
|
|
title: user.email,
|
|
|
|
class: 'has-tooltip commit-committer-link')
|
|
|
|
end
|
2017-04-28 11:33:23 -04:00
|
|
|
|
|
|
|
def user_email_help_text(user)
|
|
|
|
return 'We also use email for avatar detection if no avatar is uploaded.' unless user.unconfirmed_email.present?
|
|
|
|
|
|
|
|
confirmation_link = link_to 'Resend confirmation e-mail', user_confirmation_path(user: { email: @user.unconfirmed_email }), method: :post
|
|
|
|
|
|
|
|
h('Please click the link in the confirmation email before continuing. It was sent to ') +
|
|
|
|
content_tag(:strong) { user.unconfirmed_email } + h('.') +
|
|
|
|
content_tag(:p) { confirmation_link }
|
|
|
|
end
|
2017-12-11 09:21:06 -05:00
|
|
|
|
|
|
|
def profile_tabs
|
|
|
|
@profile_tabs ||= get_profile_tabs
|
|
|
|
end
|
|
|
|
|
|
|
|
def profile_tab?(tab)
|
|
|
|
profile_tabs.include?(tab)
|
|
|
|
end
|
|
|
|
|
2018-04-25 10:54:26 -04:00
|
|
|
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
|
|
|
|
|
2017-12-11 09:21:06 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def get_profile_tabs
|
|
|
|
[:activity, :groups, :contributed, :projects, :snippets]
|
|
|
|
end
|
2018-04-25 10:54:26 -04:00
|
|
|
|
|
|
|
def get_current_user_menu_items
|
2018-04-27 08:56:50 -04:00
|
|
|
items = []
|
2018-04-25 10:54:26 -04:00
|
|
|
|
2018-04-27 08:56:50 -04:00
|
|
|
items << :sign_out if current_user
|
|
|
|
|
2018-05-08 09:07:55 -04:00
|
|
|
return items if current_user&.required_terms_not_accepted?
|
2018-04-27 08:56:50 -04:00
|
|
|
|
2018-05-08 09:07:55 -04:00
|
|
|
items << :help
|
|
|
|
items << :profile if can?(current_user, :read_user, current_user)
|
|
|
|
items << :settings if can?(current_user, :update_user, current_user)
|
2018-04-25 10:54:26 -04:00
|
|
|
|
|
|
|
items
|
|
|
|
end
|
2017-03-23 04:43:34 -04:00
|
|
|
end
|