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

Events improved & refactored. Dashboard pollished

parent 3ac9c3ad
......@@ -67,6 +67,12 @@ a:focus {
}
}
.event_label {
background: #FCEEC1;
padding:0 2px;
font-family: monospace;
}
.tabs > li > a, .pills > li > a {
color:$style_color;
}
......@@ -126,6 +132,9 @@ a:focus {
.ipadded {
padding:20px !important;
}
.lborder {
border-left:1px solid #eee;
}
.no-borders {
border:none;
}
......@@ -872,10 +881,9 @@ p.time {
border:none;
padding:0px 5px;
.project_link {
color:#888;
&:hover {
background:$hover;
//border-left:4px solid $styled_border_color;
h4 {
color:#111;
.ico.project {
background-position:-209px -21px;
......@@ -1077,7 +1085,6 @@ p.time {
}
.arrow{
float: right;
background: #E3E5EA;
padding: 5px;
margin-top:5px;
......
......@@ -9,6 +9,8 @@ class Event < ActiveRecord::Base
Commented = 6
Merged = 7
does "event/push"
belongs_to :project
belongs_to :target, :polymorphic => true
......@@ -30,14 +32,17 @@ class Event < ActiveRecord::Base
# - new issue
# - merge request
def allowed?
push? || new_issue? || new_merge_request? ||
changed_merge_request? || changed_issue?
push? || issue? || merge_request?
end
def push?
action == self.class::Pushed
end
def merged?
action == self.class::Merged
end
def closed?
action == self.class::Closed
end
......@@ -46,28 +51,12 @@ class Event < ActiveRecord::Base
action == self.class::Reopened
end
def new_tag?
data[:ref]["refs/tags"]
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/", "")
def issue?
target_type == "Issue"
end
def tag_name
@tag_name ||= data[:ref].gsub("refs/tags/", "")
def merge_request?
target_type == "MergeRequest"
end
def new_issue?
......@@ -102,9 +91,13 @@ class Event < ActiveRecord::Base
@author ||= User.find(author_id)
end
def commits
@commits ||= data[:commits].map do |commit|
project.commit(commit[:id])
def action_name
if closed?
"closed"
elsif merged?
"merged"
else
"opened"
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|
%div.dash_project_item
= link_to project do
%h4
= link_to project, :class => "project_link" do
%span.ico.project
= truncate project.name, :length => 30
= truncate project.name, :length => 24
%small
last activity at
= 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 @@
.dashboard_block
.row
.span4.right
%div.borders.ipadded
%h1
%div.lborder.ipadded
%h3
= pluralize current_user.projects.count, "project", "projects"
- if current_user.can_create_project?
%hr
......
- if event.allowed?
.event_feed
- if event.new_issue?
= render "events/event_new_issue", :event => event
- elsif event.new_merge_request?
= render "events/event_new_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
- if event.issue?
= render "events/event_issue", :event => event
- elsif event.merge_request?
= render "events/event_merge_request", :event => event
- elsif event.push?
= 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"
%strong #{event.author_name}
%span.label.success created
&nbsp;new issue
%span.event_label= event.action_name
&nbsp;issue
= link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title
at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
%span.label.success requested
&nbsp;merge
%span.event_label= event.action_name
&nbsp;merge request
= link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title
at
......@@ -10,7 +10,7 @@ at
= time_ago_in_words(event.created_at)
ago.
%br
%span.label= event.merge_request.source_branch
%span= event.merge_request.source_branch
&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"
%strong #{event.author_name}
%span.label.pushed pushed
&nbsp;new
- if event.new_tag?
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
%span.event_label= event.push_action_name
= link_to project_commits_path(event.project, :ref => event.ref_name) do
%strong= event.ref_name
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
- if event.md_ref?
- 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
%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