提交 d0e794cc 编写于 作者: J 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
上级 3e1853c5
......@@ -23,11 +23,12 @@ class Projects::BranchesController < Projects::ApplicationController
end
def destroy
@branch = @repository.find_branch(params[:id])
DeleteBranchService.new.execute(project, params[:id], current_user)
respond_to do |format|
format.html { redirect_to project_branches_path(@project) }
format.js { render nothing: true }
format.js
end
end
end
- commit = @repository.commit(branch.target)
%li
%li(class="js-branch-#{branch.name}")
%h4
= link_to project_tree_path(@project, branch.name) do
%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 @@
= nav_link(html_options: {class: branches_tab_class}) do
= link_to project_branches_path(@project) do
Branches
%span.badge= @repository.branches.size
%span.badge.js-totalbranch-count= @repository.branches.size
= nav_link(controller: :tags) do
= link_to project_tags_path(@project) do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册