Skip to content
Snippets Groups Projects
Commit 88c741dd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Refactor recent branches page

parent bb5e50e0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,6 +11,10 @@ class Projects::BranchesController < Projects::ApplicationController
@branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30)
end
 
def recent
@branches = @repository.recent_branches
end
def create
@repository.add_branch(params[:branch_name], params[:ref])
 
Loading
Loading
Loading
Loading
@@ -4,10 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController
before_filter :authorize_code_access!
before_filter :require_non_empty_project
 
def show
@activities = @repository.commits_with_refs(20)
end
def stats
@stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref)
@graph = @stats.graph
Loading
Loading
Loading
Loading
@@ -49,6 +49,12 @@ class Repository
tags.find { |tag| tag.name == name }
end
 
def recent_branches(limit = 20)
branches.sort do |a, b|
a.commit.committed_date <=> b.commit.committed_date
end[0..limit]
end
def add_branch(branch_name, ref)
Rails.cache.delete(cache_key(:branch_names))
 
Loading
Loading
%ul.nav.nav-pills.nav-stacked
= nav_link(path: 'repositories#show') do
= link_to 'Recent', project_repository_path(@project)
= nav_link(path: 'branches#recent') do
= link_to 'Recent', recent_project_branches_path(@project)
= nav_link(path: 'protected_branches#index') do
= link_to project_protected_branches_path(@project) do
Protected
Loading
Loading
= render "projects/commits/head"
.row
.span3
= render "projects/repositories/filter"
= render "filter"
.span9
- unless @branches.empty?
%ul.bordered-list
Loading
Loading
Loading
Loading
@@ -4,6 +4,5 @@
= render "filter"
.span9
%ul.bordered-list
- @activities.each do |update|
= render "projects/branches/branch", branch: update.head
- @branches.each do |branch|
= render "projects/branches/branch", branch: branch
Loading
Loading
@@ -7,7 +7,7 @@
= link_to 'Compare', project_compare_index_path(@project)
 
= nav_link(html_options: {class: branches_tab_class}) do
= link_to project_repository_path(@project) do
= link_to recent_project_branches_path(@project) do
Branches
%span.badge= @repository.branches.length
 
Loading
Loading
= render "projects/commits/head"
.row
.span3
= render "projects/repositories/filter"
= render "projects/branches/filter"
.span9
.alert.alert-info
%p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}.
Loading
Loading
Loading
Loading
@@ -225,8 +225,13 @@ Gitlab::Application.routes.draw do
end
end
 
resources :branches, only: [:index, :new, :create, :destroy] do
collection do
get :recent
end
end
resources :tags, only: [:index, :new, :create, :destroy]
resources :branches, only: [:index, :new, :create, :destroy]
resources :protected_branches, only: [:index, :create, :destroy]
 
resources :refs, only: [] do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment