Refactored events output. Added links to authors of events

This commit is contained in:
Dmitriy Zaporozhets 2012-10-01 16:39:19 +03:00
parent 433387be35
commit 663dd6fad6
11 changed files with 43 additions and 54 deletions

View file

@ -5,32 +5,23 @@
.event_label {
&.pushed {
padding:0 2px;
@extend .alert;
@extend .alert-info;
}
&.opened {
padding:0 2px;
@extend .alert;
@extend .alert-success;
}
&.closed {
padding:0 2px;
@extend .alert;
@extend .alert-error;
}
&.merged {
padding:0 2px;
@extend .alert;
@extend .alert-success;
}
&.left,
&.joined {
padding:0 2px;
@extend .alert;
float:none;
}
}

View file

@ -0,0 +1,22 @@
module EventsHelper
def link_to_author(event)
project = event.project
tm = project.team_member_by_id(event.author_id)
if tm
link_to event.author_name, project_team_member_path(project, tm)
else
event.author_name
end
end
def event_action_name(event)
target = if event.target_type
event.target_type.titleize.downcase
else
'project'
end
[event.action_name, target].join(" ")
end
end

View file

@ -33,7 +33,7 @@ module IssuesHelper
classes
end
def issue_tags
def issue_tags
@project.issues.tag_counts_on(:labels).map(&:name)
end

View file

@ -6,5 +6,9 @@ module ProjectsHelper
def remove_from_team_message(project, member)
"You are going to remove #{member.user_name} from #{project.name}. Are you sure?"
end
def link_to_project project
link_to project.name, project
end
end

View file

@ -58,6 +58,10 @@ class Event < ActiveRecord::Base
end
end
def target_title
target.try :title
end
def push?
action == self.class::Pushed && valid_push?
end

View file

@ -1,16 +1,9 @@
- if event.allowed?
%div.event-item
- if event.issue?
= render "events/event_issue", event: event
- elsif event.merge_request?
= render "events/event_merge_request", event: event
- elsif event.push?
- if event.push?
= render "events/event_push", event: event
- elsif event.membership_changed?
= render "events/event_membership_changed", event: event
- else
= render "events/event_common", event: event
%span.cgray.right
= time_ago_in_words(event.created_at)

View file

@ -0,0 +1,8 @@
= image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title
%span.author_name= link_to_author event
%span.event_label{class: event.action_name}= event_action_name(event)
= link_to [event.project, event.target] do
%strong= truncate event.target_title
at
= link_to_project event.project

View file

@ -1,8 +0,0 @@
= image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title
%strong.author_name #{event.author_name}
%span.event_label{class: event.action_name} #{event.action_name} 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

View file

@ -1,9 +0,0 @@
= image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title
%strong.author_name #{event.author_name}
%span.event_label{class: event.action_name} #{event.action_name} project
%strong= link_to event.project_name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.

View file

@ -1,16 +0,0 @@
- if event.action_name == "merged"
.event_icon= image_tag "event_mr_merged.png"
= image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title
%strong.author_name #{event.author_name}
%span.event_label{class: event.action_name} #{event.action_name} 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
.event-body
.event-info
%span= event.merge_request.source_branch
&rarr;
%span= event.merge_request.target_branch

View file

@ -3,7 +3,7 @@
= image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title
%strong.author_name #{event.author_name}
%span.author_name= link_to_author event
%span.event_label.pushed #{event.push_action_name} #{event.ref_type}
= link_to project_commits_path(event.project, event.ref_name) do
%strong= event.ref_name