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

74 lines
2.1 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
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
2023-03-04 22:38:38 +05:30
def ssh_key_usage_types
{
s_('SSHKey|Authentication & Signing') => 'auth_and_signing',
s_('SSHKey|Authentication') => 'auth',
s_('SSHKey|Signing') => 'signing'
}
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?
end
# Overridden in EE::ProfilesHelper#ssh_key_expires_field_description
def ssh_key_expires_field_description
2022-10-11 01:57:18 +05:30
s_('Profiles|Optional but recommended. If set, key becomes invalid on the specified date.')
2021-04-29 21:17:54 +05:30
end
2022-01-26 12:08:38 +05:30
# Overridden in EE::ProfilesHelper#ssh_key_expiration_policy_enabled?
def ssh_key_expiration_policy_enabled?
false
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