summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-23 07:24:09 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-23 07:24:09 +0300
commitf17ddeb394ced4322f9b29eada92d5086bdef03b (patch)
tree088fc56719cdce732491223587f373dd83885eeb /app
parent552b3105fba11493d25575ee9220631a816141f6 (diff)
downloadgitlab-ce-f17ddeb394ced4322f9b29eada92d5086bdef03b.tar.gz
Make admin project list more useful
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/gitlab_bootstrap/typography.scss4
-rw-r--r--app/controllers/admin/projects_controller.rb3
-rw-r--r--app/helpers/application_helper.rb15
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/views/admin/projects/index.html.haml12
6 files changed, 30 insertions, 8 deletions
diff --git a/app/assets/stylesheets/gitlab_bootstrap/typography.scss b/app/assets/stylesheets/gitlab_bootstrap/typography.scss
index fe3bd68b608..6896bb518c2 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/typography.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/typography.scss
@@ -77,3 +77,7 @@ a {
a:focus {
outline: none;
}
+
+.monospace {
+ font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace;
+}
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index 7829cc9315c..418ed4a7062 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -3,8 +3,9 @@ class Admin::ProjectsController < AdminController
def index
@projects = Project.scoped
+ @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
@projects = @projects.search(params[:name]) if params[:name].present?
- @projects = @projects.order("name ASC").page(params[:page]).per(20)
+ @projects = @projects.includes(:namespace).order("namespaces.code, projects.name ASC").page(params[:page]).per(20)
end
def show
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8f206609a2f..d7dbf5ea820 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -74,16 +74,25 @@ module ApplicationHelper
grouped_options_for_select(options, @ref || @project.default_branch)
end
- def namespaces_options
+ def namespaces_options(selected = :current_user, scope = :default)
groups = current_user.namespaces.select {|n| n.type == 'Group'}
- users = current_user.namespaces.reject {|n| n.type == 'Group'}
+
+ users = if scope == :all
+ Namespace.root
+ else
+ current_user.namespaces.reject {|n| n.type == 'Group'}
+ end
options = [
["Groups", groups.map {|g| [g.human_name, g.id]} ],
[ "Users", users.map {|u| [u.human_name, u.id]} ]
]
- grouped_options_for_select(options, current_user.namespace.id)
+ if selected == :current_user
+ selected = current_user.namespace.id
+ end
+
+ grouped_options_for_select(options, selected)
end
def search_autocomplete_source
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 2fa8b06d924..120dac1ce5a 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base
delegate :name, to: :owner, allow_nil: true, prefix: true
+ scope :root, where('type IS NULL')
+
def self.search query
where("name LIKE :query OR code LIKE :query", query: "%#{query}%")
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 07697b1315f..75752125e11 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
end
def search query
- where("name LIKE :query OR code LIKE :query OR path LIKE :query", query: "%#{query}%")
+ where("projects.name LIKE :query OR projects.code LIKE :query OR projects.path LIKE :query", query: "%#{query}%")
end
def create_by_user(params, user)
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index 7239794a812..ffe3cde5293 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -4,13 +4,14 @@
= link_to 'New Project', new_project_path, class: "btn small right"
%br
= form_tag admin_projects_path, method: :get, class: 'form-inline' do
+ = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen xlarge", include_blank: true
= text_field_tag :name, params[:name], class: "xlarge"
= submit_tag "Search", class: "btn submit primary"
%table
%thead
%th Name
- %th Path
+ %th Project
%th Team Members
%th Last Commit
%th Edit
@@ -18,8 +19,13 @@
- @projects.each do |project|
%tr
- %td= link_to project.name, [:admin, project]
- %td= project.path
+ %td
+ - if project.namespace
+ = link_to project.namespace.human_name, [:admin, project]
+ &rarr;
+ = link_to project.name, [:admin, project]
+ %td
+ %span.monospace= project.path_with_namespace + ".git"
%td= project.users_projects.count
%td= last_commit(project)
%td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"