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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
71e4175f
Commit
71e4175f
authored
Jul 07, 2016
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
...
@@ -25,14 +25,15 @@ module NotesHelper
end
end
def
diff_view_data
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
)
@comments_target
.
slice
(
:noteable_id
,
:noteable_type
,
:commit_id
)
end
end
def
use_legacy_diff_notes?
(
line_cod
e
)
def
diff_view_line_data
(
line_code
,
position
,
line_typ
e
)
return
@use_legacy_diff_notes
if
defined?
(
@use_legacy_diff_notes
)
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
# 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
# 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
# active legacy diff notes at this line, in which case newly created notes
...
@@ -42,36 +43,42 @@ module NotesHelper
...
@@ -42,36 +43,42 @@ module NotesHelper
# are incompatible.
# are incompatible.
# If we didn't, diff notes that would show for the same line on the changes
# 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.
# tab, would show in different discussions on the discussion tab.
line_diff_notes
=
@grouped_diff_notes
[
line_code
]
use_legacy_diff_note
||=
begin
@use_legacy_diff_notes
=
line_diff_notes
&&
line_diff_notes
.
any?
(
&
:legacy_diff_note?
)
line_diff_notes
=
@grouped_diff_notes
[
line_code
]
end
@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
{
data
=
{
line_code:
line_code
,
line_code:
line_code
,
position:
position
.
to_json
,
line_type:
line_type
,
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_note
if
use_legacy_diff_notes?
(
line_code
)
discussion_id
=
LegacyDiffNote
.
build_discussion_id
(
LegacyDiffNote
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
line_code
line_code
)
)
data
.
merge!
(
note_type:
LegacyDiffNote
.
name
,
discussion_id:
discussion_id
)
else
else
discussion_id
=
DiffNote
.
build_discussion_id
(
discussion_id
=
DiffNote
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
position
position
)
)
data
.
merge!
(
position:
position
.
to_json
,
note_type:
DiffNote
.
name
,
discussion_id:
discussion_id
)
end
end
data
end
end
def
link_to_reply_discussion
(
note
,
line_type
=
nil
)
def
link_to_reply_discussion
(
note
,
line_type
=
nil
)
...
...
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