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
This commit is contained in:
Oxan van Leeuwen
2016-11-22 18:11:34 +01:00
parent ef6a91af12
commit bb447383c5
5 changed files with 39 additions and 24 deletions

View File

@ -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?
return events if params.blank? || params == EventFilter.all
filter = params.dup
actions = []
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