Commit 83f7e98d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add project filter by visibility and tag to explore page

parent 8527e8d5
...@@ -36,7 +36,6 @@ class DashboardController < ApplicationController ...@@ -36,7 +36,6 @@ class DashboardController < ApplicationController
end end
@projects = @projects.where(namespace_id: Group.find_by(name: params[:group])) if params[:group].present? @projects = @projects.where(namespace_id: Group.find_by(name: params[:group])) if params[:group].present?
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
@projects = @projects.includes(:namespace, :forked_from_project, :tags) @projects = @projects.includes(:namespace, :forked_from_project, :tags)
@projects = @projects.tagged_with(params[:tag]) if params[:tag].present? @projects = @projects.tagged_with(params[:tag]) if params[:tag].present?
@projects = @projects.sort(@sort = params[:sort]) @projects = @projects.sort(@sort = params[:sort])
......
...@@ -6,6 +6,9 @@ class Explore::ProjectsController < ApplicationController ...@@ -6,6 +6,9 @@ class Explore::ProjectsController < ApplicationController
def index def index
@projects = ProjectsFinder.new.execute(current_user) @projects = ProjectsFinder.new.execute(current_user)
@tags = @projects.tags_on(:tags)
@projects = @projects.tagged_with(params[:tag]) if params[:tag].present?
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
@projects = @projects.search(params[:search]) if params[:search].present? @projects = @projects.search(params[:search]) if params[:search].present?
@projects = @projects.sort(@sort = params[:sort]) @projects = @projects.sort(@sort = params[:sort])
@projects = @projects.includes(:namespace).page(params[:page]).per(20) @projects = @projects.includes(:namespace).page(params[:page]).per(20)
......
module DashboardHelper module DashboardHelper
def projects_dashboard_filter_path(options={})
exist_opts = {
sort: params[:sort],
scope: params[:scope],
group: params[:group],
tag: params[:tag],
visibility_level: params[:visibility_level],
}
options = exist_opts.merge(options)
path = request.path
path << "?#{options.to_param}"
path
end
def assigned_issues_dashboard_path def assigned_issues_dashboard_path
issues_dashboard_path(assignee_id: current_user.id) issues_dashboard_path(assignee_id: current_user.id)
end end
......
module ExploreHelper
def explore_projects_filter_path(options={})
exist_opts = {
sort: params[:sort],
scope: params[:scope],
group: params[:group],
tag: params[:tag],
visibility_level: params[:visibility_level],
}
options = exist_opts.merge(options)
path = request.path
path << "?#{options.to_param}"
path
end
end
.dash-projects-filters.append-bottom-20
.append-right-20
%ul.nav.nav-tabs
= nav_tab :scope, nil do
= link_to projects_dashboard_filter_path(scope: nil) do
All
= nav_tab :scope, 'personal' do
= link_to projects_dashboard_filter_path(scope: 'personal') do
Personal
= nav_tab :scope, 'joined' do
= link_to projects_dashboard_filter_path(scope: 'joined') do
Joined
= nav_tab :scope, 'owned' do
= link_to projects_dashboard_filter_path(scope: 'owned') do
Owned
.dropdown.inline.append-right-10
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-globe
%span.light Visibility:
- if params[:visibility_level].present?
= visibility_level_label(params[:visibility_level].to_i)
- else
Any
%b.caret
%ul.dropdown-menu
%li
= link_to projects_dashboard_filter_path(visibility_level: nil) do
Any
- Gitlab::VisibilityLevel.values.each do |level|
%li{ class: (level.to_s == params[:visibility_level]) ? 'active' : 'light' }
= link_to projects_dashboard_filter_path(visibility_level: level) do
= visibility_level_icon(level)
= visibility_level_label(level)
- if @groups.present?
.dropdown.inline.append-right-10
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-group
%span.light Group:
- if params[:group].present?
= Group.find_by(name: params[:group]).name
- else
Any
%b.caret
%ul.dropdown-menu
%li
= link_to projects_dashboard_filter_path(group: nil) do
Any
- @groups.each do |group|
%li{ class: (group.name == params[:group]) ? 'active' : 'light' }
= link_to projects_dashboard_filter_path(group: group.name) do
= group.name
%small.pull-right
= group.projects.count
- if @tags.present?
.dropdown.inline.append-right-10
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-tags
%span.light Tags:
- if params[:tag].present?
= params[:tag]
- else
Any
%b.caret
%ul.dropdown-menu
%li
= link_to projects_dashboard_filter_path(tag: nil) do
Any
- @tags.each do |tag|
%li{ class: (tag.name == params[:tag]) ? 'active' : 'light' }
= link_to projects_dashboard_filter_path(tag: tag.name) do
%i.fa.fa-tag
= tag.name
.pull-right
.dropdown.inline
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%span.light sort:
- if @sort.present?
= sort_options_hash[@sort]
- else
= sort_title_recently_created
%b.caret
%ul.dropdown-menu
%li
= link_to projects_dashboard_filter_path(sort: sort_value_recently_created) do
= sort_title_recently_created
= link_to projects_dashboard_filter_path(sort: sort_value_oldest_created) do
= sort_title_oldest_created
= link_to projects_dashboard_filter_path(sort: sort_value_recently_updated) do
= sort_title_recently_updated
= link_to projects_dashboard_filter_path(sort: sort_value_oldest_updated) do
= sort_title_oldest_updated
= link_to projects_dashboard_filter_path(sort: sort_value_name) do
= sort_title_name
.pull-left
= form_tag explore_projects_filter_path, method: :get, class: 'form-inline form-tiny' do |f|
.form-group
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input input-mn-300", id: "projects_search"
.form-group
= button_tag 'Search', class: "btn btn-primary wide"
.pull-right.hidden-sm.hidden-xs
- if current_user
.dropdown.inline.append-right-10
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-globe
%span.light Visibility:
- if params[:visibility_level].present?
= visibility_level_label(params[:visibility_level].to_i)
- else
Any
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_filter_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
= visibility_level_icon(level)
= visibility_level_label(level)
- if @tags.present?
.dropdown.inline.append-right-10
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%i.fa.fa-tags
%span.light Tags:
- if params[:tag].present?
= params[:tag]
- else
Any
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_filter_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
= tag.name
.dropdown.inline
%button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
%span.light sort:
- if @sort.present?
= sort_options_hash[@sort]
- else
= sort_title_recently_created
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_filter_path(sort: sort_value_recently_created) do
= sort_title_recently_created
= link_to explore_projects_filter_path(sort: sort_value_oldest_created) do
= sort_title_oldest_created
= link_to explore_projects_filter_path(sort: sort_value_recently_updated) do
= sort_title_recently_updated
= link_to explore_projects_filter_path(sort: sort_value_oldest_updated) do
= sort_title_oldest_updated
.clearfix .clearfix
.pull-left = render 'filter'
= form_tag explore_projects_path, method: :get, class: 'form-inline form-tiny' do |f|
.form-group
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input input-mn-300", id: "projects_search"
.form-group
= button_tag 'Search', class: "btn btn-primary wide"
.pull-right
.dropdown.inline
%button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
%span.light sort:
- if @sort.present?
= sort_options_hash[@sort]
- else
= sort_title_recently_created
%b.caret
%ul.dropdown-menu
%li
= link_to explore_projects_path(sort: sort_value_recently_created) do
= sort_title_recently_created
= link_to explore_projects_path(sort: sort_value_oldest_created) do
= sort_title_oldest_created
= link_to explore_projects_path(sort: sort_value_recently_updated) do
= sort_title_recently_updated
= link_to explore_projects_path(sort: sort_value_oldest_updated) do
= sort_title_oldest_updated
%hr %hr
.public-projects .public-projects
......
...@@ -41,4 +41,3 @@ ...@@ -41,4 +41,3 @@
%i.fa.fa-question-circle %i.fa.fa-question-circle
%span %span
Help Help
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment