From edd81a79c5c2a61e565664cfa787185c4e19729b Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 12 Jun 2012 23:13:42 +0300 Subject: Dashboard refactoring: * dashboard should be in dashboard controller not project index * projects index removed --- app/assets/stylesheets/common.scss | 6 +++- app/controllers/dashboard_controller.rb | 17 +++++----- app/helpers/application_helper.rb | 3 +- app/views/dashboard/index.atom.builder | 36 +++++++++++++++++++++ app/views/dashboard/index.html.haml | 56 +++++++++++++++++++++++++++++++++ app/views/dashboard/index.js.haml | 2 ++ app/views/layouts/_app_menu.html.haml | 2 +- app/views/projects/index.atom.builder | 36 --------------------- app/views/projects/index.html.haml | 49 ----------------------------- app/views/projects/index.js.haml | 2 -- app/views/projects/show.html.haml | 4 --- 11 files changed, 110 insertions(+), 103 deletions(-) create mode 100644 app/views/dashboard/index.atom.builder create mode 100644 app/views/dashboard/index.html.haml create mode 100644 app/views/dashboard/index.js.haml delete mode 100644 app/views/projects/index.atom.builder delete mode 100644 app/views/projects/index.html.haml delete mode 100644 app/views/projects/index.js.haml (limited to 'app') diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 18023c55e6b..32667ec646f 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -659,6 +659,10 @@ li.note { width:24px; vertical-align:top; } + + strong { + line-height:24px; + } } .automerge_widget { @@ -741,7 +745,7 @@ li.note { */ .event_lp { @extend .alert-info; - margin-bottom:15px; + margin-bottom:20px; padding:8px; border-style: solid; border-width: 1px; diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index c28f17167e6..a054940738e 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,18 +2,17 @@ class DashboardController < ApplicationController respond_to :html def index - @projects = current_user.projects.all - - @active_projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse + @projects = current_user.projects.includes(:events).order("events.created_at DESC") + @projects = @projects.page(params[:page]).per(40) - @merge_requests = MergeRequest.where("author_id = :id or assignee_id = :id", :id => current_user.id).opened.order("created_at DESC").limit(5) + @events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20) - @user = current_user - @issues = current_user.assigned_issues.opened.order("created_at DESC").limit(5) - @issues = @issues.includes(:author, :project) + @last_push = current_user.recent_push - @events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20) - @last_push = Event.where(:project_id => @projects.map(&:id)).recent.code_push.limit(1).first + respond_to do |format| + format.html + format.atom { render :layout => false } + end end # Get authored or assigned open merge requests diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6b9e457cc9d..be0e0c9eedf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,8 +60,9 @@ module ApplicationHelper def search_autocomplete_source projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } } default_nav = [ + { :label => "Profile", :url => profile_path }, { :label => "Keys", :url => keys_path }, - { :label => "Projects", :url => projects_path }, + { :label => "Dashboard", :url => root_path }, { :label => "Admin", :url => admin_root_path } ] diff --git a/app/views/dashboard/index.atom.builder b/app/views/dashboard/index.atom.builder new file mode 100644 index 00000000000..706b808ee43 --- /dev/null +++ b/app/views/dashboard/index.atom.builder @@ -0,0 +1,36 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}" + xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml" + xml.link :href => projects_url, :rel => "alternate", :type => "text/html" + xml.id projects_url + xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? + + @events.each do |event| + if event.allowed? + xml.entry do + if event.issue? + event_link = project_issue_url(event.project, event.issue) + event_title = event.issue_title + elsif event.merge_request? + event_link = project_merge_request_url(event.project, event.merge_request) + event_title = event.merge_request_title + elsif event.push? + event_link = project_commits_url(event.project, :ref => event.ref_name) + event_title = event.ref_name + end + + xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" + xml.link :href => event_link + xml.title truncate(event_title, :length => 80) + xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email) + xml.author do |author| + xml.name event.author_name + xml.email event.author_email + end + xml.summary event_title + end + end + end +end diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml new file mode 100644 index 00000000000..b38544509b2 --- /dev/null +++ b/app/views/dashboard/index.html.haml @@ -0,0 +1,56 @@ +- if @projects.any? + .projects + .activities.span8 + - if current_user.require_ssh_key? + .alert.alert-error.padded + %span + You wont be able to pull/push project code unless you + %strong + = link_to new_key_path, :class => "vlink" do + add new key + to your profile + - if @events.any? + = render @events + - else + %h4.nothing_here_message Projects activity will be displayed here + .side + = render "events/event_last_push", :event => @last_push + .projects_box + %h5 + Projects + %small + (#{@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 + - @projects.each do |project| + = link_to project_path(project), :class => dom_class(project) do + %h4 + %span.ico.project + = truncate(project.name, :length => 25) + %span.right + → + .bottom= paginate @projects, :theme => "gitlab" + + %hr + %div + %span.rss-icon + = link_to dashboard_path(:atom, { :private_token => current_user.private_token }) do + = image_tag "rss_ui.png", :title => "feed" + %strong News Feed + +- else + %h3.nothing_here_message There are no projects you have access to. + %br + %h4.nothing_here_message + - if current_user.can_create_project? + You can create up to + = current_user.projects_limit + projects. Click on button below to add a new one + .link_holder + = link_to new_project_path, :class => "btn primary" do + New Project » + - else + If you will be added to project - it will be displayed here diff --git a/app/views/dashboard/index.js.haml b/app/views/dashboard/index.js.haml new file mode 100644 index 00000000000..aa038e75928 --- /dev/null +++ b/app/views/dashboard/index.js.haml @@ -0,0 +1,2 @@ +:plain + $(".projects .activities").append("#{escape_javascript(render(@events))}"); diff --git a/app/views/layouts/_app_menu.html.haml b/app/views/layouts/_app_menu.html.haml index c0e3e8a39a1..7b5f2cf9225 100644 --- a/app/views/layouts/_app_menu.html.haml +++ b/app/views/layouts/_app_menu.html.haml @@ -1,5 +1,5 @@ %nav.main_menu - = link_to "Home", root_path, :class => "home #{"current" if current_page?(projects_path) || current_page?(root_path)}", :title => "Home" + = link_to "Home", root_path, :class => "home #{"current" if current_page?(dashboard_path) || current_page?(root_path)}", :title => "Home" = link_to dashboard_issues_path, :class => "#{"current" if current_page?(dashboard_issues_path)}", :id => "issues_slide" do Issues %span.count= current_user.assigned_issues.opened.count diff --git a/app/views/projects/index.atom.builder b/app/views/projects/index.atom.builder deleted file mode 100644 index 706b808ee43..00000000000 --- a/app/views/projects/index.atom.builder +++ /dev/null @@ -1,36 +0,0 @@ -xml.instruct! -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}" - xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => projects_url, :rel => "alternate", :type => "text/html" - xml.id projects_url - xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? - - @events.each do |event| - if event.allowed? - xml.entry do - if event.issue? - event_link = project_issue_url(event.project, event.issue) - event_title = event.issue_title - elsif event.merge_request? - event_link = project_merge_request_url(event.project, event.merge_request) - event_title = event.merge_request_title - elsif event.push? - event_link = project_commits_url(event.project, :ref => event.ref_name) - event_title = event.ref_name - end - - xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" - xml.link :href => event_link - xml.title truncate(event_title, :length => 80) - xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email) - xml.author do |author| - xml.name event.author_name - xml.email event.author_email - end - xml.summary event_title - end - end - end -end diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml deleted file mode 100644 index 3a77e39d645..00000000000 --- a/app/views/projects/index.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -- if @projects.any? - .projects - .activities.span8 - - if current_user.require_ssh_key? - .alert.alert-error.padded - %span - You wont be able to pull/push project code unless you - %strong - = link_to new_key_path, :class => "vlink" do - add new key - to your profile - - if @events.any? - = render @events - - else - %h4.nothing_here_message Projects activity will be displayed here - .side - = render "events/event_last_push", :event => @last_push - .projects_box - %h5 - Projects - %small - (#{@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 - - @projects.each do |project| - = link_to project_path(project), :class => dom_class(project) do - %h4 - %span.ico.project - = truncate(project.name, :length => 25) - %span.right - → - .bottom= paginate @projects, :theme => "gitlab" - -- else - %h3.nothing_here_message There are no projects you have access to. - %br - %h4.nothing_here_message - - if current_user.can_create_project? - You can create up to - = current_user.projects_limit - projects. Click on button below to add a new one - .link_holder - = link_to new_project_path, :class => "btn primary" do - New Project » - - else - If you will be added to project - it will be displayed here diff --git a/app/views/projects/index.js.haml b/app/views/projects/index.js.haml deleted file mode 100644 index 15bbd9730d0..00000000000 --- a/app/views/projects/index.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - Pager.append(#{@projects.count}, "#{escape_javascript(render(:partial => 'projects/tile'))}"); diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 9ecbce38658..48b541544ff 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -2,10 +2,6 @@ .entry .row - -#.span2 - .back_link - = link_to projects_path do - ← To projects list .span7 .form-horizontal .input-prepend -- cgit v1.2.3