Commit 5d785457 authored by Douwe Maan's avatar Douwe Maan

Clean up overlap between dashboard and explore.

- Split up SnippetsController into separate dashboard and explore sections.
- Use consistent page titles, header titles and sidebars between dashboard and explore sections when signed in or not.
parent 260fcd45
class Dashboard::ProjectsController < Dashboard::ApplicationController
before_action :event_filter
def index
@projects = current_user.authorized_projects.sorted_by_activity.non_archived
@projects = @projects.includes(:namespace)
@last_push = current_user.recent_push
respond_to do |format|
format.html
format.atom do
event_filter
load_events
render layout: false
end
end
end
def starred
@projects = current_user.starred_projects
@projects = @projects.includes(:namespace, :forked_from_project, :tags)
......
class Dashboard::SnippetsController < Dashboard::ApplicationController
def index
@snippets = SnippetsFinder.new.execute(current_user,
filter: :by_user,
user: current_user,
scope: params[:scope]
)
@snippets = @snippets.page(params[:page]).per(PER_PAGE)
end
end
class DashboardController < Dashboard::ApplicationController
before_action :load_projects, except: :activity
before_action :event_filter, only: :activity
respond_to :html
def show
@projects = @projects.includes(:namespace)
@last_push = current_user.recent_push
respond_to do |format|
format.html
format.atom do
event_filter
load_events
render layout: false
end
end
end
def merge_requests
@merge_requests = get_merge_requests_collection
@merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE)
......@@ -50,10 +35,6 @@ class DashboardController < Dashboard::ApplicationController
protected
def load_projects
@projects = current_user.authorized_projects.sorted_by_activity.non_archived
end
def load_events
project_ids =
if params[:filter] == "starred"
......
class Explore::ApplicationController < ApplicationController
skip_before_action :authenticate_user!, :reject_blocked
layout 'explore'
end
class Explore::GroupsController < Explore::ApplicationController
skip_before_action :authenticate_user!,
:reject_blocked, :set_current_user_for_observers
def index
@groups = GroupsFinder.new.execute(current_user)
@groups = @groups.search(params[:search]) if params[:search].present?
......
class Explore::ProjectsController < Explore::ApplicationController
skip_before_action :authenticate_user!,
:reject_blocked
def index
@projects = ProjectsFinder.new.execute(current_user)
@tags = @projects.tags_on(:tags)
......
class Explore::SnippetsController < Explore::ApplicationController
def index
@snippets = SnippetsFinder.new.execute(current_user, filter: :all)
@snippets = @snippets.page(params[:page]).per(PER_PAGE)
end
end
......@@ -14,6 +14,10 @@ class GroupsController < Groups::ApplicationController
layout :determine_layout
def index
redirect_to (current_user ? dashboard_groups_path : explore_groups_path)
end
def new
@group = Group.new
end
......
......@@ -10,6 +10,10 @@ class ProjectsController < ApplicationController
layout :determine_layout
def index
redirect_to (current_user ? root_path : explore_root_path)
end
def new
@project = Project.new
end
......
......@@ -6,10 +6,10 @@
#
# For users who haven't customized the setting, we simply delegate to
# `DashboardController#show`, which is the default.
class RootController < DashboardController
class RootController < Dashboard::ProjectsController
before_action :redirect_to_custom_dashboard, only: [:show]
def show
def index
super
end
......@@ -20,6 +20,7 @@ class RootController < DashboardController
case current_user.dashboard
when 'stars'
flash.keep
redirect_to starred_dashboard_projects_path
else
return
......
......@@ -24,13 +24,9 @@ class SnippetsController < ApplicationController
scope: params[:scope] }).
page(params[:page]).per(PER_PAGE)
if @user == current_user
render 'current_user_index'
else
render 'user_index'
end
render 'index'
else
@snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE)
redirect_to (current_user ? dashboard_snippets_path : explore_snippets_path)
end
end
......
%ul.center-top-menu
= nav_link(page: [dashboard_groups_path]) do
= nav_link(page: dashboard_groups_path) do
= link_to dashboard_groups_path, title: 'Your groups', data: {placement: 'right'} do
Your Groups
= nav_link(page: [explore_groups_path]) do
= nav_link(page: explore_groups_path) do
= link_to explore_groups_path, title: 'Explore groups', data: {placement: 'bottom'} do
Explore Groups
%ul.center-top-menu
= nav_link(path: ['dashboard#show', 'root#show']) do
= link_to dashboard_path, title: 'Home', class: 'shortcuts-activity', data: {placement: 'right'} do
= nav_link(path: ['projects#index', 'root#index']) do
= link_to dashboard_projects_path, title: 'Home', class: 'shortcuts-activity', data: {placement: 'right'} do
Your Projects
= nav_link(page: starred_dashboard_projects_path) do
= link_to starred_dashboard_projects_path, title: 'Starred Projects', data: {placement: 'right'} do
......
%ul.center-top-menu
= nav_link(page: dashboard_snippets_path, html_options: {class: 'home'}) do
= link_to dashboard_snippets_path, title: 'Your snippets', data: {placement: 'right'} do
Your Snippets
= nav_link(page: explore_snippets_path) do
= link_to explore_snippets_path, title: 'Explore snippets', data: {placement: 'right'} do
Explore Snippets
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, dashboard_url(format: :atom, private_token: current_user.private_token), title: "All activity")
= auto_discovery_link_tag(:atom, dashboard_projects_url(format: :atom, private_token: current_user.private_token), title: "All activity")
- page_title "Activity"
- header_title "Activity", activity_dashboard_path
= render 'dashboard/activity_head'
%section.activities
......
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Activity"
xml.link href: dashboard_url(format: :atom, private_token: current_user.try(:private_token)), rel: "self", type: "application/atom+xml"
xml.link href: dashboard_url, rel: "alternate", type: "text/html"
xml.id dashboard_url
xml.link href: dashboard_projects_url(format: :atom, private_token: current_user.try(:private_token)), rel: "self", type: "application/atom+xml"
xml.link href: dashboard_projects_url, rel: "alternate", type: "text/html"
xml.id dashboard_projects_url
xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any?
@events.each do |event|
......
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, dashboard_url(format: :atom, private_token: current_user.private_token), title: "All activity")
= auto_discovery_link_tag(:atom, dashboard_projects_url(format: :atom, private_token: current_user.private_token), title: "All activity")
- page_title "Projects"
- header_title "Projects", root_path
- header_title "Projects", (current_user ? root_path : explore_root_path)
= render 'dashboard/projects_head'
- if @last_push
......
- page_title "Starred Projects"
- header_title "Projects", (current_user ? root_path : explore_root_path)
- header_title "Projects", projects_path
= render 'dashboard/projects_head'
- if @projects.any?
= render 'dashboard/projects'
= render 'projects'
- else
%h3 You don't have starred projects yet
%p.slead Visit project page and press on star icon and it will appear on this page.
- page_title "Your Snippets"
= render 'head'
- page_title "Snippets"
- header_title "Snippets", dashboard_snippets_path
= render 'dashboard/snippets_head'
.gray-content-block
.pull-right
......@@ -11,26 +13,26 @@
%ul.nav.nav-tabs.prepend-top-20
= nav_tab :scope, nil do
= link_to user_snippets_path(@user) do
= link_to dashboard_snippets_path do
All
%span.badge
= @user.snippets.count
= current_user.snippets.count
= nav_tab :scope, 'are_private' do
= link_to user_snippets_path(@user, scope: 'are_private') do
= link_to dashboard_snippets_path(scope: 'are_private') do
Private
%span.badge
= @user.snippets.are_private.count
= current_user.snippets.are_private.count
= nav_tab :scope, 'are_internal' do
= link_to user_snippets_path(@user, scope: 'are_internal') do
= link_to dashboard_snippets_path(scope: 'are_internal') do
Internal
%span.badge
= @user.snippets.are_internal.count
= current_user.snippets.are_internal.count
= nav_tab :scope, 'are_public' do
= link_to user_snippets_path(@user, scope: 'are_public') do
= link_to dashboard_snippets_path(scope: 'are_public') do
Public
%span.badge
= @user.snippets.are_public.count
= current_user.snippets.are_public.count
.my-snippets
= render 'snippets'
= render 'snippets/snippets'
.explore-title
%h3
Explore GitLab
%p.lead
Discover projects, groups and snippets. Share your projects with others
%br
- page_title "Groups"
- header_title "Groups", (current_user ? dashboard_groups_path : explore_groups_path)
- page_title "Groups"
- header_title "Groups", dashboard_groups_path
- if current_user
= render 'dashboard/groups_head'
- else
= render 'explore/head'
.gray-content-block.clearfix
.pull-left
= form_tag explore_groups_path, method: :get, class: 'form-inline form-tiny' do |f|
......
- page_title "Projects"
- page_title "Projects"
- header_title "Projects", root_path
- if current_user
= render 'dashboard/projects_head'
- else
= render 'explore/head'
.gray-content-block.clearfix
= render 'filter'
= render 'projects', projects: @projects
......
- page_title "Starred Projects"
- page_title "Projects"
- header_title "Projects", root_path
- if current_user
= render 'dashboard/projects_head'
- else
= render 'explore/head'
.explore-trending-block
.gray-content-block
......
- page_title "Trending Projects"
- page_title "Projects"
- header_title "Projects", root_path
- if current_user
= render 'dashboard/projects_head'
- else
.explore-title
%h3
Explore GitLab
%p.lead
Discover projects and groups. Share your projects with others
%br
= render 'explore/head'
.explore-trending-block
.gray-content-block
.pull-right
......
- page_title "Snippets"
- header_title "Snippets", snippets_path
- if current_user
= render 'dashboard/snippets_head'
- else
= render 'explore/head'
.gray-content-block
- if current_user
.pull-right
= link_to new_snippet_path, class: "btn btn-new", title: "New Snippet" do
Add new snippet
.oneline
Public snippets created by you and other users are listed here
= render 'snippets/snippets'
......@@ -6,10 +6,14 @@
= brand_header_logo
.gitlab-text-container
%h3 GitLab
- if defined?(sidebar) && sidebar
= render "layouts/nav/#{sidebar}"
- elsif current_user
= render 'layouts/nav/dashboard'
- else
= render 'layouts/nav/explore'
.collapse-nav
= render partial: 'layouts/collapse_button'
- if current_user
......
- page_title "Explore"
- if current_user
- unless @header_title
- header_title "Projects", (current_user ? root_path : explore_root_path)
- else
- unless current_user
- header_title "Explore GitLab", explore_root_path
- sidebar "dashboard"
= render template: "layouts/application"
%ul.nav.nav-sidebar
= nav_link(path: ['dashboard#show', 'root#show', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do
= link_to (current_user ? root_path : explore_root_path), title: 'Home', class: 'shortcuts-activity', data: {placement: 'right'} do
= nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do
= link_to root_path, title: 'Projects', data: {placement: 'right'} do
= icon('home fw')
%span
Projects
= nav_link(path: 'dashboard#activity') do
= link_to activity_dashboard_path, title: 'Activity', data: {placement: 'right'} do
= link_to activity_dashboard_path, class: 'shortcuts-activity', title: 'Activity', data: {placement: 'right'} do
= icon('dashboard fw')
%span
Activity
= nav_link(controller: :groups) do
= link_to (current_user ? dashboard_groups_path : explore_groups_path), title: 'Groups', data: {placement: 'right'} do
= link_to dashboard_groups_path, title: 'Groups', data: {placement: 'right'} do
= icon('group fw')
%span
Groups
- if current_user
= nav_link(controller: :milestones) do
= link_to dashboard_milestones_path, title: 'Milestones', data: {placement: 'right'} do
= icon('clock-o fw')
%span
Milestones
= nav_link(path: 'dashboard#issues') do
= link_to assigned_issues_dashboard_path, title: 'Issues', class: 'shortcuts-issues', data: {placement: 'right'} do
= icon('exclamation-circle fw')
%span
Issues
%span.count= current_user.assigned_issues.opened.count
= nav_link(controller: :milestones) do
= link_to dashboard_milestones_path, title: 'Milestones', data: {placement: 'right'} do
= icon('clock-o fw')
%span
Milestones
= nav_link(path: 'dashboard#issues') do
= link_to assigned_issues_dashboard_path, title: 'Issues', class: 'shortcuts-issues', data: {placement: 'right'} do
= icon('exclamation-circle fw')
%span
Issues
%span.count= current_user.assigned_issues.opened.count
= nav_link(path: 'dashboard#merge_requests') do
= link_to assigned_mrs_dashboard_path, title: 'Merge Requests', class: 'shortcuts-merge_requests', data: {placement: 'right'} do
= icon('tasks fw')
......@@ -33,16 +32,15 @@
Merge Requests
%span.count= current_user.assigned_merge_requests.opened.count
= nav_link(controller: :snippets) do
= link_to (current_user ? user_snippets_path(current_user) : snippets_path), title: 'Your snippets', data: {placement: 'right'} do
= link_to dashboard_snippets_path, title: 'Your snippets', data: {placement: 'right'} do
= icon('clipboard fw')
%span
Snippets
- if current_user
= nav_link(controller: :profile) do
= link_to profile_path, title: 'Profile settings', data: {toggle: 'tooltip', placement: 'bottom'} do
= icon('user fw')
%span
Profile Settings
= nav_link(controller: :profile) do
= link_to profile_path, title: 'Profile settings', data: {placement: 'bottom'} do
= icon('user fw')
%span
Profile Settings
= nav_link(controller: :help) do
= link_to help_path, title: 'Help', data: {placement: 'right'} do
= icon('question-circle fw')
......
%ul.nav.nav-sidebar
= nav_link(path: ['dashboard#show', 'root#show', 'projects#trending', 'projects#starred', 'projects#index'], html_options: {class: 'home'}) do
= link_to explore_root_path, title: 'Projects', data: {placement: 'right'} do
= icon('home fw')
%span
Projects
= nav_link(controller: :groups) do
= link_to explore_groups_path, title: 'Groups', data: {placement: 'right'} do
= icon('group fw')
%span
Groups
= nav_link(controller: :snippets) do
= link_to explore_snippets_path, title: 'Snippets', data: {placement: 'right'} do
= icon('clipboard fw')
%span
Snippets
= nav_link(controller: :help) do
= link_to help_path, title: 'Help', data: {placement: 'right'} do
= icon('question-circle fw')
%span
Help
- page_title 'Snippets'
- if current_user
- header_title "Snippets", user_snippets_path(current_user)
- else
- header_title 'Snippets', snippets_path
- sidebar "dashboard"
- header_title "Snippets", snippets_path
= render template: "layouts/application"
- page_title "Activity"
= render 'projects/activity'
%ul.center-top-menu
= nav_link(page: user_snippets_path(current_user), html_options: {class: 'home'}) do
= link_to user_snippets_path(current_user), title: 'Your snippets', data: {placement: 'right'} do
Your Snippets
= nav_link(page: snippets_path) do
= link_to snippets_path, title: 'Explore snippets', data: {placement: 'right'} do
Explore Snippets
- page_title "Public Snippets"
- if current_user
= render 'head'
.gray-content-block
- if current_user
.pull-right
= link_to new_snippet_path, class: "btn btn-new", title: "New Snippet" do
Add new snippet
.oneline
Public snippets created by you and other users are listed here
- page_title "By #{@user.name}", "Snippets"
%ol.breadcrumb
%li
= link_to snippets_path do
Snippets
%li
= @user.name
.pull-right.hidden-xs
= link_to user_path(@user) do
#{@user.name} profile page
= render 'snippets'
......@@ -20,10 +20,10 @@
.back-link
- if @snippet.author == current_user
= link_to user_snippets_path(current_user) do
= link_to dashboard_snippets_path do
&larr; your snippets
- else
= link_to snippets_path do
= link_to explore_snippets_path do
&larr; explore snippets
.file-holder
......
- page_title "Snippets", @user.name
%ol.breadcrumb
%li
= link_to snippets_path do
Snippets
%li
= @user.name
.pull-right.hidden-xs
= link_to user_path(@user) do
#{@user.name} profile page
= render 'snippets'
......@@ -134,6 +134,7 @@ Gitlab::Application.routes.draw do
end
resources :groups, only: [:index]
resources :snippets, only: [:index]
root to: 'projects#trending'
end
......@@ -252,24 +253,25 @@ Gitlab::Application.routes.draw do
#
# Dashboard Area
#
resource :dashboard, controller: 'dashboard', only: [:show] do
member do
get :issues
get :merge_requests
get :activity
end
resource :dashboard, controller: 'dashboard', only: [] do
get :issues
get :merge_requests
get :activity
scope module: :dashboard do
resources :milestones, only: [:index, :show]
resources :groups, only: [:index]
resources :snippets, only: [:index]
resources :projects, only: [] do
resources :projects, only: [:index] do
collection do
get :starred
end
end
end
root to: "dashboard/projects#index"
end
#
......@@ -293,7 +295,7 @@ Gitlab::Application.routes.draw do
end
end
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
resources :projects, constraints: { id: /[^\/]+/ }, only: [:index, :new, :create]
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
......@@ -301,7 +303,7 @@ Gitlab::Application.routes.draw do
get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
end
root to: "root#show"
root to: "root#index"
#
# Project Area
......
......@@ -4,7 +4,7 @@ class Spinach::Features::SnippetsUser < Spinach::FeatureSteps
include SharedSnippet
step 'I visit my snippets page' do
visit user_snippets_path(current_user)
visit dashboard_snippets_path
end
step 'I should see "Personal snippet one" in snippets' do
......
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