Commit d65d245e authored by Douwe Maan's avatar Douwe Maan

Add link to diff header too

parent 2c0de7aa
...@@ -61,10 +61,17 @@ module NotesHelper ...@@ -61,10 +61,17 @@ module NotesHelper
end end
def discussion_diff_path(discussion) def discussion_diff_path(discussion)
return unless discussion.diff_discussion? if discussion.for_merge_request?
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
return
end
if discussion.for_merge_request? && discussion.active? diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, diff_id: diff_id, anchor: discussion.line_code)
diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: discussion.line_code)
elsif discussion.for_commit? elsif discussion.for_commit?
namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: discussion.line_code) namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: discussion.line_code)
end end
......
...@@ -20,24 +20,19 @@ ...@@ -20,24 +20,19 @@
= discussion.author.to_reference = discussion.author.to_reference
started a discussion started a discussion
- url = discussion_diff_path(discussion)
- if discussion.for_commit? && @noteable != discussion.noteable - if discussion.for_commit? && @noteable != discussion.noteable
on on
- commit = discussion.noteable - commit = discussion.noteable
- if commit - if commit
commit commit
- anchor = discussion.line_code if discussion.diff_discussion? = link_to commit.short_id, discussion_diff_path(discussion), class: 'monospace'
= link_to commit.short_id, namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: anchor), class: 'monospace'
- else - else
a deleted commit a deleted commit
- elsif discussion.diff_discussion?
on
- if discussion.active?
= link_to 'the diff', discussion_diff_path(discussion)
- else - else
- merge_request_diff = discussion.latest_merge_request_diff = conditional_link_to url.present?, url do
- if merge_request_diff - if discussion.active?
= link_to diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, diff_id: merge_request_diff, anchor: discussion.line_code) do the diff
an outdated diff
- else - else
an outdated diff an outdated diff
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment