Commit 663dd6fa authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactored events output. Added links to authors of events

parent 433387be
...@@ -5,32 +5,23 @@ ...@@ -5,32 +5,23 @@
.event_label { .event_label {
&.pushed { &.pushed {
padding:0 2px; padding:0 2px;
@extend .alert;
@extend .alert-info;
} }
&.opened { &.opened {
padding:0 2px; padding:0 2px;
@extend .alert;
@extend .alert-success;
} }
&.closed { &.closed {
padding:0 2px; padding:0 2px;
@extend .alert;
@extend .alert-error;
} }
&.merged { &.merged {
padding:0 2px; padding:0 2px;
@extend .alert;
@extend .alert-success;
} }
&.left, &.left,
&.joined { &.joined {
padding:0 2px; padding:0 2px;
@extend .alert;
float:none; float:none;
} }
} }
......
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
...@@ -33,7 +33,7 @@ module IssuesHelper ...@@ -33,7 +33,7 @@ module IssuesHelper
classes classes
end end
def issue_tags def issue_tags
@project.issues.tag_counts_on(:labels).map(&:name) @project.issues.tag_counts_on(:labels).map(&:name)
end end
......
...@@ -6,5 +6,9 @@ module ProjectsHelper ...@@ -6,5 +6,9 @@ module ProjectsHelper
def remove_from_team_message(project, member) def remove_from_team_message(project, member)
"You are going to remove #{member.user_name} from #{project.name}. Are you sure?" "You are going to remove #{member.user_name} from #{project.name}. Are you sure?"
end end
def link_to_project project
link_to project.name, project
end
end end
...@@ -58,6 +58,10 @@ class Event < ActiveRecord::Base ...@@ -58,6 +58,10 @@ class Event < ActiveRecord::Base
end end
end end
def target_title
target.try :title
end
def push? def push?
action == self.class::Pushed && valid_push? action == self.class::Pushed && valid_push?
end end
......
- if event.allowed? - if event.allowed?
%div.event-item %div.event-item
- if event.issue? - if event.push?
= 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 = render "events/event_push", event: event
- else
- elsif event.membership_changed? = render "events/event_common", event: event
= render "events/event_membership_changed", event: event
%span.cgray.right %span.cgray.right
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
......
= 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
= 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
= 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.
- 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
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
= image_tag gravatar_icon(event.author_email), class: "avatar" = image_tag gravatar_icon(event.author_email), class: "avatar"
.event-title .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} %span.event_label.pushed #{event.push_action_name} #{event.ref_type}
= link_to project_commits_path(event.project, event.ref_name) do = link_to project_commits_path(event.project, event.ref_name) do
%strong= event.ref_name %strong= event.ref_name
......
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