Commit 2e9c0e2b47ab1813a96af7afa08f4449eb4e2c2d
1 parent
843ea5bf
Exists in
master
and in
4 other branches
switch to use link_to_member to prevent 500 if user is a project owner but does …
…not have membership and leave comment
Showing
5 changed files
with
15 additions
and
10 deletions
Show diff stats
app/assets/stylesheets/gitlab_bootstrap/common.scss
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | > a { | 60 | > a { |
| 61 | padding: 8px 20px; | 61 | padding: 8px 20px; |
| 62 | margin-right: 7px; | 62 | margin-right: 7px; |
| 63 | - line-height: 19px; | 63 | + line-height: 20px; |
| 64 | border-color: #EEE; | 64 | border-color: #EEE; |
| 65 | color: #888; | 65 | color: #888; |
| 66 | border-bottom: 1px solid #ddd; | 66 | border-bottom: 1px solid #ddd; |
app/assets/stylesheets/sections/notes.scss
| @@ -22,7 +22,7 @@ ul.notes { | @@ -22,7 +22,7 @@ ul.notes { | ||
| 22 | .note-last-update { | 22 | .note-last-update { |
| 23 | font-style: italic; | 23 | font-style: italic; |
| 24 | } | 24 | } |
| 25 | - .note-author { | 25 | + .author { |
| 26 | color: $style_color; | 26 | color: $style_color; |
| 27 | font-weight: bold; | 27 | font-weight: bold; |
| 28 | &:hover { | 28 | &:hover { |
app/helpers/projects_helper.rb
| @@ -20,16 +20,21 @@ module ProjectsHelper | @@ -20,16 +20,21 @@ module ProjectsHelper | ||
| 20 | end | 20 | end |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | - def link_to_member(project, author) | 23 | + def link_to_member(project, author, opts = {}) |
| 24 | + default_opts = { avatar: true } | ||
| 25 | + opts = default_opts.merge(opts) | ||
| 26 | + | ||
| 24 | return "(deleted)" unless author | 27 | return "(deleted)" unless author |
| 25 | 28 | ||
| 29 | + author_html = "" | ||
| 30 | + | ||
| 26 | # Build avatar image tag | 31 | # Build avatar image tag |
| 27 | - avatar = image_tag(gravatar_icon(author.try(:email)), width: 16, class: "lil_av") | 32 | + author_html << image_tag(gravatar_icon(author.try(:email)), width: 16, class: "lil_av") if opts[:avatar] |
| 28 | 33 | ||
| 29 | # Build name span tag | 34 | # Build name span tag |
| 30 | - name = content_tag :span, author.name, class: 'author' | 35 | + author_html << content_tag(:span, sanitize(author.name), class: 'author') |
| 31 | 36 | ||
| 32 | - author_html = avatar + name | 37 | + author_html = author_html.html_safe |
| 33 | 38 | ||
| 34 | tm = project.team_member_by_id(author) | 39 | tm = project.team_member_by_id(author) |
| 35 | 40 | ||
| @@ -37,7 +42,7 @@ module ProjectsHelper | @@ -37,7 +42,7 @@ module ProjectsHelper | ||
| 37 | link_to author_html, project_team_member_path(project, tm), class: "author_link" | 42 | link_to author_html, project_team_member_path(project, tm), class: "author_link" |
| 38 | else | 43 | else |
| 39 | author_html | 44 | author_html |
| 40 | - end | 45 | + end.html_safe |
| 41 | end | 46 | end |
| 42 | 47 | ||
| 43 | def tm_path team_member | 48 | def tm_path team_member |
app/views/notes/_discussion.html.haml
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | Show discussion | 10 | Show discussion |
| 11 | = image_tag gravatar_icon(note.author.email), class: "avatar s32" | 11 | = image_tag gravatar_icon(note.author.email), class: "avatar s32" |
| 12 | %div | 12 | %div |
| 13 | - = link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author" | 13 | + = link_to_member(@project, note.author, avatar: false) |
| 14 | - if note.for_merge_request? | 14 | - if note.for_merge_request? |
| 15 | - if note.diff | 15 | - if note.diff |
| 16 | started a discussion on this merge request diff | 16 | started a discussion on this merge request diff |
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | %div | 30 | %div |
| 31 | - last_note = discussion_notes.last | 31 | - last_note = discussion_notes.last |
| 32 | last updated by | 32 | last updated by |
| 33 | - = link_to last_note.author_name, project_team_member_path(@project, @project.team_member_by_id(last_note.author)), class: "note-author" | 33 | + = link_to_member(@project, last_note.author, avatar: false) |
| 34 | %span.discussion-last-update | 34 | %span.discussion-last-update |
| 35 | = time_ago_in_words(last_note.updated_at) | 35 | = time_ago_in_words(last_note.updated_at) |
| 36 | ago | 36 | ago |
app/views/notes/_note.html.haml
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do | 9 | = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do |
| 10 | %i.icon-trash.cred | 10 | %i.icon-trash.cred |
| 11 | = image_tag gravatar_icon(note.author.email), class: "avatar s32" | 11 | = image_tag gravatar_icon(note.author.email), class: "avatar s32" |
| 12 | - = link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author" | 12 | + = link_to_member(@project, note.author, avatar: false) |
| 13 | %span.note-last-update | 13 | %span.note-last-update |
| 14 | = time_ago_in_words(note.updated_at) | 14 | = time_ago_in_words(note.updated_at) |
| 15 | ago | 15 | ago |