Commit 880530da authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '22457-reset-filters-button-should-be-invisible-when-no-filters-are-active' into 'master'

`Reset filters` link should only be visible when filters are active

## Why was this MR needed?

`Reset filters` link is always visible.

Closes #22457

See merge request !6497
parents 6d709417 44361930
...@@ -124,6 +124,10 @@ module IssuablesHelper ...@@ -124,6 +124,10 @@ module IssuablesHelper
end end
end end
def issuable_filters_present
params[:search] || params[:author_id] || params[:assignee_id] || params[:milestone_title] || params[:label_name]
end
def issuables_count_for_state(issuable_type, state) def issuables_count_for_state(issuable_type, state)
issuables_finder = public_send("#{issuable_type}_finder") issuables_finder = public_send("#{issuable_type}_finder")
issuables_finder.params[:state] = state issuables_finder.params[:state] = state
......
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
.filter-item.inline.labels-filter .filter-item.inline.labels-filter
= render "shared/issuable/label_dropdown", selected: finder.labels.select(:title).uniq, use_id: false, selected_toggle: params[:label_name], data_options: { field_name: "label_name[]" } = render "shared/issuable/label_dropdown", selected: finder.labels.select(:title).uniq, use_id: false, selected_toggle: params[:label_name], data_options: { field_name: "label_name[]" }
.filter-item.inline.reset-filters - if issuable_filters_present
%a{href: page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search])} Reset filters .filter-item.inline.reset-filters
%a{href: page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name, :search])} Reset filters
.pull-right .pull-right
- if boards_page - if boards_page
......
...@@ -75,6 +75,14 @@ feature 'Issues filter reset button', feature: true, js: true do ...@@ -75,6 +75,14 @@ feature 'Issues filter reset button', feature: true, js: true do
end end
end end
context 'when no filters have been applied' do
it 'the reset link should not be visible' do
visit_issues(project)
expect(page).to have_css('.issue', count: 2)
expect(page).not_to have_css '.reset_filters'
end
end
def reset_filters def reset_filters
find('.reset-filters').click find('.reset-filters').click
end end
......
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