Fix inconsistent highlighting of already selected activity nav-links

This commit is contained in:
Clement Ho
2016-08-29 12:09:33 -05:00
parent 2d9c8f4465
commit b4d614bdbc
8 changed files with 153 additions and 18 deletions

View File

@ -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