2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserPresenter < Gitlab::View::Presenter::Delegated
|
2021-11-18 22:05:49 +05:30
|
|
|
presents ::User, as: :user
|
2020-12-08 15:28:05 +05:30
|
|
|
|
|
|
|
def group_memberships
|
|
|
|
should_be_private? ? GroupMember.none : user.group_members
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_memberships
|
|
|
|
should_be_private? ? ProjectMember.none : user.project_members
|
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
def preferences_gitpod_path
|
|
|
|
profile_preferences_path(anchor: 'user_gitpod_enabled') if application_gitpod_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def profile_enable_gitpod_path
|
|
|
|
profile_path(user: { gitpod_enabled: true }) if application_gitpod_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
delegator_override :saved_replies
|
|
|
|
def saved_replies
|
2022-07-16 23:28:13 +05:30
|
|
|
return ::Users::SavedReply.none unless Feature.enabled?(:saved_replies, current_user)
|
2022-05-07 20:08:51 +05:30
|
|
|
return ::Users::SavedReply.none unless current_user.can?(:read_saved_replies, user)
|
|
|
|
|
|
|
|
user.saved_replies
|
|
|
|
end
|
|
|
|
|
2020-12-08 15:28:05 +05:30
|
|
|
private
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
def can?(...)
|
|
|
|
user.can?(...)
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
2020-12-08 15:28:05 +05:30
|
|
|
def should_be_private?
|
2021-04-29 21:17:54 +05:30
|
|
|
!Ability.allowed?(current_user, :read_user_profile, user)
|
2020-12-08 15:28:05 +05:30
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
def application_gitpod_enabled?
|
|
|
|
Gitlab::CurrentSettings.gitpod_enabled
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|