Dont show remove source branch ckecbox/button if you dont have such
permissions for MR page Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
d25bc25766
commit
affd376f7a
4 changed files with 2 additions and 12 deletions
|
@ -225,7 +225,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
@merge_request_diff = @merge_request.merge_request_diff
|
||||
@allowed_to_merge = allowed_to_merge?
|
||||
@show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge
|
||||
@allowed_to_remove_source_branch = allowed_to_remove_source_branch?
|
||||
@source_branch = @merge_request.source_project.repository.find_branch(@merge_request.source_branch).try(:name)
|
||||
end
|
||||
|
||||
|
@ -238,11 +237,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
render 'invalid'
|
||||
end
|
||||
|
||||
def allowed_to_remove_source_branch?
|
||||
allowed_to_push_code?(@merge_request.source_project, @merge_request.source_branch) &&
|
||||
!@merge_request.disallow_source_branch_removal?
|
||||
end
|
||||
|
||||
def allowed_to_push_code?(project, branch)
|
||||
action = if project.protected_branch?(branch)
|
||||
:push_code_to_protected_branches
|
||||
|
|
|
@ -212,10 +212,6 @@ class MergeRequest < ActiveRecord::Base
|
|||
target_project != source_project
|
||||
end
|
||||
|
||||
def disallow_source_branch_removal?
|
||||
source_project.root_ref?(source_branch) || source_project.protected_branches.include?(source_branch)
|
||||
end
|
||||
|
||||
def project
|
||||
target_project
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
.accept-group
|
||||
.pull-left
|
||||
= f.submit "Accept Merge Request", class: "btn btn-create accept_merge_request"
|
||||
- unless @merge_request.disallow_source_branch_removal?
|
||||
- if can_remove_branch?(@merge_request.source_project, @merge_request.source_branch)
|
||||
.remove_branch_holder.pull-left
|
||||
= label_tag :should_remove_source_branch, class: "checkbox" do
|
||||
= check_box_tag :should_remove_source_branch
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
- if @source_branch.blank?
|
||||
Source branch has been removed
|
||||
|
||||
- elsif @allowed_to_remove_source_branch && @merge_request.merged?
|
||||
- elsif can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) && @merge_request.merged?
|
||||
.remove_source_branch_widget
|
||||
%p Changes merged into #{@merge_request.target_branch}. You can remove source branch now
|
||||
= link_to project_branch_path(@merge_request.source_project, @source_branch), remote: true, method: :delete, class: "btn btn-primary btn-small remove_source_branch" do
|
||||
|
|
Loading…
Reference in a new issue