Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
71e4175f
Commit
71e4175f
authored
8 years ago
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix behavior around MRs that need legacy diff notes
parent
5a8f727f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
21 deletions
+28
-21
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+28
-21
No files found.
app/helpers/notes_helper.rb
View file @
71e4175f
...
...
@@ -25,14 +25,15 @@ module NotesHelper
end
def
diff_view_data
return
{}
unless
defined?
(
@comments_target
)
&&
@comments_target
.
any?
return
{}
unless
@comments_target
@comments_target
.
slice
(
:noteable_id
,
:noteable_type
,
:commit_id
)
end
def
use_legacy_diff_notes?
(
line_cod
e
)
return
@use_legacy_diff_notes
if
defined?
(
@use_legacy_diff_notes
)
def
diff_view_line_data
(
line_code
,
position
,
line_typ
e
)
return
if
@diff_notes_disabled
use_legacy_diff_note
=
@use_legacy_diff_notes
# If the controller doesn't force the use of legacy diff notes, we
# determine this on a line-by-line basis by seeing if there already exist
# active legacy diff notes at this line, in which case newly created notes
...
...
@@ -42,36 +43,42 @@ module NotesHelper
# are incompatible.
# If we didn't, diff notes that would show for the same line on the changes
# tab, would show in different discussions on the discussion tab.
line_diff_notes
=
@grouped_diff_notes
[
line_code
]
@use_legacy_diff_notes
=
line_diff_notes
&&
line_diff_notes
.
any?
(
&
:legacy_diff_note?
)
end
def
diff_view_line_data
(
line_code
,
position
,
line_type
)
return
if
@diff_notes_disabled
use_legacy_diff_note
||=
begin
line_diff_notes
=
@grouped_diff_notes
[
line_code
]
@use_legacy_diff_notes
=
line_diff_notes
&&
line_diff_notes
.
any?
(
&
:legacy_diff_note?
)
end
{
data
=
{
line_code:
line_code
,
position:
position
.
to_json
,
line_type:
line_type
,
note_type:
(
use_legacy_diff_notes?
(
line_code
)
?
LegacyDiffNote
.
name
:
DiffNote
.
name
),
discussion_id:
discussion_id
(
line_code
,
position
)
}
end
def
discussion_id
(
line_code
,
position
)
if
use_legacy_diff_notes?
(
line_code
)
LegacyDiffNote
.
build_discussion_id
(
if
use_legacy_diff_note
discussion_id
=
LegacyDiffNote
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
line_code
)
data
.
merge!
(
note_type:
LegacyDiffNote
.
name
,
discussion_id:
discussion_id
)
else
discussion_id
=
DiffNote
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
position
)
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
position
)
data
.
merge!
(
position:
position
.
to_json
,
note_type:
DiffNote
.
name
,
discussion_id:
discussion_id
)
end
data
end
def
link_to_reply_discussion
(
note
,
line_type
=
nil
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment