Skip to content
Snippets Groups Projects
Commit ed1f1104 authored by Phil Hughes's avatar Phil Hughes Committed by Dmitriy Zaporozhets
Browse files

Fixes filtering by name reseting archive filter

Previously the search form just wasn't including any params that had previously been set, so when you filtered by name, it would reset all the params & therefore ignoring the archived param

Closes #28007
parent b1864604
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -8,7 +8,7 @@ module FilterProjects
extend ActiveSupport::Concern
 
def filter_projects(projects)
projects = projects.search(params[:filter_projects]) if params[:filter_projects].present?
projects = projects.search(params[:name]) if params[:name].present?
projects = projects.non_archived if params[:archived].blank?
projects = projects.personal(current_user) if params[:personal].present? && current_user
 
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@
.top-area
.prepend-top-default
= form_tag admin_projects_path, method: :get do |f|
= render "shared/projects/filter_fields"
.search-holder
.search-field-holder
= search_field_tag :name, params[:name], class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false, placeholder: 'Search by name'
Loading
Loading
@@ -15,20 +16,12 @@
- if params[:visibility_level].present?
= hidden_field_tag 'visibility_level', params[:visibility_level]
 
- if params[:sort].present?
= hidden_field_tag 'sort', params[:sort]
- if params[:personal].present?
= hidden_field_tag 'visibility_level', 'true'
- if params[:archived].present?
= hidden_field_tag 'archived', 'true'
= icon("search", class: "search-icon")
 
.dropdown
- toggle_text = 'Namespace'
- if params[:namespace_id].present?
= hidden_field_tag :namespace_id, params[:namespace_id]
- namespace = Namespace.find(params[:namespace_id])
- toggle_text = "#{namespace.kind}: #{namespace.full_path}"
= dropdown_toggle(toggle_text, { toggle: 'dropdown' }, { toggle_class: 'js-namespace-select large' })
Loading
Loading
Loading
Loading
@@ -13,8 +13,9 @@
Explore projects
 
.nav-controls
= form_tag request.path, 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"
= form_tag request.fullpath, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
= render "shared/projects/filter_fields"
= search_field_tag :name, params[:name], 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 'shared/projects/dropdown'
- if current_user.can_create_project?
= link_to new_project_path, class: 'btn btn-new' do
Loading
Loading
Loading
Loading
@@ -11,8 +11,9 @@
.top-area
= render 'groups/show_nav'
.nav-controls
= form_tag request.path, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
= search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control', spellcheck: false
= form_tag request.fullpath, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
= render "shared/projects/filter_fields"
= search_field_tag :name, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control', spellcheck: false
= render 'shared/projects/dropdown'
- if can? current_user, :create_projects, @group
= link_to new_project_path(namespace_id: @group.id), class: 'btn btn-new pull-right' do
Loading
Loading
- @sort ||= sort_value_recently_updated
- name = params[:name]
- personal = params[:personal]
- archived = params[:archived]
- shared = params[:shared]
Loading
Loading
@@ -11,32 +12,32 @@
Sort by
- projects_sort_options_hash.each do |value, title|
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: value, archived: archived, personal: personal), class: ("is-active" if @sort == value) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: value, archived: archived, personal: personal, name: name), class: ("is-active" if @sort == value) do
= title
 
%li.divider
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, archived: nil), class: ("is-active" unless params[:archived].present?) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, archived: nil, name: name), class: ("is-active" unless params[:archived].present?) do
Hide archived projects
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, archived: true), class: ("is-active" if params[:archived].present?) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, archived: true, name: name), class: ("is-active" if params[:archived].present?) do
Show archived projects
- if current_user
%li.divider
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, personal: nil), class: ("is-active" unless personal.present?) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, personal: nil, name: name), class: ("is-active" unless personal.present?) do
Owned by anyone
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, personal: true), class: ("is-active" if personal.present?) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, personal: true, name: name), class: ("is-active" if personal.present?) do
Owned by me
- if @group && @group.shared_projects.present?
%li.divider
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: nil), class: ("is-active" unless shared.present?) do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: nil, name: name), class: ("is-active" unless shared.present?) do
All projects
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: 0), class: ("is-active" if shared == '0') do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: 0, name: name), class: ("is-active" if shared == '0') do
Hide shared projects
%li
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: 1), class: ("is-active" if shared == '1') do
= link_to filter_projects_path(namespace_id: namespace_id, sort: @sort, shared: 1, name: name), class: ("is-active" if shared == '1') do
Hide group projects
- if params[:sort].present?
= hidden_field_tag :sort, params[:sort]
- if params[:personal].present?
= hidden_field_tag :personal, params[:personal]
- if params[:archived].present?
= hidden_field_tag :archived, params[:archived]
- if params[:visibility_level].present?
= hidden_field_tag :visibility_level, params[:visibility_level]
---
title: Dashboard project search keeps selected sort & filters
merge_request:
author:
Loading
Loading
@@ -25,4 +25,19 @@ RSpec.describe 'Dashboard Archived Project', feature: true do
expect(page).to have_link(project.name)
expect(page).to have_link(archived_project.name)
end
it 'searchs archived projects', :js do
click_button 'Last updated'
click_link 'Show archived projects'
expect(page).to have_link(project.name)
expect(page).to have_link(archived_project.name)
fill_in 'project-filter-form-field', with: archived_project.name
find('#project-filter-form-field').native.send_keys :return
expect(page).not_to have_link(project.name)
expect(page).to have_link(archived_project.name)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment