Commit 1b6a3dfec9bdadb8c607bf57e4b6699c4ab3a80b
1 parent
f9eda9b3
Exists in
master
and in
4 other branches
Move all stuff to groups controller
Showing
16 changed files
with
339 additions
and
27 deletions
Show diff stats
app/assets/stylesheets/sections/projects.scss
app/controllers/dashboard_controller.rb
... | ... | @@ -3,21 +3,14 @@ class DashboardController < ApplicationController |
3 | 3 | |
4 | 4 | def index |
5 | 5 | @groups = Group.where(id: current_user.projects.pluck(:group_id)) |
6 | - | |
7 | 6 | @projects = current_user.projects_with_events |
8 | - | |
9 | - if params[:group].present? | |
10 | - @group = Group.find_by_code(params[:group]) | |
11 | - @projects = @projects.where(group_id: @group.id) | |
12 | - end | |
13 | - | |
14 | 7 | @projects = @projects.page(params[:page]).per(40) |
15 | 8 | |
16 | 9 | @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) |
17 | 10 | @last_push = current_user.recent_push |
18 | 11 | |
19 | 12 | respond_to do |format| |
20 | - format.html { render 'index', layout: determine_layout } | |
13 | + format.html | |
21 | 14 | format.js |
22 | 15 | format.atom { render layout: false } |
23 | 16 | end |
... | ... | @@ -41,10 +34,4 @@ class DashboardController < ApplicationController |
41 | 34 | format.atom { render layout: false } |
42 | 35 | end |
43 | 36 | end |
44 | - | |
45 | - protected | |
46 | - | |
47 | - def determine_layout | |
48 | - @group ? 'group' : 'application' | |
49 | - end | |
50 | 37 | end | ... | ... |
... | ... | @@ -0,0 +1,69 @@ |
1 | +class GroupsController < ApplicationController | |
2 | + respond_to :html | |
3 | + layout 'group' | |
4 | + | |
5 | + before_filter :group | |
6 | + before_filter :projects | |
7 | + | |
8 | + def show | |
9 | + @events = Event.where(project_id: project_ids). | |
10 | + order('id DESC'). | |
11 | + limit(20).offset(params[:offset] || 0) | |
12 | + | |
13 | + @last_push = current_user.recent_push | |
14 | + | |
15 | + respond_to do |format| | |
16 | + format.html | |
17 | + format.js | |
18 | + format.atom { render layout: false } | |
19 | + end | |
20 | + end | |
21 | + | |
22 | + # Get authored or assigned open merge requests | |
23 | + def merge_requests | |
24 | + @merge_requests = current_user.cared_merge_requests.order("created_at DESC").page(params[:page]).per(20) | |
25 | + end | |
26 | + | |
27 | + # Get only assigned issues | |
28 | + def issues | |
29 | + @user = current_user | |
30 | + @issues = current_user.assigned_issues.opened.order("created_at DESC").page(params[:page]).per(20) | |
31 | + @issues = @issues.includes(:author, :project) | |
32 | + | |
33 | + respond_to do |format| | |
34 | + format.html | |
35 | + format.atom { render layout: false } | |
36 | + end | |
37 | + end | |
38 | + | |
39 | + def search | |
40 | + query = params[:search] | |
41 | + | |
42 | + @merge_requests = [] | |
43 | + @issues = [] | |
44 | + | |
45 | + if query.present? | |
46 | + @projects = @projects.search(query).limit(10) | |
47 | + @merge_requests = MergeRequest.where(project_id: project_ids).search(query).limit(10) | |
48 | + @issues = Issue.where(project_id: project_ids).search(query).limit(10) | |
49 | + end | |
50 | + end | |
51 | + | |
52 | + def people | |
53 | + @users = group.projects.map(&:users).flatten.uniq | |
54 | + end | |
55 | + | |
56 | + protected | |
57 | + | |
58 | + def group | |
59 | + @group ||= Group.find_by_code(params[:id]) | |
60 | + end | |
61 | + | |
62 | + def projects | |
63 | + @projects ||= current_user.projects_with_events.where(group_id: @group.id) | |
64 | + end | |
65 | + | |
66 | + def project_ids | |
67 | + projects.map(&:id) | |
68 | + end | |
69 | +end | ... | ... |
app/views/dashboard/_groups.html.haml
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | %ul.unstyled |
7 | 7 | - groups.each do |group| |
8 | 8 | %li.wll |
9 | - = link_to dashboard_path(group: group), class: dom_class(group) do | |
9 | + = link_to group_path(id: group.code), class: dom_class(group) do | |
10 | 10 | %strong.group_name= truncate(group.name, length: 25) |
11 | 11 | %span.arrow |
12 | 12 | → | ... | ... |
app/views/dashboard/index.html.haml
... | ... | @@ -0,0 +1,20 @@ |
1 | +.projects_box | |
2 | + %h5 | |
3 | + Projects | |
4 | + %small | |
5 | + (#{projects.count}) | |
6 | + - if current_user.can_create_project? | |
7 | + %span.right | |
8 | + = link_to new_project_path, class: "btn very_small info" do | |
9 | + %i.icon-plus | |
10 | + New Project | |
11 | + %ul.unstyled | |
12 | + - projects.each do |project| | |
13 | + %li.wll | |
14 | + = link_to project_path(project), class: dom_class(project) do | |
15 | + %strong.project_name= truncate(project.name, length: 25) | |
16 | + %span.arrow | |
17 | + → | |
18 | + %span.last_activity | |
19 | + %strong Last activity: | |
20 | + %span= project_last_activity(project) | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +xml.instruct! | |
2 | +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do | |
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) | |
7 | + xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? | |
8 | + | |
9 | + @issues.each do |issue| | |
10 | + xml.entry do | |
11 | + xml.id project_issue_url(issue.project, issue) | |
12 | + xml.link :href => project_issue_url(issue.project, issue) | |
13 | + xml.title truncate(issue.title, :length => 80) | |
14 | + xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") | |
15 | + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email) | |
16 | + xml.author do |author| | |
17 | + xml.name issue.author_name | |
18 | + xml.email issue.author_email | |
19 | + end | |
20 | + xml.summary issue.title | |
21 | + end | |
22 | + end | |
23 | +end | |
24 | + | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +%h3.page_title | |
2 | + Issues | |
3 | + %small (assigned to you) | |
4 | + %small.right #{@issues.total_count} issues | |
5 | + | |
6 | +%br | |
7 | +.clearfix | |
8 | +- if @issues.any? | |
9 | + - @issues.group_by(&:project).each do |group| | |
10 | + %div.ui-box | |
11 | + - @project = group[0] | |
12 | + %h5= @project.name | |
13 | + %ul.unstyled.issues_table | |
14 | + - group[1].each do |issue| | |
15 | + = render(partial: 'issues/show', locals: {issue: issue}) | |
16 | + %hr | |
17 | + = paginate @issues, theme: "gitlab" | |
18 | +- else | |
19 | + %h3.nothing_here_message Nothing to show here | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +%h3.page_title | |
2 | + Merge Requests | |
3 | + %small (authored by or assigned to you) | |
4 | + %small.right #{@merge_requests.total_count} merge requests | |
5 | + | |
6 | +%br | |
7 | +- if @merge_requests.any? | |
8 | + - @merge_requests.group_by(&:project).each do |group| | |
9 | + %ul.unstyled.ui-box | |
10 | + - @project = group[0] | |
11 | + %h5= @project.name | |
12 | + - group[1].each do |merge_request| | |
13 | + = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) | |
14 | + %hr | |
15 | + = paginate @merge_requests, theme: "gitlab" | |
16 | + | |
17 | +- else | |
18 | + %h3.nothing_here_message Nothing to show here | ... | ... |
... | ... | @@ -0,0 +1,75 @@ |
1 | += form_tag search_group_path(@group), method: :get, class: 'form-inline' do |f| | |
2 | + .padded | |
3 | + = label_tag :search do | |
4 | + %strong Looking for | |
5 | + .input | |
6 | + = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" | |
7 | + = submit_tag 'Search', class: "btn primary wide" | |
8 | +- if params[:search].present? | |
9 | + %br | |
10 | + %h3 | |
11 | + Search results | |
12 | + %small (#{@projects.count + @merge_requests.count + @issues.count}) | |
13 | + %hr | |
14 | + .search_results | |
15 | + .row | |
16 | + .span6 | |
17 | + %table | |
18 | + %thead | |
19 | + %tr | |
20 | + %th Projects | |
21 | + %tbody | |
22 | + - @projects.each do |project| | |
23 | + %tr | |
24 | + %td | |
25 | + = link_to project do | |
26 | + %strong.term= project.name | |
27 | + %small.cgray | |
28 | + last activity at | |
29 | + = project.last_activity_date.stamp("Aug 25, 2011") | |
30 | + - if @projects.blank? | |
31 | + %tr | |
32 | + %td | |
33 | + %h4.nothing_here_message No Projects | |
34 | + %br | |
35 | + %table | |
36 | + %thead | |
37 | + %tr | |
38 | + %th Merge Requests | |
39 | + %tbody | |
40 | + - @merge_requests.each do |merge_request| | |
41 | + %tr | |
42 | + %td | |
43 | + = link_to [merge_request.project, merge_request] do | |
44 | + %span.badge.badge-info ##{merge_request.id} | |
45 | + – | |
46 | + %strong.term= truncate merge_request.title, length: 50 | |
47 | + %strong.right | |
48 | + %span.label= merge_request.project.name | |
49 | + - if @merge_requests.blank? | |
50 | + %tr | |
51 | + %td | |
52 | + %h4.nothing_here_message No Merge Requests | |
53 | + .span6 | |
54 | + %table | |
55 | + %thead | |
56 | + %tr | |
57 | + %th Issues | |
58 | + %tbody | |
59 | + - @issues.each do |issue| | |
60 | + %tr | |
61 | + %td | |
62 | + = link_to [issue.project, issue] do | |
63 | + %span.badge.badge-info ##{issue.id} | |
64 | + – | |
65 | + %strong.term= truncate issue.title, length: 40 | |
66 | + %strong.right | |
67 | + %span.label= issue.project.name | |
68 | + - if @issues.blank? | |
69 | + %tr | |
70 | + %td | |
71 | + %h4.nothing_here_message No Issues | |
72 | + :javascript | |
73 | + $(function() { | |
74 | + $(".search_results .term").highlight("#{params[:search]}"); | |
75 | + }) | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
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.allowed? | |
11 | + event = EventDecorator.decorate(event) | |
12 | + xml.entry do | |
13 | + event_link = event.feed_url | |
14 | + event_title = event.feed_title | |
15 | + | |
16 | + xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" | |
17 | + xml.link :href => event_link | |
18 | + xml.title truncate(event_title, :length => 80) | |
19 | + xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") | |
20 | + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email) | |
21 | + xml.author do |author| | |
22 | + xml.name event.author_name | |
23 | + xml.email event.author_email | |
24 | + end | |
25 | + xml.summary event_title | |
26 | + end | |
27 | + end | |
28 | + end | |
29 | +end | ... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +- if @projects.any? | |
2 | + .projects | |
3 | + .activities.span8 | |
4 | + = render 'shared/no_ssh' | |
5 | + - if @events.any? | |
6 | + .content_list= render @events | |
7 | + - else | |
8 | + %h4.nothing_here_message Projects activity will be displayed here | |
9 | + .loading.hide | |
10 | + .side | |
11 | + = render "events/event_last_push", event: @last_push | |
12 | + = render "projects", projects: @projects | |
13 | + %div | |
14 | + %span.rss-icon | |
15 | + = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do | |
16 | + = image_tag "rss_ui.png", title: "feed" | |
17 | + %strong News Feed | |
18 | + | |
19 | + %hr | |
20 | + .gitlab-promo | |
21 | + = link_to "Homepage", "http://gitlabhq.com" | |
22 | + = link_to "Blog", "http://blog.gitlabhq.com" | |
23 | + = link_to "@gitlabhq", "https://twitter.com/gitlabhq" | |
24 | + | |
25 | + | |
26 | +- else | |
27 | + %h3.nothing_here_message There are no projects you have access to. | |
28 | + %br | |
29 | + %h4.nothing_here_message | |
30 | + - if current_user.can_create_project? | |
31 | + You can create up to | |
32 | + = current_user.projects_limit | |
33 | + projects. Click on button below to add a new one | |
34 | + .link_holder | |
35 | + = link_to new_project_path, class: "btn primary" do | |
36 | + New Project » | |
37 | + - else | |
38 | + If you will be added to project - it will be displayed here | |
39 | + | |
40 | + | |
41 | +:javascript | |
42 | + $(function(){ Pager.init(20); }); | ... | ... |
app/views/layouts/group.html.haml
... | ... | @@ -3,22 +3,22 @@ |
3 | 3 | = render "layouts/head" |
4 | 4 | %body{class: "#{app_theme} application"} |
5 | 5 | = render "layouts/flash" |
6 | - = render "layouts/head_panel", title: "#{@group.name}:Dashboard" | |
6 | + = render "layouts/head_panel", title: "#{@group.name}" | |
7 | 7 | .container |
8 | 8 | %ul.main_menu |
9 | - = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do | |
10 | - = link_to "Home", root_path, title: "Home" | |
11 | - = nav_link(path: 'dashboard#issues') do | |
12 | - = link_to dashboard_issues_path(group: @group) do | |
9 | + = nav_link(path: 'groups#show', html_options: {class: 'home'}) do | |
10 | + = link_to "Home", group_path(@group), title: "Home" | |
11 | + = nav_link(path: 'groups#issues') do | |
12 | + = link_to issues_group_path(@group) do | |
13 | 13 | Issues |
14 | 14 | %span.count= current_user.assigned_issues.opened.count |
15 | - = nav_link(path: 'dashboard#merge_requests') do | |
16 | - = link_to dashboard_merge_requests_path(group: @group) do | |
15 | + = nav_link(path: 'groups#merge_requests') do | |
16 | + = link_to merge_requests_group_path(@group) do | |
17 | 17 | Merge Requests |
18 | 18 | %span.count= current_user.cared_merge_requests.count |
19 | - = nav_link(path: 'search#show') do | |
20 | - = link_to "People", "#" | |
21 | - = nav_link(path: 'help#index') do | |
22 | - = link_to "Help", help_path | |
19 | + = nav_link(path: 'groups#search') do | |
20 | + = link_to "Search", search_group_path(@group) | |
21 | + = nav_link(path: 'groups#people') do | |
22 | + = link_to "People", people_group_path(@group) | |
23 | 23 | |
24 | 24 | .content= yield | ... | ... |
config/routes.rb
... | ... | @@ -86,6 +86,19 @@ Gitlab::Application.routes.draw do |
86 | 86 | get "dashboard/issues" => "dashboard#issues" |
87 | 87 | get "dashboard/merge_requests" => "dashboard#merge_requests" |
88 | 88 | |
89 | + | |
90 | + # | |
91 | + # Groups Area | |
92 | + # | |
93 | + resources :groups, constraints: { id: /[^\/]+/ }, only: [:show] do | |
94 | + member do | |
95 | + get :issues | |
96 | + get :merge_requests | |
97 | + get :search | |
98 | + get :people | |
99 | + end | |
100 | + end | |
101 | + | |
89 | 102 | resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] |
90 | 103 | |
91 | 104 | devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks } | ... | ... |