Commit d0e794cc authored by Jeroen van Baarsen's avatar Jeroen van Baarsen

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
parent 3e1853c5
...@@ -23,11 +23,12 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -23,11 +23,12 @@ class Projects::BranchesController < Projects::ApplicationController
end end
def destroy def destroy
@branch = @repository.find_branch(params[:id])
DeleteBranchService.new.execute(project, params[:id], current_user) DeleteBranchService.new.execute(project, params[:id], current_user)
respond_to do |format| respond_to do |format|
format.html { redirect_to project_branches_path(@project) } format.html { redirect_to project_branches_path(@project) }
format.js { render nothing: true } format.js
end end
end end
end end
- commit = @repository.commit(branch.target) - commit = @repository.commit(branch.target)
%li %li(class="js-branch-#{branch.name}")
%h4 %h4
= link_to project_tree_path(@project, branch.name) do = link_to project_tree_path(@project, branch.name) do
%strong= truncate(branch.name, length: 60) %strong= truncate(branch.name, length: 60)
......
:plain
$(".js-branch-#{@branch.name}").remove();
$('.js-recentbranch-count').html("#{@repository.recent_branches.count}")
$('.js-protectedbranch-count').html("#{@project.protected_branches.count}")
$('.js-totalbranch-count').html("#{@repository.branch_names.count}")
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
= nav_link(html_options: {class: branches_tab_class}) do = nav_link(html_options: {class: branches_tab_class}) do
= link_to project_branches_path(@project) do = link_to project_branches_path(@project) do
Branches Branches
%span.badge= @repository.branches.size %span.badge.js-totalbranch-count= @repository.branches.size
= nav_link(controller: :tags) do = nav_link(controller: :tags) do
= link_to project_tags_path(@project) do = link_to project_tags_path(@project) do
......
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