diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-30 15:32:09 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-03 14:47:21 -0500 |
commit | f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47 (patch) | |
tree | 15816b09ecdebbd4eb797195b90cb4f46b6819c4 /app/helpers/notes_helper.rb | |
parent | 185fd98fd4cb8f920558aea3795c4e1774cd39f5 (diff) | |
download | gitlab-ce-f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47.tar.gz |
Allow commenting on older versions of the diff and comparisons between diff versionsdm-link-discussion-to-outdated-diff
Diffstat (limited to 'app/helpers/notes_helper.rb')
-rw-r--r-- | app/helpers/notes_helper.rb | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index eab0738a368..08180883eb9 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -60,20 +60,16 @@ module NotesHelper note.project.team.human_max_access(note.author_id) end - def discussion_diff_path(discussion) - if discussion.for_merge_request? && discussion.diff_discussion? - if discussion.active? - # Without a diff ID, the link always points to the latest diff version - diff_id = nil - elsif merge_request_diff = discussion.latest_merge_request_diff - diff_id = merge_request_diff.id - else - # If the discussion is not active, and we cannot find the latest - # merge request diff for this discussion, we return no path at all. - return - end - - diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, diff_id: diff_id, anchor: discussion.line_code) + def discussion_path(discussion) + if discussion.for_merge_request? + return unless discussion.diff_discussion? + + version_params = discussion.merge_request_version_params + return unless version_params + + path_params = version_params.merge(anchor: discussion.line_code) + + diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, path_params) elsif discussion.for_commit? anchor = discussion.line_code if discussion.diff_discussion? |