Commit 8b489ba7759009ea5731db82a57ee3a36386287e
Exists in
master
and in
4 other branches
Merge branch 'feature/dashboard_event_filters' of dev.gitlabhq.com:gitlabhq
Showing
11 changed files
with
134 additions
and
3 deletions
Show diff stats
750 Bytes
463 Bytes
632 Bytes
1.31 KB
app/assets/javascripts/main.js.coffee
| @@ -27,6 +27,9 @@ $ -> | @@ -27,6 +27,9 @@ $ -> | ||
| 27 | # Initialize chosen selects | 27 | # Initialize chosen selects |
| 28 | $('select.chosen').chosen() | 28 | $('select.chosen').chosen() |
| 29 | 29 | ||
| 30 | + # Initialize tooltips | ||
| 31 | + $('.has_tooltip').tooltip() | ||
| 32 | + | ||
| 30 | # Disable form buttons while a form is submitting | 33 | # Disable form buttons while a form is submitting |
| 31 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> | 34 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> |
| 32 | buttons = $('[type="submit"]', @) | 35 | buttons = $('[type="submit"]', @) |
app/assets/stylesheets/sections/events.scss
| @@ -115,3 +115,29 @@ | @@ -115,3 +115,29 @@ | ||
| 115 | margin: -3px; | 115 | margin: -3px; |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | + | ||
| 119 | +/** | ||
| 120 | + * Event filter | ||
| 121 | + * | ||
| 122 | + */ | ||
| 123 | +.event_filter { | ||
| 124 | + position: absolute; | ||
| 125 | + width: 40px; | ||
| 126 | + margin-left: -50px; | ||
| 127 | + | ||
| 128 | + .filter_icon { | ||
| 129 | + float: left; | ||
| 130 | + border-left: 3px solid #4bc; | ||
| 131 | + padding: 7px; | ||
| 132 | + background: #f9f9f9; | ||
| 133 | + margin-bottom: 10px; | ||
| 134 | + img { | ||
| 135 | + width:20px; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + &.inactive { | ||
| 139 | + border-left: 3px solid #EEE; | ||
| 140 | + opacity: 0.5; | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | +} |
app/controllers/dashboard_controller.rb
| 1 | class DashboardController < ApplicationController | 1 | class DashboardController < ApplicationController |
| 2 | respond_to :html | 2 | respond_to :html |
| 3 | 3 | ||
| 4 | + before_filter :event_filter, only: :index | ||
| 5 | + | ||
| 4 | def index | 6 | def index |
| 5 | @groups = Group.where(id: current_user.projects.pluck(:group_id)) | 7 | @groups = Group.where(id: current_user.projects.pluck(:group_id)) |
| 6 | @projects = current_user.projects_with_events | 8 | @projects = current_user.projects_with_events |
| 7 | @projects = @projects.page(params[:page]).per(30) | 9 | @projects = @projects.page(params[:page]).per(30) |
| 8 | 10 | ||
| 9 | - @events = Event.in_projects(current_user.project_ids).limit(20).offset(params[:offset] || 0) | 11 | + @events = Event.in_projects(current_user.project_ids) |
| 12 | + @events = @event_filter.apply_filter(@events) | ||
| 13 | + @events = @events.limit(20).offset(params[:offset] || 0) | ||
| 14 | + | ||
| 10 | @last_push = current_user.recent_push | 15 | @last_push = current_user.recent_push |
| 11 | 16 | ||
| 12 | respond_to do |format| | 17 | respond_to do |format| |
| @@ -34,4 +39,8 @@ class DashboardController < ApplicationController | @@ -34,4 +39,8 @@ class DashboardController < ApplicationController | ||
| 34 | format.atom { render layout: false } | 39 | format.atom { render layout: false } |
| 35 | end | 40 | end |
| 36 | end | 41 | end |
| 42 | + | ||
| 43 | + def event_filter | ||
| 44 | + @event_filter ||= EventFilter.new(params[:event_filter]) | ||
| 45 | + end | ||
| 37 | end | 46 | end |
app/helpers/application_helper.rb
| @@ -36,7 +36,7 @@ module ApplicationHelper | @@ -36,7 +36,7 @@ module ApplicationHelper | ||
| 36 | else | 36 | else |
| 37 | gravatar_prefix = request.ssl? ? "https://secure" : "http://www" | 37 | gravatar_prefix = request.ssl? ? "https://secure" : "http://www" |
| 38 | user_email.strip! | 38 | user_email.strip! |
| 39 | - "#{gravatar_prefix}.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email.downcase)}?s=#{size}&d=identicon" | 39 | + "#{gravatar_prefix}.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email.downcase)}?s=#{size}&d=mm" |
| 40 | end | 40 | end |
| 41 | end | 41 | end |
| 42 | 42 |
app/helpers/events_helper.rb
| @@ -33,4 +33,22 @@ module EventsHelper | @@ -33,4 +33,22 @@ module EventsHelper | ||
| 33 | image_tag event_image_path | 33 | image_tag event_image_path |
| 34 | end | 34 | end |
| 35 | end | 35 | end |
| 36 | + | ||
| 37 | + def event_filter_link key, tooltip | ||
| 38 | + key = key.to_s | ||
| 39 | + | ||
| 40 | + filter = @event_filter.options key | ||
| 41 | + | ||
| 42 | + inactive = if @event_filter.active? key | ||
| 43 | + nil | ||
| 44 | + else | ||
| 45 | + 'inactive' | ||
| 46 | + end | ||
| 47 | + | ||
| 48 | + content_tag :div, class: "filter_icon #{inactive}" do | ||
| 49 | + link_to dashboard_path(event_filter: filter), class: 'has_tooltip', 'data-original-title' => tooltip do | ||
| 50 | + image_tag "event_filter_#{key}.png" | ||
| 51 | + end | ||
| 52 | + end | ||
| 53 | + end | ||
| 36 | end | 54 | end |
app/views/dashboard/index.html.haml
| @@ -3,10 +3,17 @@ | @@ -3,10 +3,17 @@ | ||
| 3 | .activities.span8 | 3 | .activities.span8 |
| 4 | = render "events/event_last_push", event: @last_push | 4 | = render "events/event_last_push", event: @last_push |
| 5 | = render 'shared/no_ssh' | 5 | = render 'shared/no_ssh' |
| 6 | + | ||
| 7 | + .event_filter | ||
| 8 | + = event_filter_link EventFilter.push, 'Push events' | ||
| 9 | + = event_filter_link EventFilter.merged, 'Merge events' | ||
| 10 | + = event_filter_link EventFilter.comments, 'Comments' | ||
| 11 | + = event_filter_link EventFilter.team, 'Team' | ||
| 12 | + | ||
| 6 | - if @events.any? | 13 | - if @events.any? |
| 7 | .content_list= render @events | 14 | .content_list= render @events |
| 8 | - else | 15 | - else |
| 9 | - %h4.nothing_here_message Projects activity will be displayed here | 16 | + %p.nothing_here_message Projects activity will be displayed here |
| 10 | .loading.hide | 17 | .loading.hide |
| 11 | .side | 18 | .side |
| 12 | - if @groups.present? | 19 | - if @groups.present? |
| @@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
| 1 | +class EventFilter | ||
| 2 | + attr_accessor :params | ||
| 3 | + | ||
| 4 | + class << self | ||
| 5 | + def default_filter | ||
| 6 | + %w{ push issues merge_requests team} | ||
| 7 | + end | ||
| 8 | + | ||
| 9 | + def push | ||
| 10 | + 'push' | ||
| 11 | + end | ||
| 12 | + | ||
| 13 | + def merged | ||
| 14 | + 'merged' | ||
| 15 | + end | ||
| 16 | + | ||
| 17 | + def comments | ||
| 18 | + 'comments' | ||
| 19 | + end | ||
| 20 | + | ||
| 21 | + def team | ||
| 22 | + 'team' | ||
| 23 | + end | ||
| 24 | + end | ||
| 25 | + | ||
| 26 | + def initialize params | ||
| 27 | + @params = if params | ||
| 28 | + params.dup | ||
| 29 | + else | ||
| 30 | + []#EventFilter.default_filter | ||
| 31 | + end | ||
| 32 | + end | ||
| 33 | + | ||
| 34 | + def apply_filter events | ||
| 35 | + return events unless params.present? | ||
| 36 | + | ||
| 37 | + filter = params.dup | ||
| 38 | + | ||
| 39 | + actions = [] | ||
| 40 | + actions << Event::Pushed if filter.include? 'push' | ||
| 41 | + actions << Event::Merged if filter.include? 'merged' | ||
| 42 | + | ||
| 43 | + if filter.include? 'team' | ||
| 44 | + actions << Event::Joined | ||
| 45 | + actions << Event::Left | ||
| 46 | + end | ||
| 47 | + | ||
| 48 | + actions << Event::Commented if filter.include? 'comments' | ||
| 49 | + | ||
| 50 | + events = events.where(action: actions) | ||
| 51 | + end | ||
| 52 | + | ||
| 53 | + def options key | ||
| 54 | + filter = params.dup | ||
| 55 | + | ||
| 56 | + if filter.include? key | ||
| 57 | + filter.delete key | ||
| 58 | + else | ||
| 59 | + filter << key | ||
| 60 | + end | ||
| 61 | + | ||
| 62 | + filter | ||
| 63 | + end | ||
| 64 | + | ||
| 65 | + def active? key | ||
| 66 | + params.include? key | ||
| 67 | + end | ||
| 68 | +end |