diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2016-08-29 20:09:33 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2016-10-05 23:38:18 +0300 |
commit | b4d614bdbcb50f506c56eaa180d7b3f3055884a8 (patch) | |
tree | 632466173ac4f48c8d366611ccc46d17a24cc59f /lib | |
parent | 2d9c8f44659ffd09dd073358a7862f033ca468d8 (diff) |
Fix inconsistent highlighting of already selected activity nav-links
Diffstat (limited to 'lib')
-rw-r--r-- | lib/event_filter.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/event_filter.rb b/lib/event_filter.rb index 668d2fa41b3..96e70e37e8f 100644 --- a/lib/event_filter.rb +++ b/lib/event_filter.rb @@ -2,8 +2,8 @@ class EventFilter attr_accessor :params class << self - def default_filter - %w{ push issues merge_requests team} + def all + 'all' end def push @@ -35,18 +35,21 @@ class EventFilter return events unless params.present? filter = params.dup - actions = [] - actions << Event::PUSHED if filter.include? 'push' - actions << Event::MERGED if filter.include? 'merged' - if filter.include? 'team' - actions << Event::JOINED - actions << Event::LEFT + case filter + when EventFilter.push + actions = [Event::PUSHED] + when EventFilter.merged + actions = [Event::MERGED] + when EventFilter.comments + actions = [Event::COMMENTED] + when EventFilter.team + actions = [Event::JOINED, Event::LEFT] + when EventFilter.all + actions = [Event::PUSHED, Event::MERGED, Event::COMMENTED, Event::JOINED, Event::LEFT] end - actions << Event::COMMENTED if filter.include? 'comments' - events.where(action: actions) end |