diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 13b7f02f..f320e819 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,26 +1,15 @@ class DashboardController < ApplicationController respond_to :html - before_filter :projects - before_filter :event_filter, only: :index + before_filter :load_projects + before_filter :event_filter, only: :show - def index + def show @groups = current_user.authorized_groups - @has_authorized_projects = @projects.count > 0 - - @projects = case params[:scope] - when 'personal' then - @projects.personal(current_user) - when 'joined' then - @projects.joined(current_user) - else - @projects - end - @teams = current_user.authorized_teams - - @projects = @projects.page(params[:page]).per(30) + @projects_count = @projects.count + @projects = @projects.limit(20) @events = Event.in_projects(current_user.authorized_projects.pluck(:id)) @events = @event_filter.apply_filter(@events) @@ -35,6 +24,19 @@ class DashboardController < ApplicationController end end + def projects + @projects = case params[:scope] + when 'personal' then + @projects.personal(current_user) + when 'joined' then + @projects.joined(current_user) + else + @projects + end + + @projects = @projects.page(params[:page]).per(30) + end + # Get authored or assigned open merge requests def merge_requests @merge_requests = current_user.cared_merge_requests @@ -57,7 +59,7 @@ class DashboardController < ApplicationController protected - def projects + def load_projects @projects = current_user.authorized_projects.sorted_by_activity end diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 0baa5b41..c759dffa 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -9,9 +9,9 @@ module DashboardHelper case entity when 'issue' then - dashboard_issues_path(options) + issues_dashboard_path(options) when 'merge_request' - dashboard_merge_requests_path(options) + merge_requests_dashboard_path(options) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c6cb9129..4f0a8071 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -55,7 +55,9 @@ module ProjectsHelper def project_title project if project.group - project.name_with_namespace + content_tag :span do + link_to(project.group.name, group_path(project.group)) + " / " + project.name + end else project.name end diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index 6c1304ee..f2acd2b0 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -2,19 +2,12 @@ %h5.title Projects %small - (#{projects.total_count}) + (#{@projects_count}) - if current_user.can_create_project? %span.right = link_to new_project_path, class: "btn very_small info" do %i.icon-plus New Project - %ul.nav.nav-projects-tabs - = nav_tab :scope, nil do - = link_to "All", dashboard_path - = nav_tab :scope, 'personal' do - = link_to "Personal", dashboard_path(scope: 'personal') - = nav_tab :scope, 'joined' do - = link_to "Joined", dashboard_path(scope: 'joined') %ul.well-list - projects.each do |project| @@ -33,4 +26,6 @@ - if projects.blank? %li %h3.nothing_here_message There are no projects here. - .bottom= paginate projects, theme: "gitlab" + - if @projects_count > 20 + %li.bottom + %strong= link_to "show all projects", projects_dashboard_path diff --git a/app/views/dashboard/issues.atom.builder b/app/views/dashboard/issues.atom.builder index 28bdc5ed..0f0f3466 100644 --- a/app/views/dashboard/issues.atom.builder +++ b/app/views/dashboard/issues.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{current_user.name} issues" - xml.link :href => dashboard_issues_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml" - xml.link :href => dashboard_issues_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html" - xml.id dashboard_issues_url(:private_token => current_user.private_token) + xml.link :href => issues_dashboard_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml" + xml.link :href => issues_dashboard_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html" + xml.id issues_dashboard_url(:private_token => current_user.private_token) xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? @issues.each do |issue| diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml new file mode 100644 index 00000000..e6c710e6 --- /dev/null +++ b/app/views/dashboard/projects.html.haml @@ -0,0 +1,56 @@ +%h3.page_title + Projects + %span + (#{@projects.total_count}) + - if current_user.can_create_project? + %span.right + = link_to new_project_path, class: "btn very_small info" do + %i.icon-plus + New Project + + +%hr +.row + .span3 + %ul.nav.nav-pills.nav-stacked + = nav_tab :scope, nil do + = link_to "All", projects_dashboard_path + = nav_tab :scope, 'personal' do + = link_to "Personal", projects_dashboard_path(scope: 'personal') + = nav_tab :scope, 'joined' do + = link_to "Joined", projects_dashboard_path(scope: 'joined') + + .span9 + = form_tag projects_dashboard_path, method: 'get' do + %fieldset.dashboard-search-filter + = hidden_field_tag "scope", params[:scope] + = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' } + = button_tag type: 'submit', class: 'btn' do + %i.icon-search + + %ul.well-list + - @projects.each do |project| + %li.clearfix + .left + = link_to project_path(project), class: dom_class(project) do + - if project.namespace + = project.namespace.human_name + \/ + %strong.well-title + = truncate(project.name, length: 25) + %br + %small.light + %strong Last activity: + %span= project_last_activity(project) + .right.light + - if project.owner == current_user + %i.icon-wrench + - tm = project.team.get_tm(current_user.id) + - if tm + = tm.project_access_human + + - if @projects.blank? + %li + %h3.nothing_here_message There are no projects here. + .bottom= paginate @projects, theme: "gitlab" + diff --git a/app/views/dashboard/index.atom.builder b/app/views/dashboard/show.atom.builder similarity index 100% rename from app/views/dashboard/index.atom.builder rename to app/views/dashboard/show.atom.builder diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/show.html.haml similarity index 100% rename from app/views/dashboard/index.html.haml rename to app/views/dashboard/show.html.haml diff --git a/app/views/dashboard/index.js.haml b/app/views/dashboard/show.js.haml similarity index 100% rename from app/views/dashboard/index.js.haml rename to app/views/dashboard/show.js.haml diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder index 5bd07bcd..701747bd 100644 --- a/app/views/groups/issues.atom.builder +++ b/app/views/groups/issues.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{@user.name} issues" - xml.link :href => dashboard_issues_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml" - xml.link :href => dashboard_issues_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html" - xml.id dashboard_issues_url(:private_token => @user.private_token) + xml.link :href => issues_dashboard_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml" + xml.link :href => issues_dashboard_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html" + xml.id issues_dashboard_url(:private_token => @user.private_token) xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? @issues.each do |issue| diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 88da5c98..261a8608 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,14 +6,17 @@ = render "layouts/head_panel", title: "Dashboard" .container %ul.main_menu - = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do + = nav_link(path: 'dashboard#show', html_options: {class: 'home'}) do = link_to "Home", root_path, title: "Home" + = nav_link(path: 'dashboard#projects') do + = link_to projects_dashboard_path do + Projects = nav_link(path: 'dashboard#issues') do - = link_to dashboard_issues_path do + = link_to issues_dashboard_path do Issues %span.count= current_user.assigned_issues.opened.count = nav_link(path: 'dashboard#merge_requests') do - = link_to dashboard_merge_requests_path do + = link_to merge_requests_dashboard_path do Merge Requests %span.count= current_user.cared_merge_requests.opened.count = nav_link(path: 'search#show') do diff --git a/config/routes.rb b/config/routes.rb index 5ae4c808..7ffa081a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -118,9 +118,13 @@ Gitlab::Application.routes.draw do # # Dashboard Area # - get "dashboard" => "dashboard#index" - get "dashboard/issues" => "dashboard#issues" - get "dashboard/merge_requests" => "dashboard#merge_requests" + resource :dashboard, controller: "dashboard" do + member do + get :projects + get :issues + get :merge_requests + end + end # # Groups Area @@ -284,5 +288,5 @@ Gitlab::Application.routes.draw do end end - root to: "dashboard#index" + root to: "dashboard#show" end diff --git a/features/dashboard/projects.feature b/features/dashboard/projects.feature new file mode 100644 index 00000000..17022dab --- /dev/null +++ b/features/dashboard/projects.feature @@ -0,0 +1,8 @@ +Feature: Dashboard + Background: + Given I sign in as a user + And I own project "Shop" + And I visit dashboard projects page + + Scenario: I should see issues list + Then I should see projects list diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 4bcefba7..8c13ad0e 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -63,6 +63,12 @@ class Dashboard < Spinach::FeatureSteps @project.team << [current_user, :master] end + Then 'I should see projects list' do + @user.authorized_projects.all.each do |project| + page.should have_link project.name_with_namespace + end + end + Then 'I should see groups list' do Group.all.each do |group| page.should have_link group.name diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index e397ff87..42ef40d6 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -33,12 +33,16 @@ module SharedPaths visit dashboard_path end + Given 'I visit dashboard projects page' do + visit projects_dashboard_path + end + Given 'I visit dashboard issues page' do - visit dashboard_issues_path + visit issues_dashboard_path end Given 'I visit dashboard merge requests page' do - visit dashboard_merge_requests_path + visit merge_requests_dashboard_path end Given 'I visit dashboard search page' do diff --git a/spec/requests/atom/dashboard_issues_spec.rb b/spec/requests/atom/dashboard_issues_spec.rb index 8ce64cd4..6f5d51d1 100644 --- a/spec/requests/atom/dashboard_issues_spec.rb +++ b/spec/requests/atom/dashboard_issues_spec.rb @@ -10,7 +10,7 @@ describe "Dashboard Issues Feed" do describe "atom feed" do it "should render atom feed via private token" do - visit dashboard_issues_path(:atom, private_token: user.private_token) + visit issues_dashboard_path(:atom, private_token: user.private_token) page.response_headers['Content-Type'].should have_content("application/atom+xml") page.body.should have_selector("title", text: "#{user.name} issues") diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 57fd70e7..5ad8165e 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -146,14 +146,14 @@ describe KeysController, "routing" do end end -# dashboard GET /dashboard(.:format) dashboard#index +# dashboard GET /dashboard(.:format) dashboard#show # dashboard_issues GET /dashboard/issues(.:format) dashboard#issues # dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests -# root / dashboard#index +# root / dashboard#show describe DashboardController, "routing" do it "to #index" do - get("/dashboard").should route_to('dashboard#index') - get("/").should route_to('dashboard#index') + get("/dashboard").should route_to('dashboard#show') + get("/").should route_to('dashboard#show') end it "to #issues" do