debian-mirror-gitlab/app/controllers/root_controller.rb

38 lines
997 B
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
# RootController
#
# This controller exists solely to handle requests to `root_url`. When a user is
# logged in and has customized their `dashboard` setting, they will be
# redirected to their preferred location.
#
# For users who haven't customized the setting, we simply delegate to
# `DashboardController#show`, which is the default.
2015-09-25 12:07:36 +05:30
class RootController < Dashboard::ProjectsController
before_action :redirect_to_custom_dashboard, only: [:index]
2015-09-11 14:41:01 +05:30
2015-09-25 12:07:36 +05:30
def index
2015-09-11 14:41:01 +05:30
super
end
private
def redirect_to_custom_dashboard
return unless current_user
case current_user.dashboard
when 'stars'
2015-09-25 12:07:36 +05:30
flash.keep
2015-09-11 14:41:01 +05:30
redirect_to starred_dashboard_projects_path
2015-10-24 18:46:33 +05:30
when 'project_activity'
redirect_to activity_dashboard_path
when 'starred_project_activity'
redirect_to activity_dashboard_path(filter: 'starred')
2016-06-02 11:05:42 +05:30
when 'groups'
redirect_to dashboard_groups_path
when 'todos'
redirect_to dashboard_todos_path
2015-09-11 14:41:01 +05:30
else
return
end
end
end