debian-mirror-gitlab/app/helpers/profiles_helper.rb

67 lines
1.9 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module ProfilesHelper
2018-12-13 13:39:08 +05:30
def commit_email_select_options(user)
private_email = user.private_commit_email
verified_emails = user.verified_emails - [private_email]
[
2021-11-11 11:23:49 +05:30
[s_('Use primary email (%{email})') % { email: user.email }, ''],
2018-12-13 13:39:08 +05:30
[s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
*verified_emails
]
end
2018-03-17 18:26:18 +05:30
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-03-27 19:54:05 +05:30
Gitlab::Auth::OAuth::Provider.label_for(user_synced_attributes_metadata.provider)
2018-03-17 18:26:18 +05:30
else
'LDAP'
end
end
2017-09-10 17:25:29 +05:30
end
2019-03-02 22:35:43 +05:30
def user_profile?
params[:controller] == 'users'
end
2021-01-29 00:20:46 +05:30
def availability_values
Types::AvailabilityEnum.enum
end
def user_status_set_to_busy?(status)
status&.availability == availability_values[:busy]
end
2021-04-29 21:17:54 +05:30
2021-11-11 11:23:49 +05:30
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-29 21:17:54 +05:30
# 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?
s_('Profiles|Key usable beyond expiration date.') if key.expired?
end
# Overridden in EE::ProfilesHelper#ssh_key_expires_field_description
def ssh_key_expires_field_description
s_('Profiles|Key can still be used after expiration.')
end
2017-09-10 17:25:29 +05:30
end
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
ProfilesHelper.prepend_mod