Make admin project list more useful
This commit is contained in:
parent
552b3105fb
commit
f17ddeb394
6 changed files with 30 additions and 8 deletions
|
@ -77,3 +77,7 @@ a {
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.monospace {
|
||||||
|
font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace;
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@ class Admin::ProjectsController < AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@projects = Project.scoped
|
@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.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
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -74,16 +74,25 @@ module ApplicationHelper
|
||||||
grouped_options_for_select(options, @ref || @project.default_branch)
|
grouped_options_for_select(options, @ref || @project.default_branch)
|
||||||
end
|
end
|
||||||
|
|
||||||
def namespaces_options
|
def namespaces_options(selected = :current_user, scope = :default)
|
||||||
groups = current_user.namespaces.select {|n| n.type == 'Group'}
|
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 = [
|
options = [
|
||||||
["Groups", groups.map {|g| [g.human_name, g.id]} ],
|
["Groups", groups.map {|g| [g.human_name, g.id]} ],
|
||||||
[ "Users", users.map {|u| [u.human_name, u.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
|
end
|
||||||
|
|
||||||
def search_autocomplete_source
|
def search_autocomplete_source
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Namespace < ActiveRecord::Base
|
||||||
|
|
||||||
delegate :name, to: :owner, allow_nil: true, prefix: true
|
delegate :name, to: :owner, allow_nil: true, prefix: true
|
||||||
|
|
||||||
|
scope :root, where('type IS NULL')
|
||||||
|
|
||||||
def self.search query
|
def self.search query
|
||||||
where("name LIKE :query OR code LIKE :query", query: "%#{query}%")
|
where("name LIKE :query OR code LIKE :query", query: "%#{query}%")
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def search query
|
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
|
end
|
||||||
|
|
||||||
def create_by_user(params, user)
|
def create_by_user(params, user)
|
||||||
|
|
|
@ -4,13 +4,14 @@
|
||||||
= link_to 'New Project', new_project_path, class: "btn small right"
|
= link_to 'New Project', new_project_path, class: "btn small right"
|
||||||
%br
|
%br
|
||||||
= form_tag admin_projects_path, method: :get, class: 'form-inline' do
|
= 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"
|
= text_field_tag :name, params[:name], class: "xlarge"
|
||||||
= submit_tag "Search", class: "btn submit primary"
|
= submit_tag "Search", class: "btn submit primary"
|
||||||
|
|
||||||
%table
|
%table
|
||||||
%thead
|
%thead
|
||||||
%th Name
|
%th Name
|
||||||
%th Path
|
%th Project
|
||||||
%th Team Members
|
%th Team Members
|
||||||
%th Last Commit
|
%th Last Commit
|
||||||
%th Edit
|
%th Edit
|
||||||
|
@ -18,8 +19,13 @@
|
||||||
|
|
||||||
- @projects.each do |project|
|
- @projects.each do |project|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to project.name, [:admin, project]
|
%td
|
||||||
%td= project.path
|
- if project.namespace
|
||||||
|
= link_to project.namespace.human_name, [:admin, project]
|
||||||
|
→
|
||||||
|
= link_to project.name, [:admin, project]
|
||||||
|
%td
|
||||||
|
%span.monospace= project.path_with_namespace + ".git"
|
||||||
%td= project.users_projects.count
|
%td= project.users_projects.count
|
||||||
%td= last_commit(project)
|
%td= last_commit(project)
|
||||||
%td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
|
%td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
|
||||||
|
|
Loading…
Add table
Reference in a new issue