Commit cd9f135a660d835763d63a7ffaefb325f03faaeb
Exists in
master
and in
4 other branches
Merge pull request #1717 from riyad/add-author-to-tree-listing
Update author info in tree listing
Showing
6 changed files
with
48 additions
and
16 deletions
Show diff stats
app/assets/stylesheets/sections/tree.scss
@@ -52,14 +52,26 @@ | @@ -52,14 +52,26 @@ | ||
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | - .tree-commit-link { | ||
56 | - color:#333; | 55 | + .tree_author { |
56 | + padding-right: 8px; | ||
57 | + | ||
58 | + img.avatar { | ||
59 | + border: 0 none; | ||
60 | + float: none; | ||
61 | + margin-right: 0; | ||
62 | + padding: 0; | ||
63 | + width: 16px; | ||
64 | + } | ||
57 | } | 65 | } |
58 | 66 | ||
59 | - a.tree-commit-link { | ||
60 | - color: #666; | ||
61 | - &:hover { | ||
62 | - text-decoration: underline; | 67 | + .tree_commit { |
68 | + color: gray; | ||
69 | + | ||
70 | + .tree-commit-link { | ||
71 | + color: #444; | ||
72 | + &:hover { | ||
73 | + text-decoration: underline; | ||
74 | + } | ||
63 | } | 75 | } |
64 | } | 76 | } |
65 | } | 77 | } |
app/decorators/commit_decorator.rb
@@ -42,6 +42,28 @@ class CommitDecorator < ApplicationDecorator | @@ -42,6 +42,28 @@ class CommitDecorator < ApplicationDecorator | ||
42 | end | 42 | end |
43 | end | 43 | end |
44 | 44 | ||
45 | + # Returns a link to the commit author. If the author has a matching user and | ||
46 | + # is a member of the current @project it will link to the team member page. | ||
47 | + # Otherwise it will link to the author email as specified in the commit. | ||
48 | + # | ||
49 | + # options: | ||
50 | + # avatar: true will prepend avatar image | ||
51 | + def author_link(options) | ||
52 | + text = if options[:avatar] | ||
53 | + avatar = h.image_tag h.gravatar_icon(author_email), class: "avatar", width: 16 | ||
54 | + "#{avatar} #{author_name}" | ||
55 | + else | ||
56 | + author_name | ||
57 | + end | ||
58 | + team_member = @project.try(:team_member_by_name_or_email, author_name, author_email) | ||
59 | + | ||
60 | + if team_member.nil? | ||
61 | + h.mail_to author_email, text.html_safe, class: "commit-author-link" | ||
62 | + else | ||
63 | + h.link_to text, h.project_team_member_path(@project, team_member), class: "commit-author-link" | ||
64 | + end | ||
65 | + end | ||
66 | + | ||
45 | protected | 67 | protected |
46 | 68 | ||
47 | def no_commit_message | 69 | def no_commit_message |
app/roles/team.rb
1 | module Team | 1 | module Team |
2 | - def team_member_by_name_or_email(email = nil, name = nil) | ||
3 | - user = users.where("email like ? or name like ?", email, name).first | ||
4 | - users_projects.find_by_user_id(user.id) if user | 2 | + def team_member_by_name_or_email(name = nil, email = nil) |
3 | + user = users.where("name like ? or email like ?", name, email).first | ||
4 | + users_projects.where(user: user) if user | ||
5 | end | 5 | end |
6 | 6 | ||
7 | # Get Team Member record by user id | 7 | # Get Team Member record by user id |
app/views/refs/logs_tree.js.haml
1 | - @logs.each do |content_data| | 1 | - @logs.each do |content_data| |
2 | - file_name = content_data[:file_name] | 2 | - file_name = content_data[:file_name] |
3 | - - content_commit = content_data[:commit] | ||
4 | - - tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name) | 3 | + - commit = content_data[:commit] |
5 | 4 | ||
6 | :plain | 5 | :plain |
7 | var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); | 6 | var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); |
8 | - row.find("td.tree_time_ago").html('#{escape_javascript(time_ago_in_words(content_commit.committed_date))} ago'); | ||
9 | - row.find("td.tree_commit").html('#{escape_javascript(render("tree/tree_commit", tm: tm, content_commit: content_commit))}'); | 7 | + row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago'); |
8 | + row.find("td.tree_commit").html('#{escape_javascript render("tree/tree_commit_column", commit: commit)}'); |
app/views/tree/_tree_commit.html.haml