Commit e569cf369ab9457d078c0f40dbbb7a67db4c6221

Authored by Dmitriy Zaporozhets
2 parents 6fdd9008 4ac56fa1

Merge pull request #6991 from jvanbaarsen/branch-counter-after-delete

Make sure the branch counter gets updated
app/controllers/projects/branches_controller.rb
@@ -24,10 +24,11 @@ class Projects::BranchesController < Projects::ApplicationController @@ -24,10 +24,11 @@ class Projects::BranchesController < Projects::ApplicationController
24 24
25 def destroy 25 def destroy
26 DeleteBranchService.new.execute(project, params[:id], current_user) 26 DeleteBranchService.new.execute(project, params[:id], current_user)
  27 + @branch_name = params[:id]
27 28
28 respond_to do |format| 29 respond_to do |format|
29 format.html { redirect_to project_branches_path(@project) } 30 format.html { redirect_to project_branches_path(@project) }
30 - format.js { render nothing: true } 31 + format.js
31 end 32 end
32 end 33 end
33 end 34 end
app/views/projects/branches/_branch.html.haml
1 - commit = @repository.commit(branch.target) 1 - commit = @repository.commit(branch.target)
2 -%li 2 +%li(class="js-branch-#{branch.name}")
3 %h4 3 %h4
4 = link_to project_tree_path(@project, branch.name) do 4 = link_to project_tree_path(@project, branch.name) do
5 %strong= truncate(branch.name, length: 60) 5 %strong= truncate(branch.name, length: 60)
app/views/projects/branches/destroy.js.haml 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +:plain
  2 + $(".js-branch-#{@branch_name}").remove();
  3 + $('.js-totalbranch-count').html("#{@repository.branches.size}")
app/views/projects/commits/_head.html.haml
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 = nav_link(html_options: {class: branches_tab_class}) do 9 = nav_link(html_options: {class: branches_tab_class}) do
10 = link_to project_branches_path(@project) do 10 = link_to project_branches_path(@project) do
11 Branches 11 Branches
12 - %span.badge= @repository.branches.size 12 + %span.badge.js-totalbranch-count= @repository.branches.size
13 13
14 = nav_link(controller: :tags) do 14 = nav_link(controller: :tags) do
15 = link_to project_tags_path(@project) do 15 = link_to project_tags_path(@project) do