2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-06 11:39:54 -04:00
|
|
|
module ProfilesHelper
|
2018-11-07 06:00:21 -05:00
|
|
|
def commit_email_select_options(user)
|
|
|
|
private_email = user.private_commit_email
|
|
|
|
verified_emails = user.verified_emails - [private_email]
|
|
|
|
|
|
|
|
[
|
|
|
|
[s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
|
2018-11-14 13:09:33 -05:00
|
|
|
*verified_emails
|
2018-11-07 06:00:21 -05:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def selected_commit_email(user)
|
|
|
|
user.read_attribute(:commit_email) || user.commit_email
|
|
|
|
end
|
|
|
|
|
2017-08-29 04:57:41 -04:00
|
|
|
def attribute_provider_label(attribute)
|
|
|
|
user_synced_attributes_metadata = current_user.user_synced_attributes_metadata
|
|
|
|
if user_synced_attributes_metadata&.synced?(attribute)
|
|
|
|
if user_synced_attributes_metadata.provider
|
2018-02-23 07:10:39 -05:00
|
|
|
Gitlab::Auth::OAuth::Provider.label_for(user_synced_attributes_metadata.provider)
|
2017-08-29 04:57:41 -04:00
|
|
|
else
|
|
|
|
'LDAP'
|
|
|
|
end
|
|
|
|
end
|
2017-06-06 11:39:54 -04:00
|
|
|
end
|
2019-02-06 04:11:39 -05:00
|
|
|
|
|
|
|
def user_profile?
|
|
|
|
params[:controller] == 'users'
|
|
|
|
end
|
2020-09-30 11:09:46 -04:00
|
|
|
|
|
|
|
def ssh_key_delete_modal_data(key, is_admin)
|
|
|
|
{
|
|
|
|
path: path_to_key(key, is_admin),
|
|
|
|
method: 'delete',
|
|
|
|
qa_selector: 'delete_ssh_key_button',
|
|
|
|
modal_attributes: {
|
|
|
|
'data-qa-selector': 'ssh_key_delete_modal',
|
|
|
|
title: _('Are you sure you want to delete this SSH key?'),
|
|
|
|
message: _('This action cannot be undone, and will permanently delete the %{key} SSH key') % { key: key.title },
|
|
|
|
okVariant: 'danger',
|
|
|
|
okTitle: _('Delete')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2017-06-06 11:39:54 -04:00
|
|
|
end
|