diff --git a/app/assets/stylesheets/gitlab_bootstrap/forms.scss b/app/assets/stylesheets/gitlab_bootstrap/forms.scss index 1a310a75c31402c1457ed6c41755ebac1303e69a..39dd1f6c7478c5a853b7996e6584365776397619 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/forms.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/forms.scss @@ -21,6 +21,10 @@ form { text-align: left; } } + + &.form-tiny { + margin: 0; + } } input.input-xpadding, diff --git a/app/contexts/issues/list_context.rb b/app/contexts/issues/list_context.rb index fd27356d1cd48d739fad969da29165ce5b77064f..b256fd4c732f669b47eed26ab2fd7eff55478540 100644 --- a/app/contexts/issues/list_context.rb +++ b/app/contexts/issues/list_context.rb @@ -29,7 +29,7 @@ module Issues if params[:milestone_id].present? @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) end - + # Sort by :sort param @issues = sort(@issues, params[:sort]) @@ -49,6 +49,5 @@ module Issues else issues end end - end end diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb index 8d66250d7b6d6e61bf1ea7d3c313b1362c877138..34425db72ab0aba000f3ef17e02019bb724a92a5 100644 --- a/app/controllers/public/projects_controller.rb +++ b/app/controllers/public/projects_controller.rb @@ -8,6 +8,13 @@ class Public::ProjectsController < ApplicationController def index @projects = Project.public_or_internal_only(current_user) @projects = @projects.search(params[:search]) if params[:search].present? - @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) + @projects = case params[:sort] + when 'newest' then @projects.order('created_at DESC') + when 'oldest' then @projects.order('created_at ASC') + when 'recently_updated' then @projects.order('updated_at DESC') + when 'last_updated' then @projects.order('updated_at ASC') + else @projects.order("namespaces.path, projects.name ASC") + end + @projects = @projects.includes(:namespace).page(params[:page]).per(20) end end diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index b88169add3c83334b61d57fc728a14cfc8529a02..193d5c089a059b671439dcc88cf75a7df2b48bc7 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -1,16 +1,35 @@ -.row - .span6 - %h3.page-title - Projects (#{@projects.total_count}) - .light - You can browse public projects in read-only mode until signed in. +%h3.page-title + Projects (#{@projects.total_count}) +.light + You can browse public projects in read-only mode until signed in. +%hr +.clearfix + .pull-left + = form_tag public_projects_path, method: :get, class: 'form-inline form-tiny' do |f| + .search-holder + = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span4 search-text-input", id: "projects_search" + = submit_tag 'Search', class: "btn btn-primary wide" + + .pull-right + .dropdown.inline + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %span.light sort: + - if @sort.present? + = @sort + - else + Newest + %b.caret + %ul.dropdown-menu + %li + = link_to public_projects_path(sort: 'newest') do + Newest + = link_to public_projects_path(sort: 'oldest') do + Oldest + = link_to public_projects_path(sort: 'recently_updated') do + Recently updated + = link_to public_projects_path(sort: 'last_updated') do + Last updated - .span6 - .pull-right - = form_tag public_projects_path, method: :get, class: 'form-inline' do |f| - .search-holder - = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search" - = submit_tag 'Search', class: "btn btn-primary wide" %hr .public-projects %ul.bordered-list.top-list