Commit 00dc34e1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Events improved & refactored. Dashboard pollished

parent 3ac9c3ad
...@@ -67,6 +67,12 @@ a:focus { ...@@ -67,6 +67,12 @@ a:focus {
} }
} }
.event_label {
background: #FCEEC1;
padding:0 2px;
font-family: monospace;
}
.tabs > li > a, .pills > li > a { .tabs > li > a, .pills > li > a {
color:$style_color; color:$style_color;
} }
...@@ -126,6 +132,9 @@ a:focus { ...@@ -126,6 +132,9 @@ a:focus {
.ipadded { .ipadded {
padding:20px !important; padding:20px !important;
} }
.lborder {
border-left:1px solid #eee;
}
.no-borders { .no-borders {
border:none; border:none;
} }
...@@ -872,10 +881,9 @@ p.time { ...@@ -872,10 +881,9 @@ p.time {
border:none; border:none;
padding:0px 5px; padding:0px 5px;
.project_link {
color:#888;
&:hover { &:hover {
background:$hover;
//border-left:4px solid $styled_border_color;
h4 {
color:#111; color:#111;
.ico.project { .ico.project {
background-position:-209px -21px; background-position:-209px -21px;
...@@ -1077,7 +1085,6 @@ p.time { ...@@ -1077,7 +1085,6 @@ p.time {
} }
.arrow{ .arrow{
float: right;
background: #E3E5EA; background: #E3E5EA;
padding: 5px; padding: 5px;
margin-top:5px; margin-top:5px;
......
...@@ -9,6 +9,8 @@ class Event < ActiveRecord::Base ...@@ -9,6 +9,8 @@ class Event < ActiveRecord::Base
Commented = 6 Commented = 6
Merged = 7 Merged = 7
does "event/push"
belongs_to :project belongs_to :project
belongs_to :target, :polymorphic => true belongs_to :target, :polymorphic => true
...@@ -30,14 +32,17 @@ class Event < ActiveRecord::Base ...@@ -30,14 +32,17 @@ class Event < ActiveRecord::Base
# - new issue # - new issue
# - merge request # - merge request
def allowed? def allowed?
push? || new_issue? || new_merge_request? || push? || issue? || merge_request?
changed_merge_request? || changed_issue?
end end
def push? def push?
action == self.class::Pushed action == self.class::Pushed
end end
def merged?
action == self.class::Merged
end
def closed? def closed?
action == self.class::Closed action == self.class::Closed
end end
...@@ -46,28 +51,12 @@ class Event < ActiveRecord::Base ...@@ -46,28 +51,12 @@ class Event < ActiveRecord::Base
action == self.class::Reopened action == self.class::Reopened
end end
def new_tag? def issue?
data[:ref]["refs/tags"] target_type == "Issue"
end
def new_branch?
data[:before] =~ /^00000/
end
def commit_from
data[:before]
end
def commit_to
data[:after]
end
def branch_name
@branch_name ||= data[:ref].gsub("refs/heads/", "")
end end
def tag_name def merge_request?
@tag_name ||= data[:ref].gsub("refs/tags/", "") target_type == "MergeRequest"
end end
def new_issue? def new_issue?
...@@ -102,9 +91,13 @@ class Event < ActiveRecord::Base ...@@ -102,9 +91,13 @@ class Event < ActiveRecord::Base
@author ||= User.find(author_id) @author ||= User.find(author_id)
end end
def commits def action_name
@commits ||= data[:commits].map do |commit| if closed?
project.commit(commit[:id]) "closed"
elsif merged?
"merged"
else
"opened"
end end
end end
......
module Event::PushTrait
as_trait do
def tag?
data[:ref]["refs/tags"]
end
def new_branch?
data[:before] =~ /^00000/
end
def new_ref?
data[:before] =~ /^00000/
end
def rm_ref?
data[:after] =~ /^00000/
end
def md_ref?
!(rm_ref? || new_ref?)
end
def commit_from
data[:before]
end
def commit_to
data[:after]
end
def ref_name
if tag?
tag_name
else
branch_name
end
end
def branch_name
@branch_name ||= data[:ref].gsub("refs/heads/", "")
end
def tag_name
@tag_name ||= data[:ref].gsub("refs/tags/", "")
end
def commits
@commits ||= data[:commits].map do |commit|
project.commit(commit[:id])
end
end
def ref_type
tag? ? "tag" : "branch"
end
def push_action_name
if new_ref?
"pushed new"
elsif rm_ref?
"removed #{ref_type}"
else
"pushed to"
end
end
end
end
- projects.first(5).each do |project| - projects.first(5).each do |project|
%div.dash_project_item %div.dash_project_item
= link_to project do
%h4 %h4
= link_to project, :class => "project_link" do
%span.ico.project %span.ico.project
= truncate project.name, :length => 30 = truncate project.name, :length => 24
%small %small
last activity at last activity at
= project.last_activity_date.stamp("Aug 25, 2011") = project.last_activity_date.stamp("Aug 25, 2011")
%span.right.arrow
&rarr; .right
%small
%strong= link_to "Browse Code »", tree_project_ref_path(project, project.root_ref), :class => "vlink"
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
.dashboard_block .dashboard_block
.row .row
.span4.right .span4.right
%div.borders.ipadded %div.lborder.ipadded
%h1 %h3
= pluralize current_user.projects.count, "project", "projects" = pluralize current_user.projects.count, "project", "projects"
- if current_user.can_create_project? - if current_user.can_create_project?
%hr %hr
......
- if event.allowed? - if event.allowed?
.event_feed .event_feed
- if event.new_issue? - if event.issue?
= render "events/event_new_issue", :event => event = render "events/event_issue", :event => event
- elsif event.new_merge_request? - elsif event.merge_request?
= render "events/event_new_merge_request", :event => event = render "events/event_merge_request", :event => event
- elsif event.changed_merge_request?
= render "events/event_changed_merge_request", :event => event
- elsif event.changed_issue?
= render "events/event_changed_issue", :event => event
- elsif event.push? - elsif event.push?
= render "events/event_push", :event => event = render "events/event_push", :event => event
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
%span.label.important
- if event.closed?
closed
- else
reopened
&nbsp;issue
= link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
%span.label.important
- if event.closed?
closed
- else
reopened
&nbsp;merge request
= link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
%br
%span.label= event.merge_request.source_branch
&rarr;
%span.label= event.merge_request.target_branch
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
%span.label.success created %span.event_label= event.action_name
&nbsp;new issue &nbsp;issue
= link_to project_issue_path(event.project, event.issue) do = link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title %strong= truncate event.issue_title
at at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
%span.label.success requested %span.event_label= event.action_name
&nbsp;merge &nbsp;merge request
= link_to project_merge_request_path(event.project, event.merge_request) do = link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title %strong= truncate event.merge_request_title
at at
...@@ -10,7 +10,7 @@ at ...@@ -10,7 +10,7 @@ at
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
%br %br
%span.label= event.merge_request.source_branch %span= event.merge_request.source_branch
&rarr; &rarr;
%span.label= event.merge_request.target_branch %span= event.merge_request.target_branch
- if event.new_branch? || event.new_tag? %div
= image_tag gravatar_icon(event.author_email), :class => "avatar" = image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name} %strong #{event.author_name}
%span.label.pushed pushed %span.event_label= event.push_action_name
&nbsp;new = link_to project_commits_path(event.project, :ref => event.ref_name) do
- if event.new_tag? %strong= event.ref_name
tag
= link_to project_commits_path(event.project, :ref => event.tag_name) do
%strong= event.tag_name
- else
branch
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
- else
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
%span.label.pushed pushed
&nbsp;to
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
at at
%strong= link_to event.project.name, event.project %strong= link_to event.project.name, event.project
%span.cgray %span.cgray
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
- if event.md_ref?
- if event.commits.count > 1 - if event.commits.count > 1
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
%strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]} %strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment