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
app/assets/stylesheets/sections/notes.scss
app/helpers/projects_helper.rb
| ... | ... | @@ -20,16 +20,21 @@ module ProjectsHelper |
| 20 | 20 | end |
| 21 | 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 | 27 | return "(deleted)" unless author |
| 25 | 28 | |
| 29 | + author_html = "" | |
| 30 | + | |
| 26 | 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 | 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 | 39 | tm = project.team_member_by_id(author) |
| 35 | 40 | |
| ... | ... | @@ -37,7 +42,7 @@ module ProjectsHelper |
| 37 | 42 | link_to author_html, project_team_member_path(project, tm), class: "author_link" |
| 38 | 43 | else |
| 39 | 44 | author_html |
| 40 | - end | |
| 45 | + end.html_safe | |
| 41 | 46 | end |
| 42 | 47 | |
| 43 | 48 | def tm_path team_member | ... | ... |
app/views/notes/_discussion.html.haml
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | Show discussion |
| 11 | 11 | = image_tag gravatar_icon(note.author.email), class: "avatar s32" |
| 12 | 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 | 14 | - if note.for_merge_request? |
| 15 | 15 | - if note.diff |
| 16 | 16 | started a discussion on this merge request diff |
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | %div |
| 31 | 31 | - last_note = discussion_notes.last |
| 32 | 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 | 34 | %span.discussion-last-update |
| 35 | 35 | = time_ago_in_words(last_note.updated_at) |
| 36 | 36 | ago | ... | ... |
app/views/notes/_note.html.haml
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 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 | 10 | %i.icon-trash.cred |
| 11 | 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 | 13 | %span.note-last-update |
| 14 | 14 | = time_ago_in_words(note.updated_at) |
| 15 | 15 | ago | ... | ... |