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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8daf9db6
Commit
8daf9db6
authored
Aug 08, 2018
by
Tim Zallmann
Committed by
Mike Greiling
Aug 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Porting MR Vue Memory Fixes to current master
parent
b507d93a
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
303 additions
and
86 deletions
+303
-86
app/assets/javascripts/commons/polyfills.js
app/assets/javascripts/commons/polyfills.js
+1
-0
app/assets/javascripts/commons/polyfills/request_idle_callback.js
...ts/javascripts/commons/polyfills/request_idle_callback.js
+17
-0
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+17
-11
app/assets/javascripts/diffs/components/diff_table_cell.vue
app/assets/javascripts/diffs/components/diff_table_cell.vue
+7
-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
+10
-12
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
...avascripts/diffs/components/parallel_diff_comment_row.vue
+27
-24
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
+13
-26
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+41
-0
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+21
-0
app/assets/javascripts/lazy_loader.js
app/assets/javascripts/lazy_loader.js
+13
-5
app/assets/javascripts/vue_shared/components/content_viewer/viewers/image_viewer.vue
...shared/components/content_viewer/viewers/image_viewer.vue
+3
-0
changelogs/unreleased/tz-mr-port-memory-fixes.yml
changelogs/unreleased/tz-mr-port-memory-fixes.yml
+5
-0
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
...scripts/diffs/components/diff_line_gutter_content_spec.js
+5
-1
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+98
-0
spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
.../components/diff_viewer/viewers/image_diff_viewer_spec.js
+0
-2
No files found.
app/assets/javascripts/commons/polyfills.js
View file @
8daf9db6
...
@@ -19,3 +19,4 @@ import './polyfills/custom_event';
...
@@ -19,3 +19,4 @@ import './polyfills/custom_event';
import
'
./polyfills/element
'
;
import
'
./polyfills/element
'
;
import
'
./polyfills/event
'
;
import
'
./polyfills/event
'
;
import
'
./polyfills/nodelist
'
;
import
'
./polyfills/nodelist
'
;
import
'
./polyfills/request_idle_callback
'
;
app/assets/javascripts/commons/polyfills/request_idle_callback.js
0 → 100644
View file @
8daf9db6
window
.
requestIdleCallback
=
window
.
requestIdleCallback
||
function
requestShim
(
cb
)
{
const
start
=
Date
.
now
();
return
setTimeout
(()
=>
{
cb
({
didTimeout
:
false
,
timeRemaining
:
()
=>
Math
.
max
(
0
,
50
-
(
Date
.
now
()
-
start
)),
});
},
1
);
};
window
.
cancelIdleCallback
=
window
.
cancelIdleCallback
||
function
cancelShim
(
id
)
{
clearTimeout
(
id
);
};
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
View file @
8daf9db6
...
@@ -71,13 +71,23 @@ export default {
...
@@ -71,13 +71,23 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
isHover
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapState
({
...
mapState
({
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
diffFiles
:
state
=>
state
.
diffs
.
diffFiles
,
}),
}),
...
mapGetters
([
'
isLoggedIn
'
,
'
discussionsByLineCode
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
lineHref
()
{
lineHref
()
{
return
this
.
lineCode
?
`#
${
this
.
lineCode
}
`
:
'
#
'
;
return
this
.
lineCode
?
`#
${
this
.
lineCode
}
`
:
'
#
'
;
},
},
...
@@ -85,26 +95,22 @@ export default {
...
@@ -85,26 +95,22 @@ export default {
return
(
return
(
this
.
isLoggedIn
&&
this
.
isLoggedIn
&&
this
.
showCommentButton
&&
this
.
showCommentButton
&&
this
.
isHover
&&
!
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
.
showCommentButton
&&
this
.
hasDiscussions
;
},
},
},
},
methods
:
{
methods
:
{
...
@@ -176,7 +182,7 @@ export default {
...
@@ -176,7 +182,7 @@ export default {
v-else
v-else
>
>
<button
<button
v-
show
=
"shouldShowCommentButton"
v-
if
=
"shouldShowCommentButton"
type=
"button"
type=
"button"
class=
"add-diff-note js-add-diff-note-button"
class=
"add-diff-note js-add-diff-note-button"
title=
"Add a comment to this line"
title=
"Add a comment to this line"
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
View file @
8daf9db6
...
@@ -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
'
]),
...
@@ -132,10 +137,12 @@ export default {
...
@@ -132,10 +137,12 @@ export default {
:line-number=
"lineNumber"
:line-number=
"lineNumber"
:meta-data=
"normalizedLine.metaData"
:meta-data=
"normalizedLine.metaData"
:show-comment-button=
"showCommentButton"
:show-comment-button=
"showCommentButton"
:is-hover=
"isHover"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
: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 @
8daf9db6
<
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
([
'
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 @
8daf9db6
...
@@ -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 @
8daf9db6
...
@@ -20,8 +20,11 @@ export default {
...
@@ -20,8 +20,11 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
]),
...
mapGetters
(
'
diffs
'
,
[
...
mapGetters
([
'
discussionsByLineCode
'
]),
'
commitId
'
,
'
shouldRenderInlineCommentRow
'
,
'
singleDiscussionByLineCode
'
,
]),
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
@@ -36,15 +39,8 @@ export default {
...
@@ -36,15 +39,8 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
shouldRenderCommentRow
(
line
)
{
discussionsList
(
line
)
{
if
(
this
.
diffLineCommentForms
[
line
.
lineCode
])
return
true
;
return
line
.
lineCode
!==
undefined
?
this
.
singleDiscussionByLineCode
(
line
.
lineCode
)
:
[];
const
lineDiscussions
=
this
.
discussionsByLineCode
[
line
.
lineCode
];
if
(
lineDiscussions
===
undefined
)
{
return
false
;
}
return
lineDiscussions
.
every
(
discussion
=>
discussion
.
expanded
);
},
},
},
},
};
};
...
@@ -65,13 +61,15 @@ export default {
...
@@ -65,13 +61,15 @@ export default {
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"line.lineCode"
:key=
"line.lineCode"
:discussions=
"discussionsList(line)"
/>
/>
<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=
"discussionsList(line)"
/>
/>
</
template
>
</
template
>
</tbody>
</tbody>
...
...
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
View file @
8daf9db6
<
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,30 +21,34 @@ export default {
...
@@ -21,30 +21,34 @@ 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
([
'
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
;
},
},
...
@@ -52,17 +56,18 @@ export default {
...
@@ -52,17 +56,18 @@ export default {
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 +85,12 @@ export default {
...
@@ -80,13 +85,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 +104,12 @@ export default {
...
@@ -100,13 +104,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 @
8daf9db6
...
@@ -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 @
8daf9db6
...
@@ -21,8 +21,11 @@ export default {
...
@@ -21,8 +21,11 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
]),
...
mapGetters
(
'
diffs
'
,
[
...
mapGetters
([
'
discussionsByLineCode
'
]),
'
commitId
'
,
'
singleDiscussionByLineCode
'
,
'
shouldRenderParallelCommentRow
'
,
]),
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
...
@@ -53,29 +56,9 @@ export default {
...
@@ -53,29 +56,9 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
shouldRenderCommentRow
(
line
)
{
discussionsByLine
(
line
,
leftOrRight
)
{
const
leftLineCode
=
line
.
left
.
lineCode
;
return
line
[
leftOrRight
]
&&
line
[
leftOrRight
].
lineCode
!==
undefined
?
const
rightLineCode
=
line
.
right
.
lineCode
;
this
.
singleDiscussionByLineCode
(
line
[
leftOrRight
].
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
;
},
},
},
},
};
};
...
@@ -98,13 +81,17 @@ export default {
...
@@ -98,13 +81,17 @@ export default {
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"index"
:key=
"index"
:left-discussions=
"discussionsByLine(line, 'left')"
:right-discussions=
"discussionsByLine(line, 'right')"
/>
/>
<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="discussionsByLine(line, 'left')"
:right-discussions="discussionsByLine(line, 'right')"
/>
/>
</
template
>
</
template
>
</tbody>
</tbody>
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
8daf9db6
...
@@ -64,6 +64,47 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
...
@@ -64,6 +64,47 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
discussion
.
diff_discussion
&&
_
.
isEqual
(
discussion
.
diff_file
.
file_hash
,
diff
.
fileHash
),
discussion
.
diff_discussion
&&
_
.
isEqual
(
discussion
.
diff_file
.
file_hash
,
diff
.
fileHash
),
)
||
[];
)
||
[];
export
const
singleDiscussionByLineCode
=
(
state
,
getters
,
rootState
,
rootGetters
)
=>
lineCode
=>
{
if
(
!
lineCode
||
lineCode
===
undefined
)
return
[];
const
discussions
=
rootGetters
.
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
);
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
8daf9db6
...
@@ -173,3 +173,24 @@ export function trimFirstCharOfLineContent(line = {}) {
...
@@ -173,3 +173,24 @@ export function trimFirstCharOfLineContent(line = {}) {
return
parsedLine
;
return
parsedLine
;
}
}
export
function
getDiffRefsByLineCode
(
diffFiles
)
{
return
diffFiles
.
reduce
((
acc
,
diffFile
)
=>
{
const
{
baseSha
,
headSha
,
startSha
}
=
diffFile
.
diffRefs
;
const
{
newPath
,
oldPath
}
=
diffFile
;
// We can only use highlightedDiffLines to create the map of diff lines because
// highlightedDiffLines will also include every parallel diff line in it.
if
(
diffFile
.
highlightedDiffLines
)
{
diffFile
.
highlightedDiffLines
.
forEach
(
line
=>
{
const
{
lineCode
,
oldLine
,
newLine
}
=
line
;
if
(
lineCode
)
{
acc
[
lineCode
]
=
{
baseSha
,
headSha
,
startSha
,
newPath
,
oldPath
,
oldLine
,
newLine
};
}
});
}
return
acc
;
},
{});
}
app/assets/javascripts/lazy_loader.js
View file @
8daf9db6
...
@@ -19,11 +19,17 @@ export default class LazyLoader {
...
@@ -19,11 +19,17 @@ export default class LazyLoader {
scrollContainer
.
addEventListener
(
'
load
'
,
()
=>
this
.
loadCheck
());
scrollContainer
.
addEventListener
(
'
load
'
,
()
=>
this
.
loadCheck
());
}
}
searchLazyImages
()
{
searchLazyImages
()
{
this
.
lazyImages
=
[].
slice
.
call
(
document
.
querySelectorAll
(
'
.lazy
'
));
const
that
=
this
;
requestIdleCallback
(
()
=>
{
that
.
lazyImages
=
[].
slice
.
call
(
document
.
querySelectorAll
(
'
.lazy
'
));
if
(
this
.
lazyImages
.
length
)
{
if
(
that
.
lazyImages
.
length
)
{
this
.
checkElementsInView
();
that
.
checkElementsInView
();
}
}
},
{
timeout
:
500
},
);
}
}
startContentObserver
()
{
startContentObserver
()
{
const
contentNode
=
document
.
querySelector
(
this
.
observerNode
)
||
document
.
querySelector
(
'
body
'
);
const
contentNode
=
document
.
querySelector
(
this
.
observerNode
)
||
document
.
querySelector
(
'
body
'
);
...
@@ -56,7 +62,9 @@ export default class LazyLoader {
...
@@ -56,7 +62,9 @@ export default class LazyLoader {
const
imgBound
=
imgTop
+
imgBoundRect
.
height
;
const
imgBound
=
imgTop
+
imgBoundRect
.
height
;
if
(
scrollTop
<
imgBound
&&
visHeight
>
imgTop
)
{
if
(
scrollTop
<
imgBound
&&
visHeight
>
imgTop
)
{
LazyLoader
.
loadImage
(
selectedImage
);
requestAnimationFrame
(()
=>
{
LazyLoader
.
loadImage
(
selectedImage
);
});
return
false
;
return
false
;
}
}
...
...
app/assets/javascripts/vue_shared/components/content_viewer/viewers/image_viewer.vue
View file @
8daf9db6
...
@@ -42,6 +42,9 @@ export default {
...
@@ -42,6 +42,9 @@ export default {
},
},
methods
:
{
methods
:
{
onImgLoad
()
{
onImgLoad
()
{
requestIdleCallback
(
this
.
calculateImgSize
,
{
timeout
:
1000
});
},
calculateImgSize
()
{
const
{
contentImg
}
=
this
.
$refs
;
const
{
contentImg
}
=
this
.
$refs
;
if
(
contentImg
)
{
if
(
contentImg
)
{
...
...
changelogs/unreleased/tz-mr-port-memory-fixes.yml
0 → 100644
View file @
8daf9db6
---
title
:
Improve performance and memory footprint of Changes tab of Merge Requests
merge_request
:
21028
author
:
type
:
performance
spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
View file @
8daf9db6
...
@@ -48,7 +48,11 @@ describe('DiffLineGutterContent', () => {
...
@@ -48,7 +48,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
);
...
...
spec/javascripts/diffs/store/getters_spec.js
View file @
8daf9db6
...
@@ -184,6 +184,104 @@ describe('Diffs Module Getters', () => {
...
@@ -184,6 +184,104 @@ describe('Diffs Module Getters', () => {
});
});
});
});
describe
(
'
singleDiscussionByLineCode
'
,
()
=>
{
it
(
'
returns found discussion per line Code
'
,
()
=>
{
const
discussionsMock
=
{};
discussionsMock
.
ABC
=
discussionMock
;
expect
(
getters
.
singleDiscussionByLineCode
(
localState
,
{},
null
,
{
discussionsByLineCode
:
()
=>
discussionsMock
,
})(
'
DEF
'
),
).
toEqual
([]);
});
it
(
'
returns empty array when no discussions match
'
,
()
=>
{
expect
(
getters
.
singleDiscussionByLineCode
(
localState
,
{},
null
,
{
discussionsByLineCode
:
()
=>
{},
})(
'
DEF
'
),
).
toEqual
([]);
});
});
describe
(
'
shouldRenderParallelCommentRow
'
,
()
=>
{
let
line
;
beforeEach
(()
=>
{
line
=
{};
line
.
left
=
{
lineCode
:
'
ABC
'
,
};
line
.
right
=
{
lineCode
:
'
DEF
'
,
};
});
it
(
'
returns true when discussion is expanded
'
,
()
=>
{
discussionMock
.
expanded
=
true
;
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[
discussionMock
],
})(
line
),
).
toEqual
(
true
);
});
it
(
'
returns false when no discussion was found
'
,
()
=>
{
localState
.
diffLineCommentForms
.
ABC
=
false
;
localState
.
diffLineCommentForms
.
DEF
=
false
;
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[],
})(
line
),
).
toEqual
(
false
);
});
it
(
'
returns true when discussionForm was found
'
,
()
=>
{
localState
.
diffLineCommentForms
.
ABC
=
{};
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[
discussionMock
],
})(
line
),
).
toEqual
(
true
);
});
});
describe
(
'
shouldRenderInlineCommentRow
'
,
()
=>
{
it
(
'
returns true when diffLineCommentForms has form
'
,
()
=>
{
localState
.
diffLineCommentForms
.
ABC
=
{};
expect
(
getters
.
shouldRenderInlineCommentRow
(
localState
)({
lineCode
:
'
ABC
'
,
}),
).
toEqual
(
true
);
});
it
(
'
returns false when no line discussions were found
'
,
()
=>
{
expect
(
getters
.
shouldRenderInlineCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[],
})(
'
DEF
'
),
).
toEqual
(
false
);
});
it
(
'
returns true if all found discussions are expanded
'
,
()
=>
{
discussionMock
.
expanded
=
true
;
expect
(
getters
.
shouldRenderInlineCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[
discussionMock
],
})(
'
ABC
'
),
).
toEqual
(
true
);
});
});
describe
(
'
getDiffFileDiscussions
'
,
()
=>
{
describe
(
'
getDiffFileDiscussions
'
,
()
=>
{
it
(
'
returns an array with discussions when fileHash matches and the discussion belongs to a diff
'
,
()
=>
{
it
(
'
returns an array with discussions when fileHash matches and the discussion belongs to a diff
'
,
()
=>
{
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
...
...
spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js
View file @
8daf9db6
...
@@ -170,8 +170,6 @@ describe('ImageDiffViewer', () => {
...
@@ -170,8 +170,6 @@ describe('ImageDiffViewer', () => {
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$el
.
querySelector
(
'
.view-modes-menu li:nth-child(3)
'
).
click
();
vm
.
$nextTick
(()
=>
{
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.dragger
'
).
style
.
left
).
toBe
(
'
100px
'
);
dragSlider
(
vm
.
$el
.
querySelector
(
'
.dragger
'
));
dragSlider
(
vm
.
$el
.
querySelector
(
'
.dragger
'
));
vm
.
$nextTick
(()
=>
{
vm
.
$nextTick
(()
=>
{
...
...
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