From bd3b677b86d7c76788420e94862836343ac5c841 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 12:34:27 +0200 Subject: [PATCH 1/6] Add projects page to dashboard. Remove projects pagination on dashboard --- app/controllers/dashboard_controller.rb | 32 +++++++++-------- app/views/dashboard/_projects.html.haml | 13 +++---- app/views/dashboard/projects.html.haml | 46 +++++++++++++++++++++++++ app/views/layouts/application.html.haml | 3 ++ config/routes.rb | 1 + 5 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 app/views/dashboard/projects.html.haml diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 13b7f02fdb8..13d8000873b 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 :load_projects before_filter :event_filter, only: :index def index @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/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index 6c1304ee4a8..d7273fdca34 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", dashboard_projects_path diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml new file mode 100644 index 00000000000..cfbb332a91a --- /dev/null +++ b/app/views/dashboard/projects.html.haml @@ -0,0 +1,46 @@ +%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", dashboard_projects_path + = nav_tab :scope, 'personal' do + = link_to "Personal", dashboard_projects_path(scope: 'personal') + = nav_tab :scope, 'joined' do + = link_to "Joined", dashboard_projects_path(scope: 'joined') + + .span9 + = form_tag dashboard_projects_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 + = 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) + %span.right.light + %strong Last activity: + %span= project_last_activity(project) + - if @projects.blank? + %li + %h3.nothing_here_message There are no projects here. + .bottom= paginate @projects, theme: "gitlab" + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 88da5c98c78..0a83be3fd2e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,6 +8,9 @@ %ul.main_menu = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do = link_to "Home", root_path, title: "Home" + = nav_link(path: 'dashboard#projects') do + = link_to dashboard_projects_path do + Projects = nav_link(path: 'dashboard#issues') do = link_to dashboard_issues_path do Issues diff --git a/config/routes.rb b/config/routes.rb index 5ae4c8087c7..6bbcf49ab5c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -119,6 +119,7 @@ Gitlab::Application.routes.draw do # Dashboard Area # get "dashboard" => "dashboard#index" + get "dashboard/projects" => "dashboard#projects" get "dashboard/issues" => "dashboard#issues" get "dashboard/merge_requests" => "dashboard#merge_requests" -- GitLab From 6b01196fb238cb921056ecd8d1572ff2874bf912 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 12:56:20 +0200 Subject: [PATCH 2/6] Dashboard to resource --- app/controllers/dashboard_controller.rb | 4 +-- app/helpers/dashboard_helper.rb | 4 +-- app/views/dashboard/_projects.html.haml | 2 +- app/views/dashboard/issues.atom.builder | 6 ++-- app/views/dashboard/projects.html.haml | 34 ++++++++++++------- .../{index.atom.builder => show.atom.builder} | 0 .../{index.html.haml => show.html.haml} | 0 .../dashboard/{index.js.haml => show.js.haml} | 0 app/views/groups/issues.atom.builder | 6 ++-- app/views/layouts/application.html.haml | 8 ++--- config/routes.rb | 13 ++++--- 11 files changed, 45 insertions(+), 32 deletions(-) rename app/views/dashboard/{index.atom.builder => show.atom.builder} (100%) rename app/views/dashboard/{index.html.haml => show.html.haml} (100%) rename app/views/dashboard/{index.js.haml => show.js.haml} (100%) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 13d8000873b..f320e819e26 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,9 +2,9 @@ class DashboardController < ApplicationController respond_to :html before_filter :load_projects - before_filter :event_filter, only: :index + before_filter :event_filter, only: :show - def index + def show @groups = current_user.authorized_groups @has_authorized_projects = @projects.count > 0 @teams = current_user.authorized_teams diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 0baa5b4108e..c759dffa16e 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/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index d7273fdca34..f2acd2b0b0c 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -28,4 +28,4 @@ %h3.nothing_here_message There are no projects here. - if @projects_count > 20 %li.bottom - %strong= link_to "show all projects", dashboard_projects_path + %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 28bdc5ed814..0f0f3466e92 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 index cfbb332a91a..e6c710e68e9 100644 --- a/app/views/dashboard/projects.html.haml +++ b/app/views/dashboard/projects.html.haml @@ -8,19 +8,20 @@ %i.icon-plus New Project + %hr .row .span3 %ul.nav.nav-pills.nav-stacked = nav_tab :scope, nil do - = link_to "All", dashboard_projects_path + = link_to "All", projects_dashboard_path = nav_tab :scope, 'personal' do - = link_to "Personal", dashboard_projects_path(scope: 'personal') + = link_to "Personal", projects_dashboard_path(scope: 'personal') = nav_tab :scope, 'joined' do - = link_to "Joined", dashboard_projects_path(scope: 'joined') + = link_to "Joined", projects_dashboard_path(scope: 'joined') .span9 - = form_tag dashboard_projects_path, method: 'get' do + = 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' } @@ -29,16 +30,25 @@ %ul.well-list - @projects.each do |project| - %li - = 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) - %span.right.light + %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. 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 5bd07bcd89f..701747bdbc3 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 0a83be3fd2e..261a8608ca4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,17 +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 dashboard_projects_path 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 6bbcf49ab5c..7ffa081ac32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -118,10 +118,13 @@ Gitlab::Application.routes.draw do # # Dashboard Area # - get "dashboard" => "dashboard#index" - get "dashboard/projects" => "dashboard#projects" - 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 @@ -285,5 +288,5 @@ Gitlab::Application.routes.draw do end end - root to: "dashboard#index" + root to: "dashboard#show" end -- GitLab From 070f49fdc550654e538977f4fe6ce4a609521696 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 13:12:30 +0200 Subject: [PATCH 3/6] Make group name a link at header --- app/helpers/projects_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c6cb9129499..4f0a80710cb 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 -- GitLab From 7175b6a7695cf5c14185deccb8850d988f0dba95 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 13:20:23 +0200 Subject: [PATCH 4/6] Fixed dashboard show specs --- spec/requests/atom/dashboard_issues_spec.rb | 2 +- spec/routing/routing_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/requests/atom/dashboard_issues_spec.rb b/spec/requests/atom/dashboard_issues_spec.rb index 8ce64cd4c14..6f5d51d16b6 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 57fd70e7497..5ad8165ecce 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 -- GitLab From cd47e625f0f6b564dff9a5e5fa51f3d88db2b530 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 14:10:42 +0200 Subject: [PATCH 5/6] Fix features --- features/steps/shared/paths.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index e397ff87f41..0cfadfdffc4 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -34,11 +34,11 @@ module SharedPaths 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 -- GitLab From d24fd32aa5090e1f26f028921048e15f09f82323 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 15:41:35 +0200 Subject: [PATCH 6/6] feature tests --- features/dashboard/projects.feature | 8 ++++++++ features/steps/dashboard/dashboard.rb | 6 ++++++ features/steps/shared/paths.rb | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 features/dashboard/projects.feature diff --git a/features/dashboard/projects.feature b/features/dashboard/projects.feature new file mode 100644 index 00000000000..17022dab54f --- /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 4bcefba76de..8c13ad0e151 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 0cfadfdffc4..42ef40d6b95 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -33,6 +33,10 @@ 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 issues_dashboard_path end -- GitLab