Commit aca0caa8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #2534 from AlexDenisov/ajax_activities

Reload activities/events on the dashboard page via ajax
parents d27cc91e d7bc1214
$ ->
dashboardPage()
dashboardPage = ->
Pager.init 20, true
$(".event_filter_link").bind "click", (event) ->
event.preventDefault()
toggleFilter $(this)
reloadActivities()
reloadActivities = ->
$(".content_list").html ''
Pager.init 20, true
toggleFilter = (sender) ->
sender.parent().toggleClass "inactive"
event_filters = $.cookie("event_filter")
filter = sender.attr("id").split("_")[0]
if event_filters
event_filters = event_filters.split(",")
else
event_filters = new Array()
index = event_filters.indexOf(filter)
if index is -1
event_filters.push filter
else
event_filters.splice index, 1
$.cookie "event_filter", event_filters.join(",")
...@@ -60,6 +60,7 @@ class DashboardController < ApplicationController ...@@ -60,6 +60,7 @@ class DashboardController < ApplicationController
end end
def event_filter def event_filter
@event_filter ||= EventFilter.new(params[:event_filter]) filters = cookies['event_filter'].split(',') if cookies['event_filter']
@event_filter ||= EventFilter.new(filters)
end end
end end
...@@ -22,9 +22,6 @@ module EventsHelper ...@@ -22,9 +22,6 @@ module EventsHelper
def event_filter_link key, tooltip def event_filter_link key, tooltip
key = key.to_s key = key.to_s
filter = @event_filter.options key
inactive = if @event_filter.active? key inactive = if @event_filter.active? key
nil nil
else else
...@@ -32,7 +29,7 @@ module EventsHelper ...@@ -32,7 +29,7 @@ module EventsHelper
end end
content_tag :div, class: "filter_icon #{inactive}" do content_tag :div, class: "filter_icon #{inactive}" do
link_to dashboard_path(event_filter: filter), class: 'has_tooltip', 'data-original-title' => tooltip do link_to dashboard_path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do
image_tag "event_filter_#{key}.png" image_tag "event_filter_#{key}.png"
end end
end end
......
...@@ -7,5 +7,3 @@ ...@@ -7,5 +7,3 @@
- else - else
= render "zero_authorized_projects" = render "zero_authorized_projects"
:javascript
$(function(){ Pager.init(20, true); });
Feature: Event filters
Background:
Given I sign in as a user
And I own a project
And this project has push event
And this project has new member event
And this project has merge request event
And I visit dashboard page
@javascript
Scenario: I should see all events
Then I should see push event
And I should see new member event
And I should see merge request event
@javascript
Scenario: I should see only pushed events
When I click "push" event filter
Then I should see push event
And I should not see new member event
And I should not see merge request event
@javascript
Scenario: I should see only joined events
When I click "team" event filter
Then I should see new member event
And I should not see push event
And I should not see merge request event
@javascript
Scenario: I should see only merged events
When I click "merge" event filter
Then I should see merge request event
And I should not see push event
And I should not see new member event
@javascript
Scenario: I should see only selected events while page reloaded
When I click "push" event filter
And I visit dashboard page
Then I should see push event
And I should not see new member event
When I click "team" event filter
And I visit dashboard page
Then I should see push event
And I should see new member event
And I should not see merge request event
When I click "push" event filter
Then I should not see push event
And I should see new member event
And I should not see merge request event
class EventFilters < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
Then 'I should see push event' do
page.should have_selector('span.pushed')
end
Then 'I should not see push event' do
page.should_not have_selector('span.pushed')
end
Then 'I should see new member event' do
page.should have_selector('span.joined')
end
And 'I should not see new member event' do
page.should_not have_selector('span.joined')
end
Then 'I should see merge request event' do
page.should have_selector('span.merged')
end
And 'I should not see merge request event' do
page.should_not have_selector('span.merged')
end
And 'this project has push event' do
data = {
before: "0000000000000000000000000000000000000000",
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
ref: "refs/heads/new_design",
user_id: @user.id,
user_name: @user.name,
repository: {
name: @project.name,
url: "localhost/rubinius",
description: "",
homepage: "localhost/rubinius",
private: true
}
}
@event = Event.create(
project: @project,
action: Event::Pushed,
data: data,
author_id: @user.id
)
end
And 'this project has new member event' do
user = create(:user, {name: "John Doe"})
Event.create(
project: @project,
author_id: user.id,
action: Event::Joined
)
end
And 'this project has merge request event' do
merge_request = create :merge_request, author: @user, project: @project
Event.create(
project: @project,
action: Event::Merged,
target_id: merge_request.id,
target_type: "MergeRequest",
author_id: @user.id
)
end
When 'I click "push" event filter' do
click_link("push_event_filter")
end
When 'I click "team" event filter' do
click_link("team_event_filter")
end
When 'I click "merge" event filter' do
click_link("merged_event_filter")
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment