From e3efce9237ea15c7b1c609a364d3dac927ac6286 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Thu, 10 Mar 2016 14:29:38 +0100
Subject: [PATCH] Move group activity feed to separate page for consistency
 with dashboard and project pages

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 CHANGELOG                                   |  1 +
 app/assets/javascripts/dispatcher.js.coffee |  3 ++-
 app/controllers/groups_controller.rb        |  6 ++++--
 app/views/groups/_activities.html.haml      | 12 ++++++++++++
 app/views/groups/activity.html.haml         |  9 +++++++++
 app/views/groups/show.html.haml             | 15 +--------------
 app/views/layouts/nav/_group.html.haml      |  7 ++++++-
 config/routes.rb                            |  2 +-
 features/groups.feature                     |  4 ++++
 features/steps/shared/paths.rb              |  4 ++++
 10 files changed, 44 insertions(+), 19 deletions(-)
 create mode 100644 app/views/groups/_activities.html.haml
 create mode 100644 app/views/groups/activity.html.haml

diff --git a/CHANGELOG b/CHANGELOG
index 9474ca50b24..e2846ee48df 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,7 @@ v 8.6.0 (unreleased)
   - Show labels in dashboard and group milestone views
   - Add main language of a project in the list of projects (Tiago Botelho)
   - Add ability to show archived projects on dashboard, explore and group pages
+  - Move group activity to separate page
 
 v 8.5.5
   - Ensure removing a project removes associated Todo entries.
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index 54b28f2dd8d..ee81fee5868 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -74,8 +74,9 @@ class Dispatcher
         shortcut_handler = new ShortcutsNavigation()
 
         new TreeView() if $('#tree-slider').length
-      when 'groups:show'
+      when 'groups:activity'
         new Activities()
+      when 'groups:show'
         shortcut_handler = new ShortcutsNavigation()
       when 'groups:group_members:index'
         new GroupMembers()
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index f05c29e9974..360930f95a8 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -15,7 +15,7 @@ class GroupsController < Groups::ApplicationController
 
   # Load group projects
   before_action :load_projects, except: [:index, :new, :create, :projects, :edit, :update, :autocomplete]
-  before_action :event_filter, only: [:show, :events]
+  before_action :event_filter, only: [:activity]
 
   layout :determine_layout
 
@@ -62,8 +62,10 @@ class GroupsController < Groups::ApplicationController
     end
   end
 
-  def events
+  def activity
     respond_to do |format|
+      format.html
+
       format.json do
         load_events
         pager_json("events/_events", @events.count)
diff --git a/app/views/groups/_activities.html.haml b/app/views/groups/_activities.html.haml
new file mode 100644
index 00000000000..dc76599b776
--- /dev/null
+++ b/app/views/groups/_activities.html.haml
@@ -0,0 +1,12 @@
+.hidden-xs
+  = render "events/event_last_push", event: @last_push
+
+.nav-block
+  - if current_user
+    .controls
+      = link_to dashboard_projects_path(:atom, { private_token: current_user.private_token }), class: 'btn rss-btn' do
+        %i.fa.fa-rss
+  = render 'shared/event_filter'
+
+.content_list
+= spinner
diff --git a/app/views/groups/activity.html.haml b/app/views/groups/activity.html.haml
new file mode 100644
index 00000000000..10b432ef03e
--- /dev/null
+++ b/app/views/groups/activity.html.haml
@@ -0,0 +1,9 @@
+= content_for :meta_tags do
+  - if current_user
+    = auto_discovery_link_tag(:atom, group_url(@group, format: :atom, private_token: current_user.private_token), title: "#{@group.name} activity")
+
+- page_title    "Activity"
+- header_title  "Activity", activity_dashboard_path
+
+%section.activities
+  = render 'activities'
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index 6148d8cb3d2..3cf0a4baacd 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -30,26 +30,13 @@
 
   %ul.nav-links
     %li.active
-      = link_to "#activity", 'data-toggle' => 'tab' do
-        Activity
-    %li
       = link_to "#projects", 'data-toggle' => 'tab' do
         Projects
 
 - if can?(current_user, :read_group, @group)
   %div{ class: container_class }
     .tab-content
-      .tab-pane.active#activity
-        .activity-filter-block
-          - if current_user
-            = render "events/event_last_push", event: @last_push
-
-            = render 'shared/event_filter'
-
-        .content_list{data: {href: events_group_path}}
-        = spinner
-
-      .tab-pane#projects
+      .tab-pane.active#projects
         = render "projects", projects: @projects
 
 - else
diff --git a/app/views/layouts/nav/_group.html.haml b/app/views/layouts/nav/_group.html.haml
index e5e2a59eaed..59411ae1da1 100644
--- a/app/views/layouts/nav/_group.html.haml
+++ b/app/views/layouts/nav/_group.html.haml
@@ -9,10 +9,15 @@
 
   = nav_link(path: 'groups#show', html_options: {class: 'home'}) do
     = link_to group_path(@group), title: 'Home' do
-      = icon('dashboard fw')
+      = icon('group fw')
       %span
         Group
   - if can?(current_user, :read_group, @group)
+    = nav_link(path: 'groups#activity') do
+      = link_to activity_group_path(@group), title: 'Activity' do
+        = icon('dashboard fw')
+        %span
+          Activity
     - if current_user
       = nav_link(controller: [:group, :milestones]) do
         = link_to group_milestones_path(@group), title: 'Milestones' do
diff --git a/config/routes.rb b/config/routes.rb
index a918b5bd3f0..869fca03ec4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -382,7 +382,7 @@ Rails.application.routes.draw do
       get :issues
       get :merge_requests
       get :projects
-      get :events
+      get :activity
     end
 
     scope module: :groups do
diff --git a/features/groups.feature b/features/groups.feature
index a60c3860b83..419a5d3963d 100644
--- a/features/groups.feature
+++ b/features/groups.feature
@@ -15,6 +15,10 @@ Feature: Groups
   Scenario: I should see group "Owned" dashboard list
     When I visit group "Owned" page
     Then I should see group "Owned" projects list
+
+  @javascript
+  Scenario: I should see group "Owned" activity feed
+    When I visit group "Owned" activity page
     And I should see projects activity feed
 
   Scenario: I should see group "Owned" issues list
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index da9d1503ebc..2bd8ea745e4 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -27,6 +27,10 @@ module SharedPaths
     visit group_path(Group.find_by(name: "Owned"))
   end
 
+  step 'I visit group "Owned" activity page' do
+    visit activity_group_path(Group.find_by(name: "Owned"))
+  end
+
   step 'I visit group "Owned" issues page' do
     visit issues_group_path(Group.find_by(name: "Owned"))
   end
-- 
GitLab