Commit 5c0bfc17 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Approve widget with users who approved

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent a2726dc3
......@@ -188,3 +188,7 @@
.merge-request-form .select2-container {
width: 250px !important;
}
.approved-by-users {
padding: 5px 12px;
}
......@@ -419,8 +419,18 @@ class MergeRequest < ActiveRecord::Base
end
def requires_approve?
return false if approvals_required.zero?
!approvals_required.zero?
end
def approved?
approvals.count >= approvals_required
end
def approved_by?(user)
approved_by_users.include?(user)
end
approvals_required > approvals.count
def approved_by_users
approvals.map(&:user)
end
end
.clearfix
- unless @merge_request.approved_by?(current_user)
.pull-left
= form_for [:approve, @project.namespace.becomes(Namespace), @project, @merge_request], method: :post do |f|
= f.submit "Approve Merge Request", class: "btn btn-reopen"
- if @merge_request.approvals.any?
.pull-left.approved-by-users
Approved by
- @merge_request.approved_by_users.each do |user|
= link_to_member(@project, user, name: false, size: 24)
%br
%p This merge request must be approved by #{pluralize(@merge_request.approvals_required, 'user')} before it can be merged
......@@ -17,10 +17,8 @@
- if @show_merge_controls
.automerge_widget.can_be_merged.hide
.clearfix
- if @merge_request.requires_approve?
= form_for [:approve, @project.namespace.becomes(Namespace), @project, @merge_request], method: :post do |f|
%p This merge request must be approved by #{pluralize(@merge_request.approvals_left, 'user')} before it can be merged
= f.submit "Approve Merge Request", class: "btn btn-reopen"
- if @merge_request.requires_approve? && !@merge_request.approved?
= render 'projects/merge_requests/show/approve'
- else
= form_for [:automerge, @project.namespace.becomes(Namespace), @project, @merge_request], remote: true, method: :post do |f|
.accept-merge-holder.clearfix.js-toggle-container
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment