2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-06 15:39:54 +00:00
|
|
|
module ProfilesHelper
|
2018-11-07 11:00:21 +00:00
|
|
|
def commit_email_select_options(user)
|
|
|
|
private_email = user.private_commit_email
|
|
|
|
verified_emails = user.verified_emails - [private_email]
|
|
|
|
|
|
|
|
[
|
2021-08-30 03:09:16 +00:00
|
|
|
[s_('Use primary email (%{email})') % { email: user.email }, ''],
|
2018-11-07 11:00:21 +00:00
|
|
|
[s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
|
2018-11-14 18:09:33 +00:00
|
|
|
*verified_emails
|
2018-11-07 11:00:21 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2017-08-29 08:57:41 +00: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 12:10:39 +00:00
|
|
|
Gitlab::Auth::OAuth::Provider.label_for(user_synced_attributes_metadata.provider)
|
2017-08-29 08:57:41 +00:00
|
|
|
else
|
|
|
|
'LDAP'
|
|
|
|
end
|
|
|
|
end
|
2017-06-06 15:39:54 +00:00
|
|
|
end
|
2019-02-06 09:11:39 +00:00
|
|
|
|
|
|
|
def user_profile?
|
|
|
|
params[:controller] == 'users'
|
|
|
|
end
|
2020-11-17 15:09:28 +00:00
|
|
|
|
|
|
|
def availability_values
|
|
|
|
Types::AvailabilityEnum.enum
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_status_set_to_busy?(status)
|
|
|
|
status&.availability == availability_values[:busy]
|
|
|
|
end
|
2021-04-12 12:09:15 +00:00
|
|
|
|
2021-08-26 00:09:31 +00:00
|
|
|
def middle_dot_divider_classes(stacking, breakpoint)
|
|
|
|
['gl-mb-3'].tap do |classes|
|
|
|
|
if stacking
|
|
|
|
classes.concat(%w(middle-dot-divider-sm gl-display-block gl-sm-display-inline-block))
|
|
|
|
else
|
|
|
|
classes << 'gl-display-inline-block'
|
|
|
|
classes << if breakpoint.nil?
|
|
|
|
'middle-dot-divider'
|
|
|
|
else
|
|
|
|
"middle-dot-divider-#{breakpoint}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-12 12:09:15 +00:00
|
|
|
# Overridden in EE::ProfilesHelper#ssh_key_expiration_tooltip
|
|
|
|
def ssh_key_expiration_tooltip(key)
|
|
|
|
return key.errors.full_messages.join(', ') if key.errors.full_messages.any?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Overridden in EE::ProfilesHelper#ssh_key_expires_field_description
|
|
|
|
def ssh_key_expires_field_description
|
2022-05-11 18:07:55 +00:00
|
|
|
s_('Profiles|Key becomes invalid on this date.')
|
2021-04-12 12:09:15 +00:00
|
|
|
end
|
2021-12-06 09:10:26 +00:00
|
|
|
|
|
|
|
# Overridden in EE::ProfilesHelper#ssh_key_expiration_policy_enabled?
|
|
|
|
def ssh_key_expiration_policy_enabled?
|
|
|
|
false
|
|
|
|
end
|
2017-06-06 15:39:54 +00:00
|
|
|
end
|
2021-04-12 12:09:15 +00:00
|
|
|
|
2021-05-11 21:10:21 +00:00
|
|
|
ProfilesHelper.prepend_mod
|