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
422dcfde
Commit
422dcfde
authored
Jul 17, 2018
by
Tim Zallmann
Committed by
Fatih Acet
Jul 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "MR: Reduce the memory footprint of the component tree"
parent
98547133
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
170 additions
and
145 deletions
+170
-145
app/assets/javascripts/diffs/components/app.vue
app/assets/javascripts/diffs/components/app.vue
+4
-1
app/assets/javascripts/diffs/components/diff_file.vue
app/assets/javascripts/diffs/components/diff_file.vue
+3
-3
app/assets/javascripts/diffs/components/diff_file_header.vue
app/assets/javascripts/diffs/components/diff_file_header.vue
+3
-3
app/assets/javascripts/diffs/components/diff_line_note_form.vue
...sets/javascripts/diffs/components/diff_line_note_form.vue
+5
-7
app/assets/javascripts/diffs/components/diff_table_cell.vue
app/assets/javascripts/diffs/components/diff_table_cell.vue
+8
-4
app/assets/javascripts/diffs/components/edit_button.vue
app/assets/javascripts/diffs/components/edit_button.vue
+4
-4
app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
.../javascripts/diffs/components/inline_diff_comment_row.vue
+4
-9
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
...ts/javascripts/diffs/components/inline_diff_table_row.vue
+11
-5
app/assets/javascripts/diffs/components/inline_diff_view.vue
app/assets/javascripts/diffs/components/inline_diff_view.vue
+3
-3
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
...avascripts/diffs/components/parallel_diff_comment_row.vue
+6
-12
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
.../javascripts/diffs/components/parallel_diff_table_row.vue
+10
-4
app/assets/javascripts/diffs/components/parallel_diff_view.vue
...ssets/javascripts/diffs/components/parallel_diff_view.vue
+4
-4
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+4
-0
app/assets/javascripts/notes/components/diff_with_note.vue
app/assets/javascripts/notes/components/diff_with_note.vue
+79
-83
spec/javascripts/diffs/components/diff_file_header_spec.js
spec/javascripts/diffs/components/diff_file_header_spec.js
+1
-1
spec/javascripts/diffs/components/diff_file_spec.js
spec/javascripts/diffs/components/diff_file_spec.js
+1
-1
spec/javascripts/diffs/components/diff_line_note_form_spec.js
.../javascripts/diffs/components/diff_line_note_form_spec.js
+1
-1
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+19
-0
No files found.
app/assets/javascripts/diffs/components/app.vue
View file @
422dcfde
...
...
@@ -85,6 +85,9 @@ export default {
}
return
__
(
'
Show latest version
'
);
},
canCurrentUserFork
()
{
return
this
.
currentUser
.
canFork
===
true
&&
this
.
currentUser
.
canCreateMergeRequest
;
},
},
watch
:
{
diffViewType
()
{
...
...
@@ -192,7 +195,7 @@ export default {
v-for=
"file in diffFiles"
:key=
"file.newPath"
:file=
"file"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
/>
</div>
<no-changes
v-else
/>
...
...
app/assets/javascripts/diffs/components/diff_file.vue
View file @
422dcfde
...
...
@@ -18,8 +18,8 @@ export default {
type
:
Object
,
required
:
true
,
},
c
urrentUser
:
{
type
:
Object
,
c
anCurrentUserFork
:
{
type
:
Boolean
,
required
:
true
,
},
},
...
...
@@ -87,7 +87,7 @@ export default {
class=
"diff-file file-holder"
>
<diff-file-header
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
:diff-file=
"file"
:collapsible=
"true"
:expanded=
"!isCollapsed"
...
...
app/assets/javascripts/diffs/components/diff_file_header.vue
View file @
422dcfde
...
...
@@ -39,8 +39,8 @@ export default {
required
:
false
,
default
:
true
,
},
c
urrentUser
:
{
type
:
Object
,
c
anCurrentUserFork
:
{
type
:
Boolean
,
required
:
true
,
},
},
...
...
@@ -228,7 +228,7 @@ export default {
<edit-button
v-if=
"!diffFile.deletedFile"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
:edit-path=
"diffFile.editPath"
:can-modify-blob=
"diffFile.canModifyBlob"
@
showForkMessage=
"showForkMessage"
...
...
app/assets/javascripts/diffs/components/diff_line_note_form.vue
View file @
422dcfde
...
...
@@ -13,12 +13,8 @@ export default {
noteForm
,
},
props
:
{
diffFile
:
{
type
:
Object
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
diffFileHash
:
{
type
:
String
,
required
:
true
,
},
line
:
{
...
...
@@ -40,6 +36,7 @@ export default {
noteableData
:
state
=>
state
.
notes
.
noteableData
,
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
}),
...
mapGetters
(
'
diffs
'
,
[
'
getDiffFileByHash
'
]),
...
mapGetters
([
'
isLoggedIn
'
,
'
noteableType
'
,
'
getNoteableData
'
,
'
getNotesDataByProp
'
]),
},
mounted
()
{
...
...
@@ -68,13 +65,14 @@ export default {
});
},
handleSaveNote
(
note
)
{
const
selectedDiffFile
=
this
.
getDiffFileByHash
(
this
.
diffFileHash
);
const
postData
=
getNoteFormData
({
note
,
noteableData
:
this
.
noteableData
,
noteableType
:
this
.
noteableType
,
noteTargetLine
:
this
.
noteTargetLine
,
diffViewType
:
this
.
diffViewType
,
diffFile
:
this
.
d
iffFile
,
diffFile
:
selectedD
iffFile
,
linePosition
:
this
.
position
,
});
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
View file @
422dcfde
...
...
@@ -24,8 +24,12 @@ export default {
type
:
Object
,
required
:
true
,
},
diffFile
:
{
type
:
Object
,
fileHash
:
{
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
},
diffViewType
:
{
...
...
@@ -120,14 +124,14 @@ export default {
:class=
"classNameMap"
>
<diff-line-gutter-content
:file-hash=
"diffFile.fileHash"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line-type=
"normalizedLine.type"
:line-code=
"normalizedLine.lineCode"
:line-position=
"linePosition"
:line-number=
"lineNumber"
:meta-data=
"normalizedLine.metaData"
:show-comment-button=
"showCommentButton"
:context-lines-path=
"diffFile.contextLinesPath"
:is-bottom=
"isBottom"
:is-match-line=
"isMatchLine"
:is-context-line=
"isContentLine"
...
...
app/assets/javascripts/diffs/components/edit_button.vue
View file @
422dcfde
...
...
@@ -5,8 +5,8 @@ export default {
type
:
String
,
required
:
true
,
},
c
urrentUser
:
{
type
:
Object
,
c
anCurrentUserFork
:
{
type
:
Boolean
,
required
:
true
,
},
canModifyBlob
:
{
...
...
@@ -17,12 +17,12 @@ export default {
},
methods
:
{
handleEditClick
(
evt
)
{
if
(
!
this
.
c
urrentUser
||
this
.
canModifyBlob
)
{
if
(
!
this
.
c
anCurrentUserFork
||
this
.
canModifyBlob
)
{
// if we can Edit, do default Edit button behavior
return
;
}
if
(
this
.
c
urrentUser
.
canFork
&&
this
.
currentUser
.
canCreateMergeRequest
)
{
if
(
this
.
c
anCurrentUserFork
)
{
evt
.
preventDefault
();
this
.
$emit
(
'
showForkMessage
'
);
}
...
...
app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
View file @
422dcfde
...
...
@@ -13,12 +13,8 @@ export default {
type
:
Object
,
required
:
true
,
},
diffFile
:
{
type
:
Object
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
diffFileHash
:
{
type
:
String
,
required
:
true
,
},
lineIndex
:
{
...
...
@@ -58,10 +54,9 @@ export default {
/>
<diff-line-note-form
v-if=
"diffLineCommentForms[line.lineCode]"
:diff-file=
"diffFile"
:diff-lines=
"diffLines"
:diff-file-hash=
"diffFileHash"
:line=
"line"
:note-target-line=
"
diffLines[lineIndex]
"
:note-target-line=
"
line
"
/>
</div>
</td>
...
...
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
View file @
422dcfde
...
...
@@ -16,8 +16,12 @@ export default {
DiffTableCell
,
},
props
:
{
diffFile
:
{
type
:
Object
,
fileHash
:
{
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
},
line
:
{
...
...
@@ -50,7 +54,7 @@ export default {
inlineRowId
()
{
const
{
lineCode
,
oldLine
,
newLine
}
=
this
.
line
;
return
lineCode
||
`
${
this
.
diffFile
.
fileHash
}
_
${
oldLine
}
_
${
newLine
}
`
;
return
lineCode
||
`
${
this
.
fileHash
}
_
${
oldLine
}
_
${
newLine
}
`
;
},
},
created
()
{
...
...
@@ -78,7 +82,8 @@ export default {
@
mouseout=
"handleMouseMove"
>
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line-type=
"oldLineType"
:is-bottom=
"isBottom"
...
...
@@ -87,7 +92,8 @@ export default {
class=
"diff-line-num old_line"
/>
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line-type=
"newLineType"
:is-bottom=
"isBottom"
...
...
app/assets/javascripts/diffs/components/inline_diff_view.vue
View file @
422dcfde
...
...
@@ -60,15 +60,15 @@ export default {
v-for=
"(line, index) in normalizedDiffLines"
>
<inline-diff-table-row
:diff-file=
"diffFile"
:file-hash=
"diffFile.fileHash"
:context-lines-path=
"diffFile.contextLinesPath"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"line.lineCode"
/>
<inline-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
:diff-file=
"diffFile"
:diff-lines=
"normalizedDiffLines"
:diff-file-hash=
"diffFile.fileHash"
:line=
"line"
:line-index=
"index"
:key=
"index"
...
...
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
View file @
422dcfde
...
...
@@ -13,12 +13,8 @@ export default {
type
:
Object
,
required
:
true
,
},
diffFile
:
{
type
:
Object
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
diffFileHash
:
{
type
:
String
,
required
:
true
,
},
lineIndex
:
{
...
...
@@ -91,10 +87,9 @@ export default {
<diff-line-note-form
v-if=
"diffLineCommentForms[leftLineCode] &&
diffLineCommentForms[leftLineCode]"
:diff-file=
"diffFile"
:diff-lines=
"diffLines"
:diff-file-hash=
"diffFileHash"
:line=
"line.left"
:note-target-line=
"
diffLines[lineIndex]
.left"
:note-target-line=
"
line
.left"
position=
"left"
/>
</td>
...
...
@@ -112,10 +107,9 @@ export default {
<diff-line-note-form
v-if=
"diffLineCommentForms[rightLineCode] &&
diffLineCommentForms[rightLineCode] && line.right.type"
:diff-file=
"diffFile"
:diff-lines=
"diffLines"
:diff-file-hash=
"diffFileHash"
:line=
"line.right"
:note-target-line=
"
diffLines[lineIndex]
.right"
:note-target-line=
"
line
.right"
position=
"right"
/>
</td>
...
...
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
View file @
422dcfde
...
...
@@ -19,8 +19,12 @@ export default {
DiffTableCell
,
},
props
:
{
diffFile
:
{
type
:
Object
,
fileHash
:
{
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
},
line
:
{
...
...
@@ -103,7 +107,8 @@ export default {
@
mouseout=
"handleMouseMove"
>
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line-type=
"oldLineType"
:line-position=
"linePositionLeft"
...
...
@@ -123,7 +128,8 @@ export default {
>
</td>
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line-type=
"newLineType"
:line-position=
"linePositionRight"
...
...
app/assets/javascripts/diffs/components/parallel_diff_view.vue
View file @
422dcfde
...
...
@@ -93,17 +93,17 @@ export default {
v-for=
"(line, index) in parallelDiffLines"
>
<parallel-diff-table-row
:diff-file=
"diffFile"
:file-hash=
"diffFile.fileHash"
:context-lines-path=
"diffFile.contextLinesPath"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"index"
/>
<parallel-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
:key=
"
line.left.lineCode || line.right.lineCode
"
:key=
"
`dcr-$
{index}`
"
:line="line"
:diff-file=
"diffFile"
:diff-lines=
"parallelDiffLines"
:diff-file-hash="diffFile.fileHash"
:line-index="index"
/>
</
template
>
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
422dcfde
...
...
@@ -57,4 +57,8 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
)
||
[];
// prevent babel-plugin-rewire from generating an invalid default during karma∂ tests
export
const
getDiffFileByHash
=
state
=>
fileHash
=>
state
.
diffFiles
.
find
(
file
=>
file
.
fileHash
===
fileHash
);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
app/assets/javascripts/notes/components/diff_with_note.vue
View file @
422dcfde
<
script
>
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
imageDiffHelper
from
'
~/image_diff/helpers/index
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
SkeletonLoadingContainer
from
'
~/vue_shared/components/skeleton_loading_container.vue
'
;
import
{
trimFirstCharOfLineContent
}
from
'
~/diffs/store/utils
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
imageDiffHelper
from
'
~/image_diff/helpers/index
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
SkeletonLoadingContainer
from
'
~/vue_shared/components/skeleton_loading_container.vue
'
;
import
{
trimFirstCharOfLineContent
}
from
'
~/diffs/store/utils
'
;
export
default
{
export
default
{
components
:
{
DiffFileHeader
,
SkeletonLoadingContainer
,
...
...
@@ -27,8 +27,7 @@
noteableData
:
state
=>
state
.
notes
.
noteableData
,
}),
hasTruncatedDiffLines
()
{
return
this
.
discussion
.
truncatedDiffLines
&&
this
.
discussion
.
truncatedDiffLines
.
length
!==
0
;
return
this
.
discussion
.
truncatedDiffLines
&&
this
.
discussion
.
truncatedDiffLines
.
length
!==
0
;
},
isDiscussionsExpanded
()
{
return
true
;
// TODO: @fatihacet - Fix this.
...
...
@@ -49,9 +48,6 @@
imageDiffHtml
()
{
return
this
.
discussion
.
imageDiffHtml
;
},
currentUser
()
{
return
this
.
noteableData
.
current_user
;
},
userColorScheme
()
{
return
window
.
gon
.
user_color_scheme
;
},
...
...
@@ -88,7 +84,7 @@
});
},
},
};
};
</
script
>
<
template
>
...
...
@@ -99,7 +95,7 @@
>
<diff-file-header
:diff-file=
"diffFile"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"false
"
:discussions-expanded=
"isDiscussionsExpanded"
:expanded=
"!isCollapsed"
/>
...
...
spec/javascripts/diffs/components/diff_file_header_spec.js
View file @
422dcfde
...
...
@@ -24,7 +24,7 @@ describe('diff_file_header', () => {
const
diffFile
=
convertObjectPropsToCamelCase
(
diffDiscussionMock
.
diff_file
,
{
deep
:
true
});
props
=
{
diffFile
,
c
urrentUser
:
{}
,
c
anCurrentUserFork
:
false
,
};
});
...
...
spec/javascripts/diffs/components/diff_file_spec.js
View file @
422dcfde
...
...
@@ -11,7 +11,7 @@ describe('DiffFile', () => {
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
store
,
{
file
:
getDiffFileMock
(),
c
urrentUser
:
{}
,
c
anCurrentUserFork
:
false
,
}).
$mount
();
});
...
...
spec/javascripts/diffs/components/diff_line_note_form_spec.js
View file @
422dcfde
...
...
@@ -15,7 +15,7 @@ describe('DiffLineNoteForm', () => {
diffLines
=
diffFile
.
highlightedDiffLines
;
component
=
createComponentWithStore
(
Vue
.
extend
(
DiffLineNoteForm
),
store
,
{
diffFile
,
diffFile
Hash
:
diffFile
.
fileHash
,
diffLines
,
line
:
diffLines
[
0
],
noteTargetLine
:
diffLines
[
0
],
...
...
spec/javascripts/diffs/store/getters_spec.js
View file @
422dcfde
...
...
@@ -184,4 +184,23 @@ describe('Diffs Module Getters', () => {
).
toEqual
(
0
);
});
});
describe
(
'
getDiffFileByHash
'
,
()
=>
{
it
(
'
returns file by hash
'
,
()
=>
{
const
fileA
=
{
fileHash
:
'
123
'
,
};
const
fileB
=
{
fileHash
:
'
456
'
,
};
localState
.
diffFiles
=
[
fileA
,
fileB
];
expect
(
getters
.
getDiffFileByHash
(
localState
)(
'
456
'
)).
toEqual
(
fileB
);
});
it
(
'
returns null if no matching file is found
'
,
()
=>
{
localState
.
diffFiles
=
[];
expect
(
getters
.
getDiffFileByHash
(
localState
)(
'
123
'
)).
toBeUndefined
();
});
});
});
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