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
b2dbc936
Commit
b2dbc936
authored
Jul 23, 2018
by
Tim Zallmann
Committed by
Fatih Acet
Jul 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reducing the memory footprint for the rendering
parent
58a0df7e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
149 additions
and
94 deletions
+149
-94
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+9
-10
app/assets/javascripts/diffs/components/diff_table_cell.vue
app/assets/javascripts/diffs/components/diff_table_cell.vue
+6
-0
app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
.../javascripts/diffs/components/inline_diff_comment_row.vue
+6
-5
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
...ts/javascripts/diffs/components/inline_diff_table_row.vue
+7
-0
app/assets/javascripts/diffs/components/inline_diff_view.vue
app/assets/javascripts/diffs/components/inline_diff_view.vue
+9
-14
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
...avascripts/diffs/components/parallel_diff_comment_row.vue
+27
-26
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
.../javascripts/diffs/components/parallel_diff_table_row.vue
+12
-0
app/assets/javascripts/diffs/components/parallel_diff_view.vue
...ssets/javascripts/diffs/components/parallel_diff_view.vue
+10
-28
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+53
-10
changelogs/unreleased/tz-mr-refactor-memory-reduction.yml
changelogs/unreleased/tz-mr-refactor-memory-reduction.yml
+5
-0
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
...scripts/diffs/components/diff_line_gutter_content_spec.js
+5
-1
No files found.
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
View file @
b2dbc936
...
@@ -71,6 +71,11 @@ export default {
...
@@ -71,6 +71,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapState
({
...
mapState
({
...
@@ -78,7 +83,6 @@ export default {
...
@@ -78,7 +83,6 @@ export default {
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
}),
}),
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
discussionsByLineCode
'
]),
lineHref
()
{
lineHref
()
{
return
this
.
lineCode
?
`#
${
this
.
lineCode
}
`
:
'
#
'
;
return
this
.
lineCode
?
`#
${
this
.
lineCode
}
`
:
'
#
'
;
},
},
...
@@ -88,24 +92,19 @@ export default {
...
@@ -88,24 +92,19 @@ export default {
this
.
showCommentButton
&&
this
.
showCommentButton
&&
!
this
.
isMatchLine
&&
!
this
.
isMatchLine
&&
!
this
.
isContextLine
&&
!
this
.
isContextLine
&&
!
this
.
hasDiscussions
&&
!
this
.
isMetaLine
&&
!
this
.
isMetaLine
!
this
.
hasDiscussions
);
);
},
},
discussions
()
{
return
this
.
discussionsByLineCode
[
this
.
lineCode
]
||
[];
},
hasDiscussions
()
{
hasDiscussions
()
{
return
this
.
discussions
.
length
>
0
;
return
this
.
discussions
.
length
>
0
;
},
},
shouldShowAvatarsOnGutter
()
{
shouldShowAvatarsOnGutter
()
{
let
render
=
this
.
hasDiscussions
&&
this
.
showCommentButton
;
if
(
!
this
.
lineType
&&
this
.
linePosition
===
LINE_POSITION_RIGHT
)
{
if
(
!
this
.
lineType
&&
this
.
linePosition
===
LINE_POSITION_RIGHT
)
{
re
nder
=
false
;
re
turn
false
;
}
}
return
render
;
return
this
.
hasDiscussions
&&
this
.
showCommentButton
;
},
},
},
},
methods
:
{
methods
:
{
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
View file @
b2dbc936
...
@@ -67,6 +67,11 @@ export default {
...
@@ -67,6 +67,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
...
@@ -136,6 +141,7 @@ export default {
...
@@ -136,6 +141,7 @@ export default {
:is-match-line=
"isMatchLine"
:is-match-line=
"isMatchLine"
:is-context-line=
"isContentLine"
:is-context-line=
"isContentLine"
:is-meta-line=
"isMetaLine"
:is-meta-line=
"isMetaLine"
:discussions=
"discussions"
/>
/>
</td>
</td>
</
template
>
</
template
>
app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
View file @
b2dbc936
<
script
>
<
script
>
import
{
mapState
,
mapGetters
}
from
'
vuex
'
;
import
{
mapState
}
from
'
vuex
'
;
import
diffDiscussions
from
'
./diff_discussions.vue
'
;
import
diffDiscussions
from
'
./diff_discussions.vue
'
;
import
diffLineNoteForm
from
'
./diff_line_note_form.vue
'
;
import
diffLineNoteForm
from
'
./diff_line_note_form.vue
'
;
...
@@ -21,15 +21,16 @@ export default {
...
@@ -21,15 +21,16 @@ export default {
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
},
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
mapGetters
(
'
diffs
'
,
[
'
discussionsByLineCode
'
]),
discussions
()
{
return
this
.
discussionsByLineCode
[
this
.
line
.
lineCode
]
||
[];
},
className
()
{
className
()
{
return
this
.
discussions
.
length
?
''
:
'
js-temp-notes-holder
'
;
return
this
.
discussions
.
length
?
''
:
'
js-temp-notes-holder
'
;
},
},
...
...
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
View file @
b2dbc936
...
@@ -33,6 +33,11 @@ export default {
...
@@ -33,6 +33,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -89,6 +94,7 @@ export default {
...
@@ -89,6 +94,7 @@ export default {
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isHover"
:is-hover=
"isHover"
:show-comment-button=
"true"
:show-comment-button=
"true"
:discussions=
"discussions"
class=
"diff-line-num old_line"
class=
"diff-line-num old_line"
/>
/>
<diff-table-cell
<diff-table-cell
...
@@ -98,6 +104,7 @@ export default {
...
@@ -98,6 +104,7 @@ export default {
:line-type=
"newLineType"
:line-type=
"newLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isHover"
:is-hover=
"isHover"
:discussions=
"discussions"
class=
"diff-line-num new_line"
class=
"diff-line-num new_line"
/>
/>
<td
<td
...
...
app/assets/javascripts/diffs/components/inline_diff_view.vue
View file @
b2dbc936
...
@@ -20,7 +20,11 @@ export default {
...
@@ -20,7 +20,11 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
,
'
discussionsByLineCode
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
,
'
shouldRenderInlineCommentRow
'
,
'
singleDiscussionByLineCode
'
,
]),
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
@@ -34,18 +38,7 @@ export default {
...
@@ -34,18 +38,7 @@ export default {
return
window
.
gon
.
user_color_scheme
;
return
window
.
gon
.
user_color_scheme
;
},
},
},
},
methods
:
{
methods
:
{},
shouldRenderCommentRow
(
line
)
{
if
(
this
.
diffLineCommentForms
[
line
.
lineCode
])
return
true
;
const
lineDiscussions
=
this
.
discussionsByLineCode
[
line
.
lineCode
];
if
(
lineDiscussions
===
undefined
)
{
return
false
;
}
return
lineDiscussions
.
every
(
discussion
=>
discussion
.
expanded
);
},
},
};
};
</
script
>
</
script
>
...
@@ -64,13 +57,15 @@ export default {
...
@@ -64,13 +57,15 @@ export default {
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"line.lineCode"
:key=
"line.lineCode"
:discussions=
"singleDiscussionByLineCode(line.lineCode)"
/>
/>
<inline-diff-comment-row
<inline-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
v-if=
"shouldRender
Inline
CommentRow(line)"
:diff-file-hash=
"diffFile.fileHash"
:diff-file-hash=
"diffFile.fileHash"
:line=
"line"
:line=
"line"
:line-index=
"index"
:line-index=
"index"
:key=
"index"
:key=
"index"
:discussions=
"singleDiscussionByLineCode(line.lineCode)"
/>
/>
</
template
>
</
template
>
</tbody>
</tbody>
...
...
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
View file @
b2dbc936
<
script
>
<
script
>
import
{
mapState
,
mapGetters
}
from
'
vuex
'
;
import
{
mapState
}
from
'
vuex
'
;
import
diffDiscussions
from
'
./diff_discussions.vue
'
;
import
diffDiscussions
from
'
./diff_discussions.vue
'
;
import
diffLineNoteForm
from
'
./diff_line_note_form.vue
'
;
import
diffLineNoteForm
from
'
./diff_line_note_form.vue
'
;
...
@@ -21,48 +21,51 @@ export default {
...
@@ -21,48 +21,51 @@ export default {
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
},
},
leftDiscussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
rightDiscussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
mapGetters
(
'
diffs
'
,
[
'
discussionsByLineCode
'
]),
leftLineCode
()
{
leftLineCode
()
{
return
this
.
line
.
left
.
lineCode
;
return
this
.
line
.
left
.
lineCode
;
},
},
rightLineCode
()
{
rightLineCode
()
{
return
this
.
line
.
right
.
lineCode
;
return
this
.
line
.
right
.
lineCode
;
},
},
hasDiscussion
()
{
const
discussions
=
this
.
discussionsByLineCode
;
return
discussions
[
this
.
leftLineCode
]
||
discussions
[
this
.
rightLineCode
];
},
hasExpandedDiscussionOnLeft
()
{
hasExpandedDiscussionOnLeft
()
{
const
discussions
=
this
.
discussionsByLineCode
[
this
.
leftLineCode
];
const
discussions
=
this
.
leftDiscussions
;
return
discussions
?
discussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
return
discussions
?
discussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
},
},
hasExpandedDiscussionOnRight
()
{
hasExpandedDiscussionOnRight
()
{
const
discussions
=
this
.
discussionsByLineCode
[
this
.
rightLineCode
];
const
discussions
=
this
.
rightDiscussions
;
return
discussions
?
discussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
return
discussions
?
discussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
},
},
hasAnyExpandedDiscussion
()
{
hasAnyExpandedDiscussion
()
{
return
this
.
hasExpandedDiscussionOnLeft
||
this
.
hasExpandedDiscussionOnRight
;
return
this
.
hasExpandedDiscussionOnLeft
||
this
.
hasExpandedDiscussionOnRight
;
},
},
shouldRenderDiscussionsOnLeft
()
{
shouldRenderDiscussionsOnLeft
()
{
return
this
.
discussionsByLineCode
[
this
.
leftLineCode
]
&&
this
.
hasExpandedDiscussionOnLeft
;
return
this
.
leftDiscussions
&&
this
.
hasExpandedDiscussionOnLeft
;
},
},
shouldRenderDiscussionsOnRight
()
{
shouldRenderDiscussionsOnRight
()
{
return
(
return
this
.
rightDiscussions
&&
this
.
hasExpandedDiscussionOnRight
&&
this
.
line
.
right
.
type
;
this
.
discussionsByLineCode
[
this
.
rightLineCode
]
&&
},
this
.
hasExpandedDiscussionOnRight
&&
showRightSideCommentForm
()
{
this
.
line
.
right
.
type
return
this
.
line
.
right
.
type
&&
this
.
diffLineCommentForms
[
this
.
rightLineCode
];
);
},
},
className
()
{
className
()
{
return
this
.
hasDiscussion
?
''
:
'
js-temp-notes-holder
'
;
return
this
.
leftDiscussions
.
length
>
0
||
this
.
rightDiscussions
.
length
>
0
?
''
:
'
js-temp-notes-holder
'
;
},
},
},
},
};
};
...
@@ -80,13 +83,12 @@ export default {
...
@@ -80,13 +83,12 @@ export default {
class=
"content"
class=
"content"
>
>
<diff-discussions
<diff-discussions
v-if=
"
discussionsByLineCode[leftLineCode]
.length"
v-if=
"
leftDiscussions
.length"
:discussions=
"
discussionsByLineCode[leftLineCode]
"
:discussions=
"
leftDiscussions
"
/>
/>
</div>
</div>
<diff-line-note-form
<diff-line-note-form
v-if=
"diffLineCommentForms[leftLineCode] &&
v-if=
"diffLineCommentForms[leftLineCode]"
diffLineCommentForms[leftLineCode]"
:diff-file-hash=
"diffFileHash"
:diff-file-hash=
"diffFileHash"
:line=
"line.left"
:line=
"line.left"
:note-target-line=
"line.left"
:note-target-line=
"line.left"
...
@@ -100,13 +102,12 @@ export default {
...
@@ -100,13 +102,12 @@ export default {
class=
"content"
class=
"content"
>
>
<diff-discussions
<diff-discussions
v-if=
"
discussionsByLineCode[rightLineCode]
.length"
v-if=
"
rightDiscussions
.length"
:discussions=
"
discussionsByLineCode[rightLineCode]
"
:discussions=
"
rightDiscussions
"
/>
/>
</div>
</div>
<diff-line-note-form
<diff-line-note-form
v-if=
"diffLineCommentForms[rightLineCode] &&
v-if=
"showRightSideCommentForm"
diffLineCommentForms[rightLineCode] && line.right.type"
:diff-file-hash=
"diffFileHash"
:diff-file-hash=
"diffFileHash"
:line=
"line.right"
:line=
"line.right"
:note-target-line=
"line.right"
:note-target-line=
"line.right"
...
...
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
View file @
b2dbc936
...
@@ -36,6 +36,16 @@ export default {
...
@@ -36,6 +36,16 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
leftDiscussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
rightDiscussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -116,6 +126,7 @@ export default {
...
@@ -116,6 +126,7 @@ export default {
:is-hover=
"isLeftHover"
:is-hover=
"isLeftHover"
:show-comment-button=
"true"
:show-comment-button=
"true"
:diff-view-type=
"parallelDiffViewType"
:diff-view-type=
"parallelDiffViewType"
:discussions=
"leftDiscussions"
class=
"diff-line-num old_line"
class=
"diff-line-num old_line"
/>
/>
<td
<td
...
@@ -136,6 +147,7 @@ export default {
...
@@ -136,6 +147,7 @@ export default {
:is-hover=
"isRightHover"
:is-hover=
"isRightHover"
:show-comment-button=
"true"
:show-comment-button=
"true"
:diff-view-type=
"parallelDiffViewType"
:diff-view-type=
"parallelDiffViewType"
:discussions=
"rightDiscussions"
class=
"diff-line-num new_line"
class=
"diff-line-num new_line"
/>
/>
<td
<td
...
...
app/assets/javascripts/diffs/components/parallel_diff_view.vue
View file @
b2dbc936
...
@@ -21,7 +21,11 @@ export default {
...
@@ -21,7 +21,11 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
,
'
discussionsByLineCode
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
,
'
singleDiscussionByLineCode
'
,
'
shouldRenderParallelCommentRow
'
,
]),
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
@@ -51,32 +55,6 @@ export default {
...
@@ -51,32 +55,6 @@ export default {
return
window
.
gon
.
user_color_scheme
;
return
window
.
gon
.
user_color_scheme
;
},
},
},
},
methods
:
{
shouldRenderCommentRow
(
line
)
{
const
leftLineCode
=
line
.
left
.
lineCode
;
const
rightLineCode
=
line
.
right
.
lineCode
;
const
discussions
=
this
.
discussionsByLineCode
;
const
leftDiscussions
=
discussions
[
leftLineCode
];
const
rightDiscussions
=
discussions
[
rightLineCode
];
const
hasDiscussion
=
leftDiscussions
||
rightDiscussions
;
const
hasExpandedDiscussionOnLeft
=
leftDiscussions
?
leftDiscussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
const
hasExpandedDiscussionOnRight
=
rightDiscussions
?
rightDiscussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
if
(
hasDiscussion
&&
(
hasExpandedDiscussionOnLeft
||
hasExpandedDiscussionOnRight
))
{
return
true
;
}
const
hasCommentFormOnLeft
=
this
.
diffLineCommentForms
[
leftLineCode
];
const
hasCommentFormOnRight
=
this
.
diffLineCommentForms
[
rightLineCode
];
return
hasCommentFormOnLeft
||
hasCommentFormOnRight
;
},
},
};
};
</
script
>
</
script
>
...
@@ -97,13 +75,17 @@ export default {
...
@@ -97,13 +75,17 @@ export default {
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"index"
:key=
"index"
:left-discussions=
"singleDiscussionByLineCode(line.left.lineCode)"
:right-discussions=
"singleDiscussionByLineCode(line.right.lineCode)"
/>
/>
<parallel-diff-comment-row
<parallel-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
v-if=
"shouldRender
Parallel
CommentRow(line)"
:key=
"`dcr-$
{index}`"
:key=
"`dcr-$
{index}`"
:line="line"
:line="line"
:diff-file-hash="diffFile.fileHash"
:diff-file-hash="diffFile.fileHash"
:line-index="index"
:line-index="index"
:left-discussions="singleDiscussionByLineCode(line.left.lineCode)"
:right-discussions="singleDiscussionByLineCode(line.right.lineCode)"
/>
/>
</
template
>
</
template
>
</tbody>
</tbody>
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
b2dbc936
...
@@ -75,9 +75,10 @@ export const discussionsByLineCode = (state, getters, rootState, rootGetters) =>
...
@@ -75,9 +75,10 @@ export const discussionsByLineCode = (state, getters, rootState, rootGetters) =>
const
isDiffDiscussion
=
note
.
diff_discussion
;
const
isDiffDiscussion
=
note
.
diff_discussion
;
const
hasLineCode
=
note
.
line_code
;
const
hasLineCode
=
note
.
line_code
;
const
isResolvable
=
note
.
resolvable
;
const
isResolvable
=
note
.
resolvable
;
const
diffRefs
=
diffRefsByLineCode
[
note
.
line_code
];
if
(
isDiffDiscussion
&&
hasLineCode
&&
isResolvable
&&
diffRefs
)
{
if
(
isDiffDiscussion
&&
hasLineCode
&&
isResolvable
)
{
const
diffRefs
=
diffRefsByLineCode
[
note
.
line_code
];
if
(
diffRefs
)
{
const
refs
=
convertObjectPropsToCamelCase
(
note
.
position
.
formatter
);
const
refs
=
convertObjectPropsToCamelCase
(
note
.
position
.
formatter
);
const
originalRefs
=
convertObjectPropsToCamelCase
(
note
.
original_position
.
formatter
);
const
originalRefs
=
convertObjectPropsToCamelCase
(
note
.
original_position
.
formatter
);
...
@@ -91,11 +92,53 @@ export const discussionsByLineCode = (state, getters, rootState, rootGetters) =>
...
@@ -91,11 +92,53 @@ export const discussionsByLineCode = (state, getters, rootState, rootGetters) =>
}
}
}
}
}
}
}
return
acc
;
return
acc
;
},
{});
},
{});
};
};
export
const
singleDiscussionByLineCode
=
(
state
,
getters
)
=>
lineCode
=>
{
if
(
!
lineCode
)
return
[];
const
discussions
=
getters
.
discussionsByLineCode
;
return
discussions
[
lineCode
]
||
[];
};
export
const
shouldRenderParallelCommentRow
=
(
state
,
getters
)
=>
line
=>
{
const
leftLineCode
=
line
.
left
.
lineCode
;
const
rightLineCode
=
line
.
right
.
lineCode
;
const
leftDiscussions
=
getters
.
singleDiscussionByLineCode
(
leftLineCode
);
const
rightDiscussions
=
getters
.
singleDiscussionByLineCode
(
rightLineCode
);
const
hasDiscussion
=
leftDiscussions
.
length
||
rightDiscussions
.
length
;
const
hasExpandedDiscussionOnLeft
=
leftDiscussions
.
length
?
leftDiscussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
const
hasExpandedDiscussionOnRight
=
rightDiscussions
.
length
?
rightDiscussions
.
every
(
discussion
=>
discussion
.
expanded
)
:
false
;
if
(
hasDiscussion
&&
(
hasExpandedDiscussionOnLeft
||
hasExpandedDiscussionOnRight
))
{
return
true
;
}
const
hasCommentFormOnLeft
=
state
.
diffLineCommentForms
[
leftLineCode
];
const
hasCommentFormOnRight
=
state
.
diffLineCommentForms
[
rightLineCode
];
return
hasCommentFormOnLeft
||
hasCommentFormOnRight
;
};
export
const
shouldRenderInlineCommentRow
=
(
state
,
getters
)
=>
line
=>
{
if
(
state
.
diffLineCommentForms
[
line
.
lineCode
])
return
true
;
const
lineDiscussions
=
getters
.
singleDiscussionByLineCode
(
line
.
lineCode
);
if
(
lineDiscussions
.
length
===
0
)
{
return
false
;
}
return
lineDiscussions
.
every
(
discussion
=>
discussion
.
expanded
);
};
// prevent babel-plugin-rewire from generating an invalid default during karma∂ tests
// prevent babel-plugin-rewire from generating an invalid default during karma∂ tests
export
const
getDiffFileByHash
=
state
=>
fileHash
=>
export
const
getDiffFileByHash
=
state
=>
fileHash
=>
state
.
diffFiles
.
find
(
file
=>
file
.
fileHash
===
fileHash
);
state
.
diffFiles
.
find
(
file
=>
file
.
fileHash
===
fileHash
);
...
...
changelogs/unreleased/tz-mr-refactor-memory-reduction.yml
0 → 100644
View file @
b2dbc936
---
title
:
Reduces the client side memory footprint on merge requests
merge_request
:
20744
author
:
type
:
performance
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
View file @
b2dbc936
...
@@ -50,7 +50,11 @@ describe('DiffLineGutterContent', () => {
...
@@ -50,7 +50,11 @@ describe('DiffLineGutterContent', () => {
it
(
'
should return discussions for the given lineCode
'
,
()
=>
{
it
(
'
should return discussions for the given lineCode
'
,
()
=>
{
const
{
lineCode
}
=
getDiffFileMock
().
highlightedDiffLines
[
1
];
const
{
lineCode
}
=
getDiffFileMock
().
highlightedDiffLines
[
1
];
const
component
=
createComponent
({
lineCode
,
showCommentButton
:
true
});
const
component
=
createComponent
({
lineCode
,
showCommentButton
:
true
,
discussions
:
getDiscussionsMockData
(),
});
setDiscussions
(
component
);
setDiscussions
(
component
);
...
...
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