summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Denisov <1101.debian@gmail.com>2012-12-03 02:29:07 +0200
committerAlex Denisov <1101.debian@gmail.com>2013-01-09 19:30:20 +0000
commit97d17cf835ebe5121330a3775ae58bcab792851e (patch)
treeb5119e577d097c7cf3bced028a8e584a91dc0c09
parentb255c3c44b849510e19be88833bb73425b8d0e9d (diff)
downloadgitlab-ce-97d17cf835ebe5121330a3775ae58bcab792851e.tar.gz
Event filters stores at cookies.
-rw-r--r--app/assets/javascripts/dashboard.js27
-rw-r--r--app/controllers/dashboard_controller.rb3
-rw-r--r--app/helpers/events_helper.rb5
-rw-r--r--app/views/dashboard/index.html.haml1
-rw-r--r--features/dashboard/event_filters.feature19
-rw-r--r--features/steps/dashboard/dashboard_event_filters.rb12
6 files changed, 56 insertions, 11 deletions
diff --git a/app/assets/javascripts/dashboard.js b/app/assets/javascripts/dashboard.js
new file mode 100644
index 00000000000..0261926af2b
--- /dev/null
+++ b/app/assets/javascripts/dashboard.js
@@ -0,0 +1,27 @@
+/**
+ * Init dashboard page
+ *
+ */
+function dashboardPage(){
+ $(".event_filter_link").bind('click',(function(){
+ enableFilter(this.id);
+ }));
+}
+
+function enableFilter(sender_id){
+ var event_filters = $.cookie('event_filter');
+ var filter = sender_id.split('_')[0];
+ if (!event_filters) {
+ event_filters = new Array();
+ } else {
+ event_filters = event_filters.split(',');
+ }
+ var index = event_filters.indexOf(filter);
+ if (index == -1) {
+ event_filters.push(filter);
+ } else {
+ event_filters.splice(index, 1);
+ }
+ $.cookie('event_filter', event_filters.join(','));
+};
+
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 4bd840a07fb..c0ec4708e0a 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -60,6 +60,7 @@ class DashboardController < ApplicationController
end
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
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 85378400e2a..9b9d2a913e9 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -22,9 +22,6 @@ module EventsHelper
def event_filter_link key, tooltip
key = key.to_s
-
- filter = @event_filter.options key
-
inactive = if @event_filter.active? key
nil
else
@@ -32,7 +29,7 @@ module EventsHelper
end
content_tag :div, class: "filter_icon #{inactive}" do
- link_to dashboard_path(event_filter: filter), class: 'has_tooltip', id: "#{key}_event_filter", '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"
end
end
diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml
index d1422bda617..266d66aa6aa 100644
--- a/app/views/dashboard/index.html.haml
+++ b/app/views/dashboard/index.html.haml
@@ -1,3 +1,4 @@
+= javascript_include_tag 'dashboard'
- if @has_authorized_projects
.projects
.activities.span8
diff --git a/features/dashboard/event_filters.feature b/features/dashboard/event_filters.feature
index 050d98951a8..158d3e1cfa9 100644
--- a/features/dashboard/event_filters.feature
+++ b/features/dashboard/event_filters.feature
@@ -12,20 +12,39 @@ Feature: Event filters
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
+ Then I should not see push event
+ And I should see new member event
+ And I should not see merge request event
diff --git a/features/steps/dashboard/dashboard_event_filters.rb b/features/steps/dashboard/dashboard_event_filters.rb
index 03a0bd85e43..bfc053631ab 100644
--- a/features/steps/dashboard/dashboard_event_filters.rb
+++ b/features/steps/dashboard/dashboard_event_filters.rb
@@ -4,27 +4,27 @@ class EventFilters < Spinach::FeatureSteps
include SharedProject
Then 'I should see push event' do
- page.has_selector?('span.pushed').should be_true
+ page.should have_selector('span.pushed')
end
Then 'I should not see push event' do
- page.has_selector?('span.pushed').should be_false
+ page.should_not have_selector('span.pushed')
end
Then 'I should see new member event' do
- page.has_selector?('span.joined').should be_true
+ page.should have_selector('span.joined')
end
And 'I should not see new member event' do
- page.has_selector?('span.joined').should be_false
+ page.should_not have_selector('span.joined')
end
Then 'I should see merge request event' do
- page.has_selector?('span.merged').should be_true
+ page.should have_selector('span.merged')
end
And 'I should not see merge request event' do
- page.has_selector?('span.merged').should be_false
+ page.should_not have_selector('span.merged')
end
And 'this project has push event' do