Commit f17ddeb394ced4322f9b29eada92d5086bdef03b
1 parent
552b3105
Exists in
master
and in
4 other branches
Make admin project list more useful
Showing
6 changed files
with
30 additions
and
8 deletions
Show diff stats
app/assets/stylesheets/gitlab_bootstrap/typography.scss
app/controllers/admin/projects_controller.rb
@@ -3,8 +3,9 @@ class Admin::ProjectsController < AdminController | @@ -3,8 +3,9 @@ class Admin::ProjectsController < AdminController | ||
3 | 3 | ||
4 | def index | 4 | def index |
5 | @projects = Project.scoped | 5 | @projects = Project.scoped |
6 | + @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? | ||
6 | @projects = @projects.search(params[:name]) if params[:name].present? | 7 | @projects = @projects.search(params[:name]) if params[:name].present? |
7 | - @projects = @projects.order("name ASC").page(params[:page]).per(20) | 8 | + @projects = @projects.includes(:namespace).order("namespaces.code, projects.name ASC").page(params[:page]).per(20) |
8 | end | 9 | end |
9 | 10 | ||
10 | def show | 11 | def show |
app/helpers/application_helper.rb
@@ -74,16 +74,25 @@ module ApplicationHelper | @@ -74,16 +74,25 @@ module ApplicationHelper | ||
74 | grouped_options_for_select(options, @ref || @project.default_branch) | 74 | grouped_options_for_select(options, @ref || @project.default_branch) |
75 | end | 75 | end |
76 | 76 | ||
77 | - def namespaces_options | 77 | + def namespaces_options(selected = :current_user, scope = :default) |
78 | groups = current_user.namespaces.select {|n| n.type == 'Group'} | 78 | groups = current_user.namespaces.select {|n| n.type == 'Group'} |
79 | - users = current_user.namespaces.reject {|n| n.type == 'Group'} | 79 | + |
80 | + users = if scope == :all | ||
81 | + Namespace.root | ||
82 | + else | ||
83 | + current_user.namespaces.reject {|n| n.type == 'Group'} | ||
84 | + end | ||
80 | 85 | ||
81 | options = [ | 86 | options = [ |
82 | ["Groups", groups.map {|g| [g.human_name, g.id]} ], | 87 | ["Groups", groups.map {|g| [g.human_name, g.id]} ], |
83 | [ "Users", users.map {|u| [u.human_name, u.id]} ] | 88 | [ "Users", users.map {|u| [u.human_name, u.id]} ] |
84 | ] | 89 | ] |
85 | 90 | ||
86 | - grouped_options_for_select(options, current_user.namespace.id) | 91 | + if selected == :current_user |
92 | + selected = current_user.namespace.id | ||
93 | + end | ||
94 | + | ||
95 | + grouped_options_for_select(options, selected) | ||
87 | end | 96 | end |
88 | 97 | ||
89 | def search_autocomplete_source | 98 | def search_autocomplete_source |
app/models/namespace.rb
@@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base | @@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base | ||
10 | 10 | ||
11 | delegate :name, to: :owner, allow_nil: true, prefix: true | 11 | delegate :name, to: :owner, allow_nil: true, prefix: true |
12 | 12 | ||
13 | + scope :root, where('type IS NULL') | ||
14 | + | ||
13 | def self.search query | 15 | def self.search query |
14 | where("name LIKE :query OR code LIKE :query", query: "%#{query}%") | 16 | where("name LIKE :query OR code LIKE :query", query: "%#{query}%") |
15 | end | 17 | end |
app/models/project.rb
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base | @@ -80,7 +80,7 @@ class Project < ActiveRecord::Base | ||
80 | end | 80 | end |
81 | 81 | ||
82 | def search query | 82 | def search query |
83 | - where("name LIKE :query OR code LIKE :query OR path LIKE :query", query: "%#{query}%") | 83 | + where("projects.name LIKE :query OR projects.code LIKE :query OR projects.path LIKE :query", query: "%#{query}%") |
84 | end | 84 | end |
85 | 85 | ||
86 | def create_by_user(params, user) | 86 | def create_by_user(params, user) |
app/views/admin/projects/index.html.haml
@@ -4,13 +4,14 @@ | @@ -4,13 +4,14 @@ | ||
4 | = link_to 'New Project', new_project_path, class: "btn small right" | 4 | = link_to 'New Project', new_project_path, class: "btn small right" |
5 | %br | 5 | %br |
6 | = form_tag admin_projects_path, method: :get, class: 'form-inline' do | 6 | = form_tag admin_projects_path, method: :get, class: 'form-inline' do |
7 | + = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen xlarge", include_blank: true | ||
7 | = text_field_tag :name, params[:name], class: "xlarge" | 8 | = text_field_tag :name, params[:name], class: "xlarge" |
8 | = submit_tag "Search", class: "btn submit primary" | 9 | = submit_tag "Search", class: "btn submit primary" |
9 | 10 | ||
10 | %table | 11 | %table |
11 | %thead | 12 | %thead |
12 | %th Name | 13 | %th Name |
13 | - %th Path | 14 | + %th Project |
14 | %th Team Members | 15 | %th Team Members |
15 | %th Last Commit | 16 | %th Last Commit |
16 | %th Edit | 17 | %th Edit |
@@ -18,8 +19,13 @@ | @@ -18,8 +19,13 @@ | ||
18 | 19 | ||
19 | - @projects.each do |project| | 20 | - @projects.each do |project| |
20 | %tr | 21 | %tr |
21 | - %td= link_to project.name, [:admin, project] | ||
22 | - %td= project.path | 22 | + %td |
23 | + - if project.namespace | ||
24 | + = link_to project.namespace.human_name, [:admin, project] | ||
25 | + → | ||
26 | + = link_to project.name, [:admin, project] | ||
27 | + %td | ||
28 | + %span.monospace= project.path_with_namespace + ".git" | ||
23 | %td= project.users_projects.count | 29 | %td= project.users_projects.count |
24 | %td= last_commit(project) | 30 | %td= last_commit(project) |
25 | %td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small" | 31 | %td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small" |