Commit 00dc34e1929e914d1f4f194888d9d94e513fdaa5
1 parent
3ac9c3ad
Exists in
master
and in
4 other branches
Events improved & refactored. Dashboard pollished
Showing
13 changed files
with
160 additions
and
147 deletions
Show diff stats
app/assets/stylesheets/common.scss
... | ... | @@ -67,6 +67,12 @@ a:focus { |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | +.event_label { | |
71 | + background: #FCEEC1; | |
72 | + padding:0 2px; | |
73 | + font-family: monospace; | |
74 | +} | |
75 | + | |
70 | 76 | .tabs > li > a, .pills > li > a { |
71 | 77 | color:$style_color; |
72 | 78 | } |
... | ... | @@ -126,6 +132,9 @@ a:focus { |
126 | 132 | .ipadded { |
127 | 133 | padding:20px !important; |
128 | 134 | } |
135 | +.lborder { | |
136 | + border-left:1px solid #eee; | |
137 | +} | |
129 | 138 | .no-borders { |
130 | 139 | border:none; |
131 | 140 | } |
... | ... | @@ -872,10 +881,9 @@ p.time { |
872 | 881 | border:none; |
873 | 882 | padding:0px 5px; |
874 | 883 | |
875 | - &:hover { | |
876 | - background:$hover; | |
877 | - //border-left:4px solid $styled_border_color; | |
878 | - h4 { | |
884 | + .project_link { | |
885 | + color:#888; | |
886 | + &:hover { | |
879 | 887 | color:#111; |
880 | 888 | .ico.project { |
881 | 889 | background-position:-209px -21px; |
... | ... | @@ -1077,7 +1085,6 @@ p.time { |
1077 | 1085 | } |
1078 | 1086 | |
1079 | 1087 | .arrow{ |
1080 | - float: right; | |
1081 | 1088 | background: #E3E5EA; |
1082 | 1089 | padding: 5px; |
1083 | 1090 | margin-top:5px; | ... | ... |
app/models/event.rb
... | ... | @@ -9,6 +9,8 @@ class Event < ActiveRecord::Base |
9 | 9 | Commented = 6 |
10 | 10 | Merged = 7 |
11 | 11 | |
12 | + does "event/push" | |
13 | + | |
12 | 14 | belongs_to :project |
13 | 15 | belongs_to :target, :polymorphic => true |
14 | 16 | |
... | ... | @@ -30,14 +32,17 @@ class Event < ActiveRecord::Base |
30 | 32 | # - new issue |
31 | 33 | # - merge request |
32 | 34 | def allowed? |
33 | - push? || new_issue? || new_merge_request? || | |
34 | - changed_merge_request? || changed_issue? | |
35 | + push? || issue? || merge_request? | |
35 | 36 | end |
36 | 37 | |
37 | 38 | def push? |
38 | 39 | action == self.class::Pushed |
39 | 40 | end |
40 | 41 | |
42 | + def merged? | |
43 | + action == self.class::Merged | |
44 | + end | |
45 | + | |
41 | 46 | def closed? |
42 | 47 | action == self.class::Closed |
43 | 48 | end |
... | ... | @@ -46,28 +51,12 @@ class Event < ActiveRecord::Base |
46 | 51 | action == self.class::Reopened |
47 | 52 | end |
48 | 53 | |
49 | - def new_tag? | |
50 | - data[:ref]["refs/tags"] | |
51 | - end | |
52 | - | |
53 | - def new_branch? | |
54 | - data[:before] =~ /^00000/ | |
55 | - end | |
56 | - | |
57 | - def commit_from | |
58 | - data[:before] | |
59 | - end | |
60 | - | |
61 | - def commit_to | |
62 | - data[:after] | |
54 | + def issue? | |
55 | + target_type == "Issue" | |
63 | 56 | end |
64 | 57 | |
65 | - def branch_name | |
66 | - @branch_name ||= data[:ref].gsub("refs/heads/", "") | |
67 | - end | |
68 | - | |
69 | - def tag_name | |
70 | - @tag_name ||= data[:ref].gsub("refs/tags/", "") | |
58 | + def merge_request? | |
59 | + target_type == "MergeRequest" | |
71 | 60 | end |
72 | 61 | |
73 | 62 | def new_issue? |
... | ... | @@ -101,10 +90,14 @@ class Event < ActiveRecord::Base |
101 | 90 | def author |
102 | 91 | @author ||= User.find(author_id) |
103 | 92 | end |
104 | - | |
105 | - def commits | |
106 | - @commits ||= data[:commits].map do |commit| | |
107 | - project.commit(commit[:id]) | |
93 | + | |
94 | + def action_name | |
95 | + if closed? | |
96 | + "closed" | |
97 | + elsif merged? | |
98 | + "merged" | |
99 | + else | |
100 | + "opened" | |
108 | 101 | end |
109 | 102 | end |
110 | 103 | ... | ... |
... | ... | @@ -0,0 +1,67 @@ |
1 | +module Event::PushTrait | |
2 | + as_trait do | |
3 | + def tag? | |
4 | + data[:ref]["refs/tags"] | |
5 | + end | |
6 | + | |
7 | + def new_branch? | |
8 | + data[:before] =~ /^00000/ | |
9 | + end | |
10 | + | |
11 | + def new_ref? | |
12 | + data[:before] =~ /^00000/ | |
13 | + end | |
14 | + | |
15 | + def rm_ref? | |
16 | + data[:after] =~ /^00000/ | |
17 | + end | |
18 | + | |
19 | + def md_ref? | |
20 | + !(rm_ref? || new_ref?) | |
21 | + end | |
22 | + | |
23 | + def commit_from | |
24 | + data[:before] | |
25 | + end | |
26 | + | |
27 | + def commit_to | |
28 | + data[:after] | |
29 | + end | |
30 | + | |
31 | + def ref_name | |
32 | + if tag? | |
33 | + tag_name | |
34 | + else | |
35 | + branch_name | |
36 | + end | |
37 | + end | |
38 | + | |
39 | + def branch_name | |
40 | + @branch_name ||= data[:ref].gsub("refs/heads/", "") | |
41 | + end | |
42 | + | |
43 | + def tag_name | |
44 | + @tag_name ||= data[:ref].gsub("refs/tags/", "") | |
45 | + end | |
46 | + | |
47 | + def commits | |
48 | + @commits ||= data[:commits].map do |commit| | |
49 | + project.commit(commit[:id]) | |
50 | + end | |
51 | + end | |
52 | + | |
53 | + def ref_type | |
54 | + tag? ? "tag" : "branch" | |
55 | + end | |
56 | + | |
57 | + def push_action_name | |
58 | + if new_ref? | |
59 | + "pushed new" | |
60 | + elsif rm_ref? | |
61 | + "removed #{ref_type}" | |
62 | + else | |
63 | + "pushed to" | |
64 | + end | |
65 | + end | |
66 | + end | |
67 | +end | ... | ... |
app/views/dashboard/_projects_feed.html.haml
1 | 1 | - projects.first(5).each do |project| |
2 | 2 | %div.dash_project_item |
3 | - = link_to project do | |
4 | - %h4 | |
3 | + %h4 | |
4 | + = link_to project, :class => "project_link" do | |
5 | 5 | %span.ico.project |
6 | - = truncate project.name, :length => 30 | |
6 | + = truncate project.name, :length => 24 | |
7 | + %small | |
8 | + last activity at | |
9 | + = project.last_activity_date.stamp("Aug 25, 2011") | |
10 | + | |
11 | + .right | |
7 | 12 | %small |
8 | - last activity at | |
9 | - = project.last_activity_date.stamp("Aug 25, 2011") | |
10 | - %span.right.arrow | |
11 | - → | |
13 | + %strong= link_to "Browse Code »", tree_project_ref_path(project, project.root_ref), :class => "vlink" | ... | ... |
app/views/dashboard/index.html.haml
app/views/events/_event.html.haml
1 | 1 | - if event.allowed? |
2 | 2 | .event_feed |
3 | - - if event.new_issue? | |
4 | - = render "events/event_new_issue", :event => event | |
5 | - - elsif event.new_merge_request? | |
6 | - = render "events/event_new_merge_request", :event => event | |
7 | - - elsif event.changed_merge_request? | |
8 | - = render "events/event_changed_merge_request", :event => event | |
9 | - - elsif event.changed_issue? | |
10 | - = render "events/event_changed_issue", :event => event | |
3 | + - if event.issue? | |
4 | + = render "events/event_issue", :event => event | |
5 | + - elsif event.merge_request? | |
6 | + = render "events/event_merge_request", :event => event | |
11 | 7 | - elsif event.push? |
12 | 8 | = render "events/event_push", :event => event | ... | ... |
app/views/events/_event_changed_issue.html.haml
... | ... | @@ -1,15 +0,0 @@ |
1 | -= image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | -%strong #{event.author_name} | |
3 | -%span.label.important | |
4 | - - if event.closed? | |
5 | - closed | |
6 | - - else | |
7 | - reopened | |
8 | - issue | |
9 | -= link_to project_issue_path(event.project, event.issue) do | |
10 | - %strong= truncate event.issue_title | |
11 | -at | |
12 | -%strong= link_to event.project.name, event.project | |
13 | -%span.cgray | |
14 | - = time_ago_in_words(event.created_at) | |
15 | - ago. |
app/views/events/_event_changed_merge_request.html.haml
... | ... | @@ -1,20 +0,0 @@ |
1 | -= image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | -%strong #{event.author_name} | |
3 | -%span.label.important | |
4 | - - if event.closed? | |
5 | - closed | |
6 | - - else | |
7 | - reopened | |
8 | - merge request | |
9 | -= link_to project_merge_request_path(event.project, event.merge_request) do | |
10 | - %strong= truncate event.merge_request_title | |
11 | -at | |
12 | -%strong= link_to event.project.name, event.project | |
13 | -%span.cgray | |
14 | - = time_ago_in_words(event.created_at) | |
15 | - ago. | |
16 | -%br | |
17 | -%span.label= event.merge_request.source_branch | |
18 | -→ | |
19 | -%span.label= event.merge_request.target_branch | |
20 | - |
... | ... | @@ -0,0 +1,11 @@ |
1 | += image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | +%strong #{event.author_name} | |
3 | +%span.event_label= event.action_name | |
4 | + issue | |
5 | += link_to project_issue_path(event.project, event.issue) do | |
6 | + %strong= truncate event.issue_title | |
7 | +at | |
8 | +%strong= link_to event.project.name, event.project | |
9 | +%span.cgray | |
10 | + = time_ago_in_words(event.created_at) | |
11 | + ago. | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | += image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | +%strong #{event.author_name} | |
3 | +%span.event_label= event.action_name | |
4 | + merge request | |
5 | += link_to project_merge_request_path(event.project, event.merge_request) do | |
6 | + %strong= truncate event.merge_request_title | |
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 | +%br | |
13 | +%span= event.merge_request.source_branch | |
14 | +→ | |
15 | +%span= event.merge_request.target_branch | |
16 | + | ... | ... |
app/views/events/_event_new_issue.html.haml
... | ... | @@ -1,11 +0,0 @@ |
1 | -= image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | -%strong #{event.author_name} | |
3 | -%span.label.success created | |
4 | - new issue | |
5 | -= link_to project_issue_path(event.project, event.issue) do | |
6 | - %strong= truncate event.issue_title | |
7 | -at | |
8 | -%strong= link_to event.project.name, event.project | |
9 | -%span.cgray | |
10 | - = time_ago_in_words(event.created_at) | |
11 | - ago. |
app/views/events/_event_new_merge_request.html.haml
... | ... | @@ -1,16 +0,0 @@ |
1 | -= image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | -%strong #{event.author_name} | |
3 | -%span.label.success requested | |
4 | - merge | |
5 | -= link_to project_merge_request_path(event.project, event.merge_request) do | |
6 | - %strong= truncate event.merge_request_title | |
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 | -%br | |
13 | -%span.label= event.merge_request.source_branch | |
14 | -→ | |
15 | -%span.label= event.merge_request.target_branch | |
16 | - |
app/views/events/_event_push.html.haml
1 | -- if event.new_branch? || event.new_tag? | |
1 | +%div | |
2 | 2 | = image_tag gravatar_icon(event.author_email), :class => "avatar" |
3 | 3 | %strong #{event.author_name} |
4 | - %span.label.pushed pushed | |
5 | - new | |
6 | - - if event.new_tag? | |
7 | - tag | |
8 | - = link_to project_commits_path(event.project, :ref => event.tag_name) do | |
9 | - %strong= event.tag_name | |
10 | - - else | |
11 | - branch | |
12 | - = link_to project_commits_path(event.project, :ref => event.branch_name) do | |
13 | - %strong= event.branch_name | |
4 | + %span.event_label= event.push_action_name | |
5 | + = link_to project_commits_path(event.project, :ref => event.ref_name) do | |
6 | + %strong= event.ref_name | |
14 | 7 | at |
15 | 8 | %strong= link_to event.project.name, event.project |
16 | 9 | %span.cgray |
17 | 10 | = time_ago_in_words(event.created_at) |
18 | 11 | ago. |
19 | -- else | |
20 | - = image_tag gravatar_icon(event.author_email), :class => "avatar" | |
21 | - %strong #{event.author_name} | |
22 | - %span.label.pushed pushed | |
23 | - to | |
24 | - = link_to project_commits_path(event.project, :ref => event.branch_name) do | |
25 | - %strong= event.branch_name | |
26 | - at | |
27 | - %strong= link_to event.project.name, event.project | |
28 | - %span.cgray | |
29 | - = time_ago_in_words(event.created_at) | |
30 | - ago. | |
31 | - - if event.commits.count > 1 | |
32 | - = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do | |
33 | - %strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]} | |
34 | - - project = event.project | |
35 | - %ul.unstyled.event_commits | |
36 | - - if event.commits.size > 3 | |
37 | - - event.commits[0...2].each do |commit| | |
38 | - = render "events/commit", :commit => commit, :project => project | |
39 | - %li | |
40 | - %br | |
41 | - \... and #{event.commits.size - 2} more commits | |
42 | - - else | |
43 | - - event.commits.each do |commit| | |
44 | - = render "events/commit", :commit => commit, :project => project | |
12 | + | |
13 | + - if event.md_ref? | |
14 | + - if event.commits.count > 1 | |
15 | + = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do | |
16 | + %strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]} | |
17 | + - project = event.project | |
18 | + %ul.unstyled.event_commits | |
19 | + - if event.commits.size > 3 | |
20 | + - event.commits[0...2].each do |commit| | |
21 | + = render "events/commit", :commit => commit, :project => project | |
22 | + %li | |
23 | + %br | |
24 | + \... and #{event.commits.size - 2} more commits | |
25 | + - else | |
26 | + - event.commits.each do |commit| | |
27 | + = render "events/commit", :commit => commit, :project => project | |
45 | 28 | ... | ... |