Make projects sort dropdown shared so it can be reused for other pages

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-03-04 16:42:37 +01:00
parent acb211215c
commit bebf34aa47
4 changed files with 15 additions and 23 deletions

View file

@ -1,5 +1,5 @@
module ExploreHelper
def explore_projects_filter_path(options={})
def filter_projects_path(options={})
exist_opts = {
sort: params[:sort],
scope: params[:scope],
@ -9,15 +9,7 @@ module ExploreHelper
}
options = exist_opts.merge(options)
path = if explore_controller?
explore_projects_path
elsif current_action?(:starred)
starred_dashboard_projects_path
else
dashboard_projects_path
end
path = request.path
path << "?#{options.to_param}"
path
end

View file

@ -15,7 +15,7 @@
.nav-controls
= form_tag request.original_url, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
= search_field_tag :filter_projects, params[:filter_projects], placeholder: 'Filter by name...', class: 'project-filter-form-field form-control input-short projects-list-filter', spellcheck: false, id: 'project-filter-form-field', tabindex: "2"
= render 'explore/projects/dropdown'
= render 'shared/projects/dropdown'
- if current_user.can_create_project?
= link_to new_project_path, class: 'btn btn-new' do
= icon('plus')

View file

@ -10,11 +10,11 @@
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_filter_path(visibility_level: nil) do
= link_to filter_projects_path(visibility_level: nil) do
Any
- Gitlab::VisibilityLevel.values.each do |level|
%li{ class: (level.to_s == params[:visibility_level]) ? 'active' : 'light' }
= link_to explore_projects_filter_path(visibility_level: level) do
= link_to filter_projects_path(visibility_level: level) do
= visibility_level_icon(level)
= visibility_level_label(level)
@ -30,11 +30,11 @@
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_filter_path(tag: nil) do
= link_to filter_projects_path(tag: nil) do
Any
- @tags.each do |tag|
%li{ class: (tag.name == params[:tag]) ? 'active' : 'light' }
= link_to explore_projects_filter_path(tag: tag.name) do
%i.fa.fa-tag
= link_to filter_projects_path(tag: tag.name) do
= icon('tag')
= tag.name

View file

@ -8,21 +8,21 @@
%b.caret
%ul.dropdown-menu.dropdown-menu-align-right
%li
= link_to explore_projects_filter_path(sort: sort_value_name) do
= link_to filter_projects_path(sort: sort_value_name) do
= sort_title_name
= link_to explore_projects_filter_path(sort: sort_value_recently_created) do
= link_to filter_projects_path(sort: sort_value_recently_created) do
= sort_title_recently_created
= link_to explore_projects_filter_path(sort: sort_value_oldest_created) do
= link_to filter_projects_path(sort: sort_value_oldest_created) do
= sort_title_oldest_created
= link_to explore_projects_filter_path(sort: sort_value_recently_updated) do
= link_to filter_projects_path(sort: sort_value_recently_updated) do
= sort_title_recently_updated
= link_to explore_projects_filter_path(sort: sort_value_oldest_updated) do
= link_to filter_projects_path(sort: sort_value_oldest_updated) do
= sort_title_oldest_updated
%li.divider
%li
- if params[:archived].present?
= link_to explore_projects_filter_path(sort: @sort, archived: nil) do
= link_to filter_projects_path(sort: @sort, archived: nil) do
Hide archived projects
- else
= link_to explore_projects_filter_path(sort: @sort, archived: true) do
= link_to filter_projects_path(sort: @sort, archived: true) do
Show archived projects