Commit 68bfcd0521020d9f0154ffe767aa1e327e93ca24

Authored by Dmitriy Zaporozhets
1 parent 122acb22

Add public filter to admin projects

app/assets/stylesheets/application.scss
... ... @@ -32,6 +32,7 @@
32 32 @import "sections/profile.scss";
33 33 @import "sections/login.scss";
34 34 @import "sections/editor.scss";
  35 +@import "sections/admin.scss";
35 36  
36 37 @import "highlight/white.scss";
37 38 @import "highlight/dark.scss";
... ...
app/assets/stylesheets/sections/admin.scss 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +.admin-filter form {
  2 + label { width: 110px; }
  3 + .controls { margin-left: 130px; }
  4 + .form-actions { padding-left: 130px; background: #fff }
  5 +}
... ...
app/controllers/admin/projects_controller.rb
... ... @@ -4,6 +4,7 @@ class Admin::ProjectsController < AdminController
4 4 def index
5 5 @projects = Project.scoped
6 6 @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
  7 + @projects = @projects.where(public: true) if params[:public_only].present?
7 8 @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id
8 9 @projects = @projects.search(params[:name]) if params[:name].present?
9 10 @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
... ...
app/controllers/public/projects_controller.rb
... ... @@ -7,5 +7,6 @@ class Public::ProjectsController < ApplicationController
7 7  
8 8 def index
9 9 @projects = Project.public
  10 + @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
10 11 end
11 12 end
... ...
app/views/admin/projects/index.html.haml
1 1 %h3.page_title
2   - Projects (#{Project.count})
  2 + Projects
3 3 = link_to 'New Project', new_project_path, class: "btn small right"
4   -%br
5   -= form_tag admin_projects_path, method: :get, class: 'form-inline' do
6   - = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen xlarge", prompt: "Project namespace"
7   - = text_field_tag :name, params[:name], class: "xlarge"
8   - = submit_tag "Search", class: "btn submit primary"
9 4  
10   -%table
11   - %thead
12   - %tr
13   - %th
14   - Name
15   - %i.icon-sort-down
16   - %th Path
17   - %th Team Members
18   - %th Owner
19   - %th Last Commit
20   - %th Edit
21   - %th.cred Danger Zone!
  5 +%hr
22 6  
23   - - @projects.each do |project|
24   - %tr
25   - %td
26   - = link_to project.name_with_namespace, [:admin, project]
27   - %td
28   - %span.monospace= project.path_with_namespace + ".git"
29   - %td= project.users_projects.count
30   - %td
31   - - if project.owner
32   - = link_to project.owner.name, [:admin, project.owner]
  7 +.row
  8 + .span4
  9 + .admin-filter
  10 + = form_tag admin_projects_path, method: :get, class: 'form-inline' do
  11 + .control-group
  12 + = label_tag :name, 'Name:', class: 'control-label'
  13 + .controls
  14 + = text_field_tag :name, params[:name], class: "span2"
  15 +
  16 + .control-group
  17 + = label_tag :namespace_id, 'Namespace:', class: 'control-label'
  18 + .controls
  19 + = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen span2", prompt: "Any"
  20 + .control-group
  21 + = label_tag :public_only, 'Public Only', class: 'control-label'
  22 + .controls
  23 + = check_box_tag :public_only, 1, params[:public_only]
  24 +
  25 + .form-actions
  26 + = submit_tag "Search", class: "btn submit primary"
  27 + = link_to "Reset", admin_projects_path, class: "btn"
  28 + .span8
  29 + .ui-box
  30 + %h5.title
  31 + Projects (#{@projects.total_count})
  32 + %ul.well-list
  33 + - @projects.each do |project|
  34 + %li
  35 + - if project.public
  36 + %i.icon-unlock.cred
  37 + - else
  38 + %i.icon-lock.cgreen
  39 + = link_to project.name_with_namespace, [:admin, project]
  40 + .right
  41 + = link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
  42 + = link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger"
  43 + - if @projects.blank?
  44 + %p.nothing_here_message 0 projects matches
33 45 - else
34   - (deleted)
35   - %td= last_commit(project)
36   - %td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small"
37   - %td.bgred= link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger"
38   -= paginate @projects, theme: "admin"
  46 + %li.bottom
  47 + = paginate @projects, theme: "admin"
... ...
app/views/help/index.html.haml
... ... @@ -47,3 +47,5 @@
47 47 %li
48 48 %span= link_to "System Hooks", help_system_hooks_path
49 49  
  50 + %li
  51 + %span= link_to "Public Area", help_public_area_path
... ...
app/views/help/public_area.html.haml 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +%h3.page_title Public Area
  2 +.back_link
  3 + = link_to help_path do
  4 + ← to index
  5 +%hr
  6 +
  7 +%p
  8 + Public area - is part of application with public access.
  9 + %br
  10 + It used to list all projects with public read-only access.
  11 + %br
  12 + If you enable public http access to the project - it will appears there
  13 + %br
  14 +
  15 + Follow #{link_to "this link", public_root_path} to visit Public Area
  16 +
... ...
app/views/layouts/application.html.haml
... ... @@ -18,7 +18,7 @@
18 18 %span.count= current_user.cared_merge_requests.opened.count
19 19 = nav_link(path: 'search#show') do
20 20 = link_to "Search", search_path
21   - = nav_link(path: 'help#index') do
  21 + = nav_link(controller: :help) do
22 22 = link_to "Help", help_path
23 23  
24 24 .content= yield
... ...
app/views/public/projects/index.html.haml
... ... @@ -12,3 +12,6 @@
12 12 .right
13 13 %span.monospace.tiny
14 14 git clone #{project.http_url_to_repo}
  15 +
  16 +
  17 += paginate @projects, theme: "admin"
... ...
config/routes.rb
... ... @@ -35,6 +35,7 @@ Gitlab::Application.routes.draw do
35 35 get 'help/markdown' => 'help#markdown'
36 36 get 'help/ssh' => 'help#ssh'
37 37 get 'help/raketasks' => 'help#raketasks'
  38 + get 'help/public_area' => 'help#public_area'
38 39  
39 40 #
40 41 # Public namespace
... ...