Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxan van Leeuwen <oxan@oxanvanleeuwen.nl>2016-11-22 20:11:34 +0300
committerOxan van Leeuwen <oxan@oxanvanleeuwen.nl>2016-12-05 01:07:22 +0300
commitbb447383c527d28bf4f884df18462e22be05f3b4 (patch)
tree82c72bd1de0a05b52f0549d593aeacd012e720f9 /lib/event_filter.rb
parentef6a91af123d8b773ba8a286cf986abaedee6c33 (diff)
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/event_filter.rb')
-rw-r--r--lib/event_filter.rb38
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