Commit affd376f7a36df4a80369bc1c7c8557dd4822b7d
1 parent
d25bc257
Exists in
spb-stable
and in
2 other branches
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>
Showing
4 changed files
with
2 additions
and
12 deletions
Show diff stats
app/controllers/projects/merge_requests_controller.rb
... | ... | @@ -225,7 +225,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController |
225 | 225 | @merge_request_diff = @merge_request.merge_request_diff |
226 | 226 | @allowed_to_merge = allowed_to_merge? |
227 | 227 | @show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge |
228 | - @allowed_to_remove_source_branch = allowed_to_remove_source_branch? | |
229 | 228 | @source_branch = @merge_request.source_project.repository.find_branch(@merge_request.source_branch).try(:name) |
230 | 229 | end |
231 | 230 | |
... | ... | @@ -238,11 +237,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController |
238 | 237 | render 'invalid' |
239 | 238 | end |
240 | 239 | |
241 | - def allowed_to_remove_source_branch? | |
242 | - allowed_to_push_code?(@merge_request.source_project, @merge_request.source_branch) && | |
243 | - !@merge_request.disallow_source_branch_removal? | |
244 | - end | |
245 | - | |
246 | 240 | def allowed_to_push_code?(project, branch) |
247 | 241 | action = if project.protected_branch?(branch) |
248 | 242 | :push_code_to_protected_branches | ... | ... |
app/models/merge_request.rb
... | ... | @@ -212,10 +212,6 @@ class MergeRequest < ActiveRecord::Base |
212 | 212 | target_project != source_project |
213 | 213 | end |
214 | 214 | |
215 | - def disallow_source_branch_removal? | |
216 | - source_project.root_ref?(source_branch) || source_project.protected_branches.include?(source_branch) | |
217 | - end | |
218 | - | |
219 | 215 | def project |
220 | 216 | target_project |
221 | 217 | end | ... | ... |
app/views/projects/merge_requests/show/_mr_accept.html.haml
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | .accept-group |
39 | 39 | .pull-left |
40 | 40 | = f.submit "Accept Merge Request", class: "btn btn-create accept_merge_request" |
41 | - - unless @merge_request.disallow_source_branch_removal? | |
41 | + - if can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) | |
42 | 42 | .remove_branch_holder.pull-left |
43 | 43 | = label_tag :should_remove_source_branch, class: "checkbox" do |
44 | 44 | = check_box_tag :should_remove_source_branch | ... | ... |
app/views/projects/merge_requests/show/_remove_source_branch.html.haml
1 | 1 | - if @source_branch.blank? |
2 | 2 | Source branch has been removed |
3 | 3 | |
4 | -- elsif @allowed_to_remove_source_branch && @merge_request.merged? | |
4 | +- elsif can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) && @merge_request.merged? | |
5 | 5 | .remove_source_branch_widget |
6 | 6 | %p Changes merged into #{@merge_request.target_branch}. You can remove source branch now |
7 | 7 | = 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 | ... | ... |