Commit 6b01196fb238cb921056ecd8d1572ff2874bf912

Authored by Dmitriy Zaporozhets
1 parent bd3b677b

Dashboard to resource

app/controllers/dashboard_controller.rb
... ... @@ -2,9 +2,9 @@ class DashboardController < ApplicationController
2 2 respond_to :html
3 3  
4 4 before_filter :load_projects
5   - before_filter :event_filter, only: :index
  5 + before_filter :event_filter, only: :show
6 6  
7   - def index
  7 + def show
8 8 @groups = current_user.authorized_groups
9 9 @has_authorized_projects = @projects.count > 0
10 10 @teams = current_user.authorized_teams
... ...
app/helpers/dashboard_helper.rb
... ... @@ -9,9 +9,9 @@ module DashboardHelper
9 9  
10 10 case entity
11 11 when 'issue' then
12   - dashboard_issues_path(options)
  12 + issues_dashboard_path(options)
13 13 when 'merge_request'
14   - dashboard_merge_requests_path(options)
  14 + merge_requests_dashboard_path(options)
15 15 end
16 16 end
17 17  
... ...
app/views/dashboard/_projects.html.haml
... ... @@ -28,4 +28,4 @@
28 28 %h3.nothing_here_message There are no projects here.
29 29 - if @projects_count > 20
30 30 %li.bottom
31   - %strong= link_to "show all projects", dashboard_projects_path
  31 + %strong= link_to "show all projects", projects_dashboard_path
... ...
app/views/dashboard/index.atom.builder
... ... @@ -1,30 +0,0 @@
1   -xml.instruct!
2   -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
3   - xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}"
4   - xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml"
5   - xml.link :href => projects_url, :rel => "alternate", :type => "text/html"
6   - xml.id projects_url
7   - xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any?
8   -
9   - @events.each do |event|
10   - if event.proper?
11   - event = EventDecorator.decorate(event)
12   - xml.entry do
13   - event_link = event.feed_url
14   - event_title = event.feed_title
15   - event_summary = event.feed_summary
16   -
17   - xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}"
18   - xml.link :href => event_link
19   - xml.title truncate(event_title, :length => 80)
20   - xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
21   - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email)
22   - xml.author do |author|
23   - xml.name event.author_name
24   - xml.email event.author_email
25   - end
26   - xml.summary(:type => "xhtml") { |x| x << event_summary unless event_summary.nil? }
27   - end
28   - end
29   - end
30   -end
app/views/dashboard/index.html.haml
... ... @@ -1,12 +0,0 @@
1   -- if @has_authorized_projects
2   - .projects
3   - .activities.span8
4   - = render 'activities'
5   - .side.span4
6   - = render 'sidebar'
7   -
8   -- else
9   - = render "zero_authorized_projects"
10   -
11   -:javascript
12   - dashboardPage();
app/views/dashboard/index.js.haml
... ... @@ -1,2 +0,0 @@
1   -:plain
2   - Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
app/views/dashboard/issues.atom.builder
1 1 xml.instruct!
2 2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
3 3 xml.title "#{current_user.name} issues"
4   - xml.link :href => dashboard_issues_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml"
5   - xml.link :href => dashboard_issues_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html"
6   - xml.id dashboard_issues_url(:private_token => current_user.private_token)
  4 + xml.link :href => issues_dashboard_url(:atom, :private_token => current_user.private_token), :rel => "self", :type => "application/atom+xml"
  5 + xml.link :href => issues_dashboard_url(:private_token => current_user.private_token), :rel => "alternate", :type => "text/html"
  6 + xml.id issues_dashboard_url(:private_token => current_user.private_token)
7 7 xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
8 8  
9 9 @issues.each do |issue|
... ...
app/views/dashboard/projects.html.haml
... ... @@ -8,19 +8,20 @@
8 8 %i.icon-plus
9 9 New Project
10 10  
  11 +
11 12 %hr
12 13 .row
13 14 .span3
14 15 %ul.nav.nav-pills.nav-stacked
15 16 = nav_tab :scope, nil do
16   - = link_to "All", dashboard_projects_path
  17 + = link_to "All", projects_dashboard_path
17 18 = nav_tab :scope, 'personal' do
18   - = link_to "Personal", dashboard_projects_path(scope: 'personal')
  19 + = link_to "Personal", projects_dashboard_path(scope: 'personal')
19 20 = nav_tab :scope, 'joined' do
20   - = link_to "Joined", dashboard_projects_path(scope: 'joined')
  21 + = link_to "Joined", projects_dashboard_path(scope: 'joined')
21 22  
22 23 .span9
23   - = form_tag dashboard_projects_path, method: 'get' do
  24 + = form_tag projects_dashboard_path, method: 'get' do
24 25 %fieldset.dashboard-search-filter
25 26 = hidden_field_tag "scope", params[:scope]
26 27 = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' }
... ... @@ -29,16 +30,25 @@
29 30  
30 31 %ul.well-list
31 32 - @projects.each do |project|
32   - %li
33   - = link_to project_path(project), class: dom_class(project) do
34   - - if project.namespace
35   - = project.namespace.human_name
36   - \/
37   - %strong.well-title
38   - = truncate(project.name, length: 25)
39   - %span.right.light
  33 + %li.clearfix
  34 + .left
  35 + = link_to project_path(project), class: dom_class(project) do
  36 + - if project.namespace
  37 + = project.namespace.human_name
  38 + \/
  39 + %strong.well-title
  40 + = truncate(project.name, length: 25)
  41 + %br
  42 + %small.light
40 43 %strong Last activity:
41 44 %span= project_last_activity(project)
  45 + .right.light
  46 + - if project.owner == current_user
  47 + %i.icon-wrench
  48 + - tm = project.team.get_tm(current_user.id)
  49 + - if tm
  50 + = tm.project_access_human
  51 +
42 52 - if @projects.blank?
43 53 %li
44 54 %h3.nothing_here_message There are no projects here.
... ...
app/views/dashboard/show.atom.builder 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +xml.instruct!
  2 +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
  3 + xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}"
  4 + xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml"
  5 + xml.link :href => projects_url, :rel => "alternate", :type => "text/html"
  6 + xml.id projects_url
  7 + xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any?
  8 +
  9 + @events.each do |event|
  10 + if event.proper?
  11 + event = EventDecorator.decorate(event)
  12 + xml.entry do
  13 + event_link = event.feed_url
  14 + event_title = event.feed_title
  15 + event_summary = event.feed_summary
  16 +
  17 + xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}"
  18 + xml.link :href => event_link
  19 + xml.title truncate(event_title, :length => 80)
  20 + xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
  21 + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email)
  22 + xml.author do |author|
  23 + xml.name event.author_name
  24 + xml.email event.author_email
  25 + end
  26 + xml.summary(:type => "xhtml") { |x| x << event_summary unless event_summary.nil? }
  27 + end
  28 + end
  29 + end
  30 +end
... ...
app/views/dashboard/show.html.haml 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +- if @has_authorized_projects
  2 + .projects
  3 + .activities.span8
  4 + = render 'activities'
  5 + .side.span4
  6 + = render 'sidebar'
  7 +
  8 +- else
  9 + = render "zero_authorized_projects"
  10 +
  11 +:javascript
  12 + dashboardPage();
... ...
app/views/dashboard/show.js.haml 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +:plain
  2 + Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}");
... ...
app/views/groups/issues.atom.builder
1 1 xml.instruct!
2 2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
3 3 xml.title "#{@user.name} issues"
4   - xml.link :href => dashboard_issues_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml"
5   - xml.link :href => dashboard_issues_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html"
6   - xml.id dashboard_issues_url(:private_token => @user.private_token)
  4 + xml.link :href => issues_dashboard_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml"
  5 + xml.link :href => issues_dashboard_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html"
  6 + xml.id issues_dashboard_url(:private_token => @user.private_token)
7 7 xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
8 8  
9 9 @issues.each do |issue|
... ...
app/views/layouts/application.html.haml
... ... @@ -6,17 +6,17 @@
6 6 = render "layouts/head_panel", title: "Dashboard"
7 7 .container
8 8 %ul.main_menu
9   - = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
  9 + = nav_link(path: 'dashboard#show', html_options: {class: 'home'}) do
10 10 = link_to "Home", root_path, title: "Home"
11 11 = nav_link(path: 'dashboard#projects') do
12   - = link_to dashboard_projects_path do
  12 + = link_to projects_dashboard_path do
13 13 Projects
14 14 = nav_link(path: 'dashboard#issues') do
15   - = link_to dashboard_issues_path do
  15 + = link_to issues_dashboard_path do
16 16 Issues
17 17 %span.count= current_user.assigned_issues.opened.count
18 18 = nav_link(path: 'dashboard#merge_requests') do
19   - = link_to dashboard_merge_requests_path do
  19 + = link_to merge_requests_dashboard_path do
20 20 Merge Requests
21 21 %span.count= current_user.cared_merge_requests.opened.count
22 22 = nav_link(path: 'search#show') do
... ...
config/routes.rb
... ... @@ -118,10 +118,13 @@ Gitlab::Application.routes.draw do
118 118 #
119 119 # Dashboard Area
120 120 #
121   - get "dashboard" => "dashboard#index"
122   - get "dashboard/projects" => "dashboard#projects"
123   - get "dashboard/issues" => "dashboard#issues"
124   - get "dashboard/merge_requests" => "dashboard#merge_requests"
  121 + resource :dashboard, controller: "dashboard" do
  122 + member do
  123 + get :projects
  124 + get :issues
  125 + get :merge_requests
  126 + end
  127 + end
125 128  
126 129 #
127 130 # Groups Area
... ... @@ -285,5 +288,5 @@ Gitlab::Application.routes.draw do
285 288 end
286 289 end
287 290  
288   - root to: "dashboard#index"
  291 + root to: "dashboard#show"
289 292 end
... ...