diff options
author | Robert Speicher <robert@gitlab.com> | 2016-03-29 23:25:12 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-03-29 23:25:12 +0300 |
commit | f7d20a6f76de33624f069185d28649e6e9b411f7 (patch) | |
tree | 59efe3dd92c0b91de78d818e438621221b5862e2 | |
parent | 999ae7f76b275d4b8527a7ebbc012b20220e22b5 (diff) | |
parent | 191b9e3f05e8fa882e3eaf29cb4f85a942038987 (diff) |
Merge branch 'fix-mr-comment-commit-pruned' into 'master'
Gracefully handle notes on deleted commits in merge requests
Closes #3250
See merge request !3402
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 6 | ||||
-rw-r--r-- | app/views/projects/notes/discussions/_commit.html.haml | 7 |
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG index a74a120fe68..2cd06d90257 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ v 8.7.0 (unreleased) - Handle nil descriptions in Slack issue messages (Stan Hu) - Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.) + - Gracefully handle notes on deleted commits in merge requests (Stan Hu) v 8.6.2 (unreleased) - Comments on confidential issues don't show up in activity feed to non-members diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 53c543c28c5..698f90cb27a 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -5,8 +5,10 @@ module NotesHelper end def note_target_fields(note) - hidden_field_tag(:target_type, note.noteable.class.name.underscore) + - hidden_field_tag(:target_id, note.noteable.id) + if note.noteable + hidden_field_tag(:target_type, note.noteable.class.name.underscore) + + hidden_field_tag(:target_id, note.noteable.id) + end end def note_editable?(note) diff --git a/app/views/projects/notes/discussions/_commit.html.haml b/app/views/projects/notes/discussions/_commit.html.haml index 3da2f2060b8..f67ec8db942 100644 --- a/app/views/projects/notes/discussions/_commit.html.haml +++ b/app/views/projects/notes/discussions/_commit.html.haml @@ -1,4 +1,6 @@ - note = discussion_notes.first +- commit = note.noteable +- commit_description = commit ? 'commit' : 'a deleted commit' .discussion.js-toggle-container{ class: note.discussion_id } .discussion-header .discussion-actions @@ -7,8 +9,9 @@ Show/hide discussion %div = link_to_member(@project, note.author, avatar: false) - started a discussion on commit - = link_to(note.noteable.short_id, namespace_project_commit_path(note.project.namespace, note.project, note.noteable), class: 'monospace') + %p started a discussion on #{commit_description} + - if commit + = link_to(commit.short_id, namespace_project_commit_path(note.project.namespace, note.project, note.noteable), class: 'monospace') .last-update.hide.js-toggle-content - last_note = discussion_notes.last last updated by |