From bb447383c527d28bf4f884df18462e22be05f3b4 Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Tue, 22 Nov 2016 18:11:34 +0100 Subject: Add issue events filter and make sure "All" really shows everything Currently, the EventFilter whitelists event types for the "All" filter. This has gotten outdated, which causes the confusing behaviour of the "All" tab not really showing all events. To make matters worse, by default no tab at all is selected, which does show all events, so selecting the "All" tab actually hides some events. Fix this by: - Making sure All always includes all activity, by abolishing the whitelist and just returning all events instead. - Make the All tab selected by default. - Add Issue events tab to include the specific events around opening and closing issues, since there was no specific filter to see them yet. Fixes #24826 --- lib/event_filter.rb | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'lib/event_filter.rb') diff --git a/lib/event_filter.rb b/lib/event_filter.rb index 21f6a9a762b..515095af1c2 100644 --- a/lib/event_filter.rb +++ b/lib/event_filter.rb @@ -14,6 +14,10 @@ class EventFilter 'merged' end + def issue + 'issue' + end + def comments 'comments' end @@ -32,32 +36,20 @@ class EventFilter end def apply_filter(events) - return events unless params.present? - - filter = params.dup - actions = [] + return events if params.blank? || params == EventFilter.all - case filter + case params when EventFilter.push - actions = [Event::PUSHED] + events.where(action: Event::PUSHED) when EventFilter.merged - actions = [Event::MERGED] + events.where(action: Event::MERGED) when EventFilter.comments - actions = [Event::COMMENTED] + events.where(action: Event::COMMENTED) when EventFilter.team - actions = [Event::JOINED, Event::LEFT, Event::EXPIRED] - when EventFilter.all - actions = [ - Event::PUSHED, - Event::MERGED, - Event::COMMENTED, - Event::JOINED, - Event::LEFT, - Event::EXPIRED - ] + events.where(action: [Event::JOINED, Event::LEFT, Event::EXPIRED]) + when EventFilter.issue + events.where(action: [Event::CREATED, Event::UPDATED, Event::CLOSED, Event::REOPENED]) end - - events.where(action: actions) end def options(key) @@ -73,6 +65,10 @@ class EventFilter end def active?(key) - params.include? key + if params.present? + params.include? key + else + key == EventFilter.all + end end end -- cgit v1.2.3