Commit 5263dd4297e2ba71c40d74dcfb8511fec68e6620

Authored by Dmitriy Zaporozhets
1 parent 00028702

Events displayed on project page. \n Fixed theme issue. \n New issue, mr events enabled

app/assets/stylesheets/common.scss
... ... @@ -610,6 +610,35 @@ p.time {
610 610 .dashboard_category {
611 611 margin-bottom:30px;
612 612  
  613 + .ico {
  614 + background: url("images.png") no-repeat -85px -77px;
  615 + width: 19px;
  616 + height: 16px;
  617 + float: left;
  618 + position: relative;
  619 + margin-right: 10px;
  620 + top: 8px;
  621 +
  622 + &.project {
  623 + background-position: -37px -77px;
  624 + }
  625 +
  626 + &.activities {
  627 + background-position:-162px -22px;
  628 + }
  629 + &.projects {
  630 + background-position:-209px -21px;
  631 + }
  632 + }
  633 +
  634 +
  635 + h3 a {
  636 + color:#474D57;
  637 +
  638 + &:hover {
  639 + text-decoration:underline;
  640 + }
  641 + }
613 642 .dashboard_block {
614 643 width:700px;
615 644 margin:auto;
... ... @@ -625,20 +654,6 @@ p.time {
625 654 h4 {
626 655 color:#666;
627 656 }
628   - &.event_feed {
629   - min-height:40px;
630   - border-bottom:1px solid #eee;
631   - .avatar {
632   - width:32px;
633   - }
634   - ul {
635   - margin-left:50px;
636   - margin-bottom:5px;
637   - .avatar {
638   - width:24px;
639   - }
640   - }
641   - }
642 657 }
643 658 }
644 659 }
... ... @@ -651,3 +666,25 @@ p.time {
651 666 -webkit-box-shadow: 0 0 5px#888;
652 667 box-shadow: 0 0 5px #888;
653 668 }
  669 +
  670 +.event_feed {
  671 + min-height:40px;
  672 + border-bottom:1px solid #eee;
  673 + .avatar {
  674 + width:32px;
  675 + }
  676 + ul {
  677 + margin-left:50px;
  678 + margin-bottom:5px;
  679 + .avatar {
  680 + width:24px;
  681 + }
  682 + }
  683 +
  684 + padding: 10px 5px;
  685 + border-bottom: 1px solid #eee;
  686 + border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  687 + &:last-child { border:none }
  688 + .wll:hover { background:none }
  689 +}
  690 +
... ...
app/assets/stylesheets/ui_basic.scss
... ... @@ -70,7 +70,6 @@
70 70 width:16px;
71 71 height:16px;
72 72 padding: 5px;
73   - border: 1px solid #ccc;
74 73 border-radius: 4px;
75 74 margin: 0px;
76 75 background: #eee;
... ...
app/assets/stylesheets/ui_mars.scss
... ... @@ -97,14 +97,13 @@
97 97 width:16px;
98 98 height:16px;
99 99 padding: 5px;
100   - border: 1px solid #888;
101 100 border-radius: 4px;
102 101 margin: 0px;
103 102 background:#474D57 ;
104 103 margin-left:20px;
105 104 margin-top:4px;
106 105 &:hover {
107   - background:#f7f7f7;
  106 + background:#555;
108 107 }
109 108 img {
110 109 width:16px;
... ...
app/controllers/projects_controller.rb
... ... @@ -68,8 +68,8 @@ class ProjectsController < ApplicationController
68 68  
69 69 def show
70 70 return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
71   - limit = (params[:limit] || 10).to_i
72   - @activities = @project.activities(limit)
  71 + limit = (params[:limit] || 20).to_i
  72 + @events = @project.events.recent.limit(limit)
73 73 end
74 74  
75 75 def files
... ...
app/models/event.rb
... ... @@ -21,9 +21,12 @@ class Event < ActiveRecord::Base
21 21 end
22 22 end
23 23  
24   - # For now only push events enabled for system
  24 + # Next events currently enabled for system
  25 + # - push
  26 + # - new issue
  27 + # - merge request
25 28 def allowed?
26   - push?
  29 + push? || new_issue? || new_merge_request?
27 30 end
28 31  
29 32 def push?
... ... @@ -49,6 +52,28 @@ class Event < ActiveRecord::Base
49 52 def pusher
50 53 User.find_by_id(data[:user_id])
51 54 end
  55 +
  56 + def new_issue?
  57 + target_type == "Issue" &&
  58 + action == Created
  59 + end
  60 +
  61 + def new_merge_request?
  62 + target_type == "MergeRequest" &&
  63 + action == Created
  64 + end
  65 +
  66 + def issue
  67 + target if target_type == "Issue"
  68 + end
  69 +
  70 + def merge_request
  71 + target if target_type == "MergeRequest"
  72 + end
  73 +
  74 + def author
  75 + target.author
  76 + end
52 77  
53 78 def commits
54 79 @commits ||= data[:commits].map do |commit|
... ... @@ -57,6 +82,9 @@ class Event < ActiveRecord::Base
57 82 end
58 83  
59 84 delegate :id, :name, :email, :to => :pusher, :prefix => true, :allow_nil => true
  85 + delegate :name, :email, :to => :author, :prefix => true, :allow_nil => true
  86 + delegate :title, :to => :issue, :prefix => true, :allow_nil => true
  87 + delegate :title, :to => :merge_request, :prefix => true, :allow_nil => true
60 88 end
61 89 # == Schema Information
62 90 #
... ...
app/views/dashboard/_projects_feed.html.haml
... ... @@ -2,6 +2,7 @@
2 2 .wll
3 3 = link_to project do
4 4 %h4
  5 + %span.ico.project
5 6 = project.name
6 7 %small
7 8 last activity at
... ...
app/views/dashboard/index.html.haml
... ... @@ -8,6 +8,7 @@
8 8  
9 9 %div.dashboard_category
10 10 %h3
  11 + %span.ico.projects
11 12 = link_to "Projects" , "#projects", :id => "projects"
12 13 %small
13 14 ( most recent )
... ... @@ -59,6 +60,7 @@
59 60 - unless @events.blank?
60 61 %div.dashboard_category
61 62 %h3
  63 + %span.ico.activities
62 64 = link_to "Activities" , "#activities", :id => "activities"
63 65  
64 66 %hr
... ...
app/views/events/_event.html.haml
1 1 - if event.allowed?
2   - .wll.event_feed
3   - - if event.push?
4   - - if event.new_branch?
5   - = image_tag gravatar_icon(event.pusher_email), :class => "avatar"
6   - %strong #{event.pusher_name}
7   - pushed new branch
8   - = link_to project_commits_path(event.project, :ref => event.branch_name) do
9   - %strong= event.branch_name
10   - at
11   - %strong= link_to event.project.name, event.project
12   - %span.cgray
13   - = time_ago_in_words(event.created_at)
14   - ago.
15   - - else
16   - = image_tag gravatar_icon(event.pusher_email), :class => "avatar"
17   - %strong #{event.pusher_name}
18   - pushed to
19   - = link_to project_commits_path(event.project, :ref => event.branch_name) do
20   - %strong= event.branch_name
21   - at
22   - %strong= link_to event.project.name, event.project
23   - %span.cgray
24   - = time_ago_in_words(event.created_at)
25   - ago.
26   - - if event.commits.count > 1
27   - = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
28   - Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
29   - - @project = event.project
30   - %ul.unstyled
31   - = render event.commits
32   -
  2 + .event_feed
  3 + - if event.new_issue?
  4 + = render "events/event_new_issue", :event => event
  5 + - if event.new_merge_request?
  6 + = render "events/event_new_merge_request", :event => event
  7 + - elsif event.push?
  8 + = render "events/event_push", :event => event
... ...
app/views/events/_event_new_issue.html.haml 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 += image_tag gravatar_icon(event.author_email), :class => "avatar"
  2 +%strong #{event.author_name}
  3 +created new issue
  4 += link_to project_issue_path(event.project, event.issue) do
  5 + %strong= truncate event.issue_title
  6 +at
  7 +%strong= link_to event.project.name, event.project
  8 +%span.cgray
  9 + = time_ago_in_words(event.created_at)
  10 + ago.
... ...
app/views/events/_event_new_merge_request.html.haml 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 += image_tag gravatar_icon(event.author_email), :class => "avatar"
  2 +%strong #{event.author_name}
  3 +requested merge
  4 += link_to project_merge_request_path(event.project, event.merge_request) do
  5 + %strong= truncate event.merge_request_title
  6 +at
  7 +%strong= link_to event.project.name, event.project
  8 +%span.cgray
  9 + = time_ago_in_words(event.created_at)
  10 + ago.
  11 +%br
  12 +%span.label= event.merge_request.source_branch
  13 +→
  14 +%span.label= event.merge_request.target_branch
  15 +
... ...
app/views/events/_event_push.html.haml 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +- if event.new_branch?
  2 + = image_tag gravatar_icon(event.pusher_email), :class => "avatar"
  3 + %strong #{event.pusher_name}
  4 + pushed new branch
  5 + = link_to project_commits_path(event.project, :ref => event.branch_name) do
  6 + %strong= event.branch_name
  7 + at
  8 + %strong= link_to event.project.name, event.project
  9 + %span.cgray
  10 + = time_ago_in_words(event.created_at)
  11 + ago.
  12 +- else
  13 + = image_tag gravatar_icon(event.pusher_email), :class => "avatar"
  14 + %strong #{event.pusher_name}
  15 + pushed to
  16 + = link_to project_commits_path(event.project, :ref => event.branch_name) do
  17 + %strong= event.branch_name
  18 + at
  19 + %strong= link_to event.project.name, event.project
  20 + %span.cgray
  21 + = time_ago_in_words(event.created_at)
  22 + ago.
  23 + - if event.commits.count > 1
  24 + = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
  25 + Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
  26 + - @project = event.project
  27 + %ul.unstyled
  28 + = render event.commits
  29 +
  30 +
... ...
app/views/layouts/admin.html.haml
1 1 !!! 5
2 2 %html{ :lang => "en"}
3 3 = render "layouts/head"
4   - %body.ui_basic.admin
  4 + %body{:class => "#{app_theme} admin"}
5 5 = render "layouts/flash"
6 6 = render "layouts/head_panel", :title => "Admin area"
7 7 .container
... ...
app/views/projects/show.html.haml
... ... @@ -14,9 +14,8 @@
14 14 = text_field_tag :project_clone, @project.url_to_repo, :class => "xlarge one_click_select git_clone_url"
15 15  
16 16 = simple_format @project.description
17   -- unless @activities.blank?
18   - .ui-box
19   - %h5.cgray Recent Activity
20   - .content_list= render "feed"
  17 +- unless @events.blank?
  18 + %h5.cgray Recent Activity
  19 + .content_list= render @events
21 20  
22 21  
... ...