Add public filter to admin projects

This commit is contained in:
Dmitriy Zaporozhets 2013-01-13 17:24:29 +02:00
parent 122acb2254
commit 68bfcd0521
10 changed files with 73 additions and 34 deletions

View file

@ -32,6 +32,7 @@
@import "sections/profile.scss";
@import "sections/login.scss";
@import "sections/editor.scss";
@import "sections/admin.scss";
@import "highlight/white.scss";
@import "highlight/dark.scss";

View file

@ -0,0 +1,5 @@
.admin-filter form {
label { width: 110px; }
.controls { margin-left: 130px; }
.form-actions { padding-left: 130px; background: #fff }
}

View file

@ -4,6 +4,7 @@ class Admin::ProjectsController < AdminController
def index
@projects = Project.scoped
@projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
@projects = @projects.where(public: true) if params[:public_only].present?
@projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id
@projects = @projects.search(params[:name]) if params[:name].present?
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)

View file

@ -7,5 +7,6 @@ class Public::ProjectsController < ApplicationController
def index
@projects = Project.public
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
end
end

View file

@ -1,38 +1,47 @@
%h3.page_title
Projects (#{Project.count})
Projects
= 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", prompt: "Project namespace"
= text_field_tag :name, params[:name], class: "xlarge"
= submit_tag "Search", class: "btn submit primary"
%table
%thead
%tr
%th
Name
%i.icon-sort-down
%th Path
%th Team Members
%th Owner
%th Last Commit
%th Edit
%th.cred Danger Zone!
%hr
- @projects.each do |project|
%tr
%td
= link_to project.name_with_namespace, [:admin, project]
%td
%span.monospace= project.path_with_namespace + ".git"
%td= project.users_projects.count
%td
- if project.owner
= link_to project.owner.name, [:admin, project.owner]
.row
.span4
.admin-filter
= form_tag admin_projects_path, method: :get, class: 'form-inline' do
.control-group
= label_tag :name, 'Name:', class: 'control-label'
.controls
= text_field_tag :name, params[:name], class: "span2"
.control-group
= label_tag :namespace_id, 'Namespace:', class: 'control-label'
.controls
= select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen span2", prompt: "Any"
.control-group
= label_tag :public_only, 'Public Only', class: 'control-label'
.controls
= check_box_tag :public_only, 1, params[:public_only]
.form-actions
= submit_tag "Search", class: "btn submit primary"
= link_to "Reset", admin_projects_path, class: "btn"
.span8
.ui-box
%h5.title
Projects (#{@projects.total_count})
%ul.well-list
- @projects.each do |project|
%li
- if project.public
%i.icon-unlock.cred
- else
%i.icon-lock.cgreen
= link_to project.name_with_namespace, [:admin, project]
.right
= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
= link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger"
- if @projects.blank?
%p.nothing_here_message 0 projects matches
- else
(deleted)
%td= last_commit(project)
%td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
%td.bgred= link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger"
= paginate @projects, theme: "admin"
%li.bottom
= paginate @projects, theme: "admin"

View file

@ -47,3 +47,5 @@
%li
%span= link_to "System Hooks", help_system_hooks_path
%li
%span= link_to "Public Area", help_public_area_path

View file

@ -0,0 +1,16 @@
%h3.page_title Public Area
.back_link
= link_to help_path do
&larr; to index
%hr
%p
Public area - is part of application with public access.
%br
It used to list all projects with public read-only access.
%br
If you enable public http access to the project - it will appears there
%br
Follow #{link_to "this link", public_root_path} to visit Public Area

View file

@ -18,7 +18,7 @@
%span.count= current_user.cared_merge_requests.opened.count
= nav_link(path: 'search#show') do
= link_to "Search", search_path
= nav_link(path: 'help#index') do
= nav_link(controller: :help) do
= link_to "Help", help_path
.content= yield

View file

@ -12,3 +12,6 @@
.right
%span.monospace.tiny
git clone #{project.http_url_to_repo}
= paginate @projects, theme: "admin"

View file

@ -35,6 +35,7 @@ Gitlab::Application.routes.draw do
get 'help/markdown' => 'help#markdown'
get 'help/ssh' => 'help#ssh'
get 'help/raketasks' => 'help#raketasks'
get 'help/public_area' => 'help#public_area'
#
# Public namespace