diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-04 00:27:34 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-04 00:27:34 +0300 |
commit | 21e4f0534d2d9faa5ef9826b990ed32e90ea0426 (patch) | |
tree | 5d3b2873df822adc062d2b4be851ce958d93ec76 /app/helpers | |
parent | c1e2da9293bb036280c05ee6b99952b067bdc316 (diff) | |
parent | f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47 (diff) |
Merge branch 'dm-link-discussion-to-outdated-diff' into 'master'
Allow commenting on older versions of the diff and comparisons between diff versions
See merge request !10388
Diffstat (limited to 'app/helpers')
-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? |