diff options
author | Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> | 2016-11-22 18:11:34 +0100 |
---|---|---|
committer | Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> | 2016-12-04 23:07:22 +0100 |
commit | bb447383c527d28bf4f884df18462e22be05f3b4 (patch) | |
tree | 82c72bd1de0a05b52f0549d593aeacd012e720f9 /lib | |
parent | ef6a91af123d8b773ba8a286cf986abaedee6c33 (diff) | |
download | gitlab-ce-bb447383c527d28bf4f884df18462e22be05f3b4.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/event_filter.rb | 38 |
1 files changed, 17 insertions, 21 deletions
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 |