Commit d0e794cc1a7eba4d438841d6a661bc41687e624e
1 parent
3e1853c5
Exists in
spb-stable
and in
2 other branches
Make sure the branch counter gets updated
When you delete a branch, the counters wont get updated automaticly, this happends because of the JS nature of the original call. I've fixed this by responding with a JS file, and recalculate the counters. Fixes: #6030
Showing
4 changed files
with
9 additions
and
3 deletions
Show diff stats
app/controllers/projects/branches_controller.rb
| ... | ... | @@ -23,11 +23,12 @@ class Projects::BranchesController < Projects::ApplicationController |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | def destroy |
| 26 | + @branch = @repository.find_branch(params[:id]) | |
| 26 | 27 | DeleteBranchService.new.execute(project, params[:id], current_user) |
| 27 | 28 | |
| 28 | 29 | respond_to do |format| |
| 29 | 30 | format.html { redirect_to project_branches_path(@project) } |
| 30 | - format.js { render nothing: true } | |
| 31 | + format.js | |
| 31 | 32 | end |
| 32 | 33 | end |
| 33 | 34 | end | ... | ... |
app/views/projects/branches/_branch.html.haml
| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | +:plain | |
| 2 | + $(".js-branch-#{@branch.name}").remove(); | |
| 3 | + $('.js-recentbranch-count').html("#{@repository.recent_branches.count}") | |
| 4 | + $('.js-protectedbranch-count').html("#{@project.protected_branches.count}") | |
| 5 | + $('.js-totalbranch-count').html("#{@repository.branch_names.count}") | ... | ... |
app/views/projects/commits/_head.html.haml
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | = nav_link(html_options: {class: branches_tab_class}) do |
| 10 | 10 | = link_to project_branches_path(@project) do |
| 11 | 11 | Branches |
| 12 | - %span.badge= @repository.branches.size | |
| 12 | + %span.badge.js-totalbranch-count= @repository.branches.size | |
| 13 | 13 | |
| 14 | 14 | = nav_link(controller: :tags) do |
| 15 | 15 | = link_to project_tags_path(@project) do | ... | ... |