2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-12-03 22:09:49 -05:00
|
|
|
class MergeRequestUserEntity < ::API::Entities::UserBasic
|
2021-01-28 13:09:27 -05:00
|
|
|
include UserStatusTooltip
|
2021-02-02 07:10:15 -05:00
|
|
|
include RequestAwareEntity
|
2021-01-28 13:09:27 -05:00
|
|
|
|
2020-12-03 22:09:49 -05:00
|
|
|
expose :can_merge do |reviewer, options|
|
|
|
|
options[:merge_request]&.can_be_merged_by?(reviewer)
|
2018-06-21 08:22:40 -04:00
|
|
|
end
|
2021-02-02 07:10:15 -05:00
|
|
|
|
|
|
|
expose :can_update_merge_request do |reviewer, options|
|
|
|
|
request.current_user&.can?(:update_merge_request, options[:merge_request])
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :reviewed, if: -> (_, options) { options[:merge_request] && options[:merge_request].allows_reviewers? } do |reviewer, options|
|
|
|
|
reviewer = options[:merge_request].find_reviewer(reviewer)
|
|
|
|
|
|
|
|
reviewer&.reviewed?
|
|
|
|
end
|
2018-06-21 08:22:40 -04:00
|
|
|
end
|
2020-12-03 22:09:49 -05:00
|
|
|
|
|
|
|
MergeRequestUserEntity.prepend_if_ee('EE::MergeRequestUserEntity')
|