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
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
Hide 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 {
...
@@ -85,6 +85,9 @@ export default {
}
}
return
__
(
'
Show latest version
'
);
return
__
(
'
Show latest version
'
);
},
},
canCurrentUserFork
()
{
return
this
.
currentUser
.
canFork
===
true
&&
this
.
currentUser
.
canCreateMergeRequest
;
},
},
},
watch
:
{
watch
:
{
diffViewType
()
{
diffViewType
()
{
...
@@ -192,7 +195,7 @@ export default {
...
@@ -192,7 +195,7 @@ export default {
v-for=
"file in diffFiles"
v-for=
"file in diffFiles"
:key=
"file.newPath"
:key=
"file.newPath"
:file=
"file"
:file=
"file"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
/>
/>
</div>
</div>
<no-changes
v-else
/>
<no-changes
v-else
/>
...
...
app/assets/javascripts/diffs/components/diff_file.vue
View file @
422dcfde
...
@@ -18,8 +18,8 @@ export default {
...
@@ -18,8 +18,8 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
c
urrentUser
:
{
c
anCurrentUserFork
:
{
type
:
Object
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
},
},
...
@@ -87,7 +87,7 @@ export default {
...
@@ -87,7 +87,7 @@ export default {
class=
"diff-file file-holder"
class=
"diff-file file-holder"
>
>
<diff-file-header
<diff-file-header
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
:diff-file=
"file"
:diff-file=
"file"
:collapsible=
"true"
:collapsible=
"true"
:expanded=
"!isCollapsed"
:expanded=
"!isCollapsed"
...
...
app/assets/javascripts/diffs/components/diff_file_header.vue
View file @
422dcfde
...
@@ -39,8 +39,8 @@ export default {
...
@@ -39,8 +39,8 @@ export default {
required
:
false
,
required
:
false
,
default
:
true
,
default
:
true
,
},
},
c
urrentUser
:
{
c
anCurrentUserFork
:
{
type
:
Object
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
},
},
...
@@ -228,7 +228,7 @@ export default {
...
@@ -228,7 +228,7 @@ export default {
<edit-button
<edit-button
v-if=
"!diffFile.deletedFile"
v-if=
"!diffFile.deletedFile"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"canCurrentUserFork
"
:edit-path=
"diffFile.editPath"
:edit-path=
"diffFile.editPath"
:can-modify-blob=
"diffFile.canModifyBlob"
:can-modify-blob=
"diffFile.canModifyBlob"
@
showForkMessage=
"showForkMessage"
@
showForkMessage=
"showForkMessage"
...
...
app/assets/javascripts/diffs/components/diff_line_note_form.vue
View file @
422dcfde
...
@@ -13,12 +13,8 @@ export default {
...
@@ -13,12 +13,8 @@ export default {
noteForm
,
noteForm
,
},
},
props
:
{
props
:
{
diffFile
:
{
diffFileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
required
:
true
,
required
:
true
,
},
},
line
:
{
line
:
{
...
@@ -40,6 +36,7 @@ export default {
...
@@ -40,6 +36,7 @@ export default {
noteableData
:
state
=>
state
.
notes
.
noteableData
,
noteableData
:
state
=>
state
.
notes
.
noteableData
,
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
diffViewType
:
state
=>
state
.
diffs
.
diffViewType
,
}),
}),
...
mapGetters
(
'
diffs
'
,
[
'
getDiffFileByHash
'
]),
...
mapGetters
([
'
isLoggedIn
'
,
'
noteableType
'
,
'
getNoteableData
'
,
'
getNotesDataByProp
'
]),
...
mapGetters
([
'
isLoggedIn
'
,
'
noteableType
'
,
'
getNoteableData
'
,
'
getNotesDataByProp
'
]),
},
},
mounted
()
{
mounted
()
{
...
@@ -68,13 +65,14 @@ export default {
...
@@ -68,13 +65,14 @@ export default {
});
});
},
},
handleSaveNote
(
note
)
{
handleSaveNote
(
note
)
{
const
selectedDiffFile
=
this
.
getDiffFileByHash
(
this
.
diffFileHash
);
const
postData
=
getNoteFormData
({
const
postData
=
getNoteFormData
({
note
,
note
,
noteableData
:
this
.
noteableData
,
noteableData
:
this
.
noteableData
,
noteableType
:
this
.
noteableType
,
noteableType
:
this
.
noteableType
,
noteTargetLine
:
this
.
noteTargetLine
,
noteTargetLine
:
this
.
noteTargetLine
,
diffViewType
:
this
.
diffViewType
,
diffViewType
:
this
.
diffViewType
,
diffFile
:
this
.
d
iffFile
,
diffFile
:
selectedD
iffFile
,
linePosition
:
this
.
position
,
linePosition
:
this
.
position
,
});
});
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
View file @
422dcfde
...
@@ -24,8 +24,12 @@ export default {
...
@@ -24,8 +24,12 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
diffFile
:
{
fileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
required
:
true
,
},
},
diffViewType
:
{
diffViewType
:
{
...
@@ -120,14 +124,14 @@ export default {
...
@@ -120,14 +124,14 @@ export default {
:class=
"classNameMap"
:class=
"classNameMap"
>
>
<diff-line-gutter-content
<diff-line-gutter-content
:file-hash=
"diffFile.fileHash"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line-type=
"normalizedLine.type"
:line-type=
"normalizedLine.type"
:line-code=
"normalizedLine.lineCode"
:line-code=
"normalizedLine.lineCode"
:line-position=
"linePosition"
:line-position=
"linePosition"
:line-number=
"lineNumber"
:line-number=
"lineNumber"
:meta-data=
"normalizedLine.metaData"
:meta-data=
"normalizedLine.metaData"
:show-comment-button=
"showCommentButton"
:show-comment-button=
"showCommentButton"
:context-lines-path=
"diffFile.contextLinesPath"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-match-line=
"isMatchLine"
:is-match-line=
"isMatchLine"
:is-context-line=
"isContentLine"
:is-context-line=
"isContentLine"
...
...
app/assets/javascripts/diffs/components/edit_button.vue
View file @
422dcfde
...
@@ -5,8 +5,8 @@ export default {
...
@@ -5,8 +5,8 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
c
urrentUser
:
{
c
anCurrentUserFork
:
{
type
:
Object
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
canModifyBlob
:
{
canModifyBlob
:
{
...
@@ -17,12 +17,12 @@ export default {
...
@@ -17,12 +17,12 @@ export default {
},
},
methods
:
{
methods
:
{
handleEditClick
(
evt
)
{
handleEditClick
(
evt
)
{
if
(
!
this
.
c
urrentUser
||
this
.
canModifyBlob
)
{
if
(
!
this
.
c
anCurrentUserFork
||
this
.
canModifyBlob
)
{
// if we can Edit, do default Edit button behavior
// if we can Edit, do default Edit button behavior
return
;
return
;
}
}
if
(
this
.
c
urrentUser
.
canFork
&&
this
.
currentUser
.
canCreateMergeRequest
)
{
if
(
this
.
c
anCurrentUserFork
)
{
evt
.
preventDefault
();
evt
.
preventDefault
();
this
.
$emit
(
'
showForkMessage
'
);
this
.
$emit
(
'
showForkMessage
'
);
}
}
...
...
app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
View file @
422dcfde
...
@@ -13,12 +13,8 @@ export default {
...
@@ -13,12 +13,8 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
diffFile
:
{
diffFileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
required
:
true
,
required
:
true
,
},
},
lineIndex
:
{
lineIndex
:
{
...
@@ -58,10 +54,9 @@ export default {
...
@@ -58,10 +54,9 @@ export default {
/>
/>
<diff-line-note-form
<diff-line-note-form
v-if=
"diffLineCommentForms[line.lineCode]"
v-if=
"diffLineCommentForms[line.lineCode]"
:diff-file=
"diffFile"
:diff-file-hash=
"diffFileHash"
:diff-lines=
"diffLines"
:line=
"line"
:line=
"line"
:note-target-line=
"
diffLines[lineIndex]
"
:note-target-line=
"
line
"
/>
/>
</div>
</div>
</td>
</td>
...
...
app/assets/javascripts/diffs/components/inline_diff_table_row.vue
View file @
422dcfde
...
@@ -16,8 +16,12 @@ export default {
...
@@ -16,8 +16,12 @@ export default {
DiffTableCell
,
DiffTableCell
,
},
},
props
:
{
props
:
{
diffFile
:
{
fileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
required
:
true
,
},
},
line
:
{
line
:
{
...
@@ -50,7 +54,7 @@ export default {
...
@@ -50,7 +54,7 @@ export default {
inlineRowId
()
{
inlineRowId
()
{
const
{
lineCode
,
oldLine
,
newLine
}
=
this
.
line
;
const
{
lineCode
,
oldLine
,
newLine
}
=
this
.
line
;
return
lineCode
||
`
${
this
.
diffFile
.
fileHash
}
_
${
oldLine
}
_
${
newLine
}
`
;
return
lineCode
||
`
${
this
.
fileHash
}
_
${
oldLine
}
_
${
newLine
}
`
;
},
},
},
},
created
()
{
created
()
{
...
@@ -78,7 +82,8 @@ export default {
...
@@ -78,7 +82,8 @@ export default {
@
mouseout=
"handleMouseMove"
@
mouseout=
"handleMouseMove"
>
>
<diff-table-cell
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line=
"line"
:line-type=
"oldLineType"
:line-type=
"oldLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
...
@@ -87,7 +92,8 @@ export default {
...
@@ -87,7 +92,8 @@ export default {
class=
"diff-line-num old_line"
class=
"diff-line-num old_line"
/>
/>
<diff-table-cell
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line=
"line"
:line-type=
"newLineType"
:line-type=
"newLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
...
...
app/assets/javascripts/diffs/components/inline_diff_view.vue
View file @
422dcfde
...
@@ -60,15 +60,15 @@ export default {
...
@@ -60,15 +60,15 @@ export default {
v-for=
"(line, index) in normalizedDiffLines"
v-for=
"(line, index) in normalizedDiffLines"
>
>
<inline-diff-table-row
<inline-diff-table-row
:diff-file=
"diffFile"
:file-hash=
"diffFile.fileHash"
:context-lines-path=
"diffFile.contextLinesPath"
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"line.lineCode"
:key=
"line.lineCode"
/>
/>
<inline-diff-comment-row
<inline-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
v-if=
"shouldRenderCommentRow(line)"
:diff-file=
"diffFile"
:diff-file-hash=
"diffFile.fileHash"
:diff-lines=
"normalizedDiffLines"
:line=
"line"
:line=
"line"
:line-index=
"index"
:line-index=
"index"
:key=
"index"
:key=
"index"
...
...
app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
View file @
422dcfde
...
@@ -13,12 +13,8 @@ export default {
...
@@ -13,12 +13,8 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
diffFile
:
{
diffFileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
diffLines
:
{
type
:
Array
,
required
:
true
,
required
:
true
,
},
},
lineIndex
:
{
lineIndex
:
{
...
@@ -91,10 +87,9 @@ export default {
...
@@ -91,10 +87,9 @@ export default {
<diff-line-note-form
<diff-line-note-form
v-if=
"diffLineCommentForms[leftLineCode] &&
v-if=
"diffLineCommentForms[leftLineCode] &&
diffLineCommentForms[leftLineCode]"
diffLineCommentForms[leftLineCode]"
:diff-file=
"diffFile"
:diff-file-hash=
"diffFileHash"
:diff-lines=
"diffLines"
:line=
"line.left"
:line=
"line.left"
:note-target-line=
"
diffLines[lineIndex]
.left"
:note-target-line=
"
line
.left"
position=
"left"
position=
"left"
/>
/>
</td>
</td>
...
@@ -112,10 +107,9 @@ export default {
...
@@ -112,10 +107,9 @@ export default {
<diff-line-note-form
<diff-line-note-form
v-if=
"diffLineCommentForms[rightLineCode] &&
v-if=
"diffLineCommentForms[rightLineCode] &&
diffLineCommentForms[rightLineCode] && line.right.type"
diffLineCommentForms[rightLineCode] && line.right.type"
:diff-file=
"diffFile"
:diff-file-hash=
"diffFileHash"
:diff-lines=
"diffLines"
:line=
"line.right"
:line=
"line.right"
:note-target-line=
"
diffLines[lineIndex]
.right"
:note-target-line=
"
line
.right"
position=
"right"
position=
"right"
/>
/>
</td>
</td>
...
...
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
View file @
422dcfde
...
@@ -19,8 +19,12 @@ export default {
...
@@ -19,8 +19,12 @@ export default {
DiffTableCell
,
DiffTableCell
,
},
},
props
:
{
props
:
{
diffFile
:
{
fileHash
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
},
contextLinesPath
:
{
type
:
String
,
required
:
true
,
required
:
true
,
},
},
line
:
{
line
:
{
...
@@ -103,7 +107,8 @@ export default {
...
@@ -103,7 +107,8 @@ export default {
@
mouseout=
"handleMouseMove"
@
mouseout=
"handleMouseMove"
>
>
<diff-table-cell
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line=
"line"
:line-type=
"oldLineType"
:line-type=
"oldLineType"
:line-position=
"linePositionLeft"
:line-position=
"linePositionLeft"
...
@@ -123,7 +128,8 @@ export default {
...
@@ -123,7 +128,8 @@ export default {
>
>
</td>
</td>
<diff-table-cell
<diff-table-cell
:diff-file=
"diffFile"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:line=
"line"
:line=
"line"
:line-type=
"newLineType"
:line-type=
"newLineType"
:line-position=
"linePositionRight"
:line-position=
"linePositionRight"
...
...
app/assets/javascripts/diffs/components/parallel_diff_view.vue
View file @
422dcfde
...
@@ -93,17 +93,17 @@ export default {
...
@@ -93,17 +93,17 @@ export default {
v-for=
"(line, index) in parallelDiffLines"
v-for=
"(line, index) in parallelDiffLines"
>
>
<parallel-diff-table-row
<parallel-diff-table-row
:diff-file=
"diffFile"
:file-hash=
"diffFile.fileHash"
:context-lines-path=
"diffFile.contextLinesPath"
:line=
"line"
:line=
"line"
:is-bottom=
"index + 1 === diffLinesLength"
:is-bottom=
"index + 1 === diffLinesLength"
:key=
"index"
:key=
"index"
/>
/>
<parallel-diff-comment-row
<parallel-diff-comment-row
v-if=
"shouldRenderCommentRow(line)"
v-if=
"shouldRenderCommentRow(line)"
:key=
"
line.left.lineCode || line.right.lineCode
"
:key=
"
`dcr-$
{index}`
"
:line="line"
:line="line"
:diff-file=
"diffFile"
:diff-file-hash="diffFile.fileHash"
:diff-lines=
"parallelDiffLines"
:line-index="index"
:line-index="index"
/>
/>
</
template
>
</
template
>
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
422dcfde
...
@@ -57,4 +57,8 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
...
@@ -57,4 +57,8 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
)
||
[];
)
||
[];
// 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
=>
state
.
diffFiles
.
find
(
file
=>
file
.
fileHash
===
fileHash
);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
export
default
()
=>
{};
app/assets/javascripts/notes/components/diff_with_note.vue
View file @
422dcfde
<
script
>
<
script
>
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
imageDiffHelper
from
'
~/image_diff/helpers/index
'
;
import
imageDiffHelper
from
'
~/image_diff/helpers/index
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
SkeletonLoadingContainer
from
'
~/vue_shared/components/skeleton_loading_container.vue
'
;
import
SkeletonLoadingContainer
from
'
~/vue_shared/components/skeleton_loading_container.vue
'
;
import
{
trimFirstCharOfLineContent
}
from
'
~/diffs/store/utils
'
;
import
{
trimFirstCharOfLineContent
}
from
'
~/diffs/store/utils
'
;
export
default
{
export
default
{
components
:
{
components
:
{
DiffFileHeader
,
DiffFileHeader
,
SkeletonLoadingContainer
,
SkeletonLoadingContainer
,
},
props
:
{
discussion
:
{
type
:
Object
,
required
:
true
,
},
},
props
:
{
},
discussion
:
{
data
()
{
type
:
Object
,
return
{
required
:
true
,
error
:
false
,
},
};
},
computed
:
{
...
mapState
({
noteableData
:
state
=>
state
.
notes
.
noteableData
,
}),
hasTruncatedDiffLines
()
{
return
this
.
discussion
.
truncatedDiffLines
&&
this
.
discussion
.
truncatedDiffLines
.
length
!==
0
;
},
},
data
()
{
isDiscussionsExpanded
()
{
return
{
return
true
;
// TODO: @fatihacet - Fix this.
error
:
false
,
};
},
},
computed
:
{
isCollapsed
()
{
...
mapState
({
return
this
.
diffFile
.
collapsed
||
false
;
noteableData
:
state
=>
state
.
notes
.
noteableData
,
},
}),
isImageDiff
()
{
hasTruncatedDiffLines
()
{
return
!
this
.
diffFile
.
text
;
return
this
.
discussion
.
truncatedDiffLines
&&
},
this
.
discussion
.
truncatedDiffLines
.
length
!==
0
;
diffFileClass
()
{
},
const
{
text
}
=
this
.
diffFile
;
isDiscussionsExpanded
()
{
return
text
?
'
text-file
'
:
'
js-image-file
'
;
return
true
;
// TODO: @fatihacet - Fix this.
},
},
diffFile
()
{
isCollapsed
()
{
return
convertObjectPropsToCamelCase
(
this
.
discussion
.
diffFile
,
{
deep
:
true
});
return
this
.
diffFile
.
collapsed
||
false
;
},
isImageDiff
()
{
return
!
this
.
diffFile
.
text
;
},
diffFileClass
()
{
const
{
text
}
=
this
.
diffFile
;
return
text
?
'
text-file
'
:
'
js-image-file
'
;
},
diffFile
()
{
return
convertObjectPropsToCamelCase
(
this
.
discussion
.
diffFile
,
{
deep
:
true
});
},
imageDiffHtml
()
{
return
this
.
discussion
.
imageDiffHtml
;
},
currentUser
()
{
return
this
.
noteableData
.
current_user
;
},
userColorScheme
()
{
return
window
.
gon
.
user_color_scheme
;
},
normalizedDiffLines
()
{
if
(
this
.
discussion
.
truncatedDiffLines
)
{
return
this
.
discussion
.
truncatedDiffLines
.
map
(
line
=>
trimFirstCharOfLineContent
(
convertObjectPropsToCamelCase
(
line
)),
);
}
return
[];
},
},
},
mounted
()
{
imageDiffHtml
()
{
if
(
this
.
isImageDiff
)
{
return
this
.
discussion
.
imageDiffHtml
;
const
canCreateNote
=
false
;
},
const
renderCommentBadge
=
true
;
userColorScheme
()
{
imageDiffHelper
.
initImageDiff
(
this
.
$refs
.
fileHolder
,
canCreateNote
,
renderCommentBadge
);
return
window
.
gon
.
user_color_scheme
;
}
else
if
(
!
this
.
hasTruncatedDiffLines
)
{
},
this
.
fetchDiff
();
normalizedDiffLines
()
{
if
(
this
.
discussion
.
truncatedDiffLines
)
{
return
this
.
discussion
.
truncatedDiffLines
.
map
(
line
=>
trimFirstCharOfLineContent
(
convertObjectPropsToCamelCase
(
line
)),
);
}
}
return
[];
},
},
mounted
()
{
if
(
this
.
isImageDiff
)
{
const
canCreateNote
=
false
;
const
renderCommentBadge
=
true
;
imageDiffHelper
.
initImageDiff
(
this
.
$refs
.
fileHolder
,
canCreateNote
,
renderCommentBadge
);
}
else
if
(
!
this
.
hasTruncatedDiffLines
)
{
this
.
fetchDiff
();
}
},
methods
:
{
...
mapActions
([
'
fetchDiscussionDiffLines
'
]),
rowTag
(
html
)
{
return
html
.
outerHTML
?
'
tr
'
:
'
template
'
;
},
},
methods
:
{
fetchDiff
()
{
...
mapActions
([
'
fetchDiscussionDiffLines
'
]),
this
.
error
=
false
;
rowTag
(
html
)
{
this
.
fetchDiscussionDiffLines
(
this
.
discussion
)
return
html
.
outerHTML
?
'
tr
'
:
'
template
'
;
.
then
(
this
.
highlight
)
},
.
catch
(()
=>
{
fetchDiff
()
{
this
.
error
=
true
;
this
.
error
=
false
;
});
this
.
fetchDiscussionDiffLines
(
this
.
discussion
)
.
then
(
this
.
highlight
)
.
catch
(()
=>
{
this
.
error
=
true
;
});
},
},
},
};
},
};
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -99,7 +95,7 @@
...
@@ -99,7 +95,7 @@
>
>
<diff-file-header
<diff-file-header
:diff-file=
"diffFile"
:diff-file=
"diffFile"
:c
urrent-user=
"currentUser
"
:c
an-current-user-fork=
"false
"
:discussions-expanded=
"isDiscussionsExpanded"
:discussions-expanded=
"isDiscussionsExpanded"
:expanded=
"!isCollapsed"
:expanded=
"!isCollapsed"
/>
/>
...
...
spec/javascripts/diffs/components/diff_file_header_spec.js
View file @
422dcfde
...
@@ -24,7 +24,7 @@ describe('diff_file_header', () => {
...
@@ -24,7 +24,7 @@ describe('diff_file_header', () => {
const
diffFile
=
convertObjectPropsToCamelCase
(
diffDiscussionMock
.
diff_file
,
{
deep
:
true
});
const
diffFile
=
convertObjectPropsToCamelCase
(
diffDiscussionMock
.
diff_file
,
{
deep
:
true
});
props
=
{
props
=
{
diffFile
,
diffFile
,
c
urrentUser
:
{}
,
c
anCurrentUserFork
:
false
,
};
};
});
});
...
...
spec/javascripts/diffs/components/diff_file_spec.js
View file @
422dcfde
...
@@ -11,7 +11,7 @@ describe('DiffFile', () => {
...
@@ -11,7 +11,7 @@ describe('DiffFile', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
store
,
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
store
,
{
file
:
getDiffFileMock
(),
file
:
getDiffFileMock
(),
c
urrentUser
:
{}
,
c
anCurrentUserFork
:
false
,
}).
$mount
();
}).
$mount
();
});
});
...
...
spec/javascripts/diffs/components/diff_line_note_form_spec.js
View file @
422dcfde
...
@@ -15,7 +15,7 @@ describe('DiffLineNoteForm', () => {
...
@@ -15,7 +15,7 @@ describe('DiffLineNoteForm', () => {
diffLines
=
diffFile
.
highlightedDiffLines
;
diffLines
=
diffFile
.
highlightedDiffLines
;
component
=
createComponentWithStore
(
Vue
.
extend
(
DiffLineNoteForm
),
store
,
{
component
=
createComponentWithStore
(
Vue
.
extend
(
DiffLineNoteForm
),
store
,
{
diffFile
,
diffFile
Hash
:
diffFile
.
fileHash
,
diffLines
,
diffLines
,
line
:
diffLines
[
0
],
line
:
diffLines
[
0
],
noteTargetLine
:
diffLines
[
0
],
noteTargetLine
:
diffLines
[
0
],
...
...
spec/javascripts/diffs/store/getters_spec.js
View file @
422dcfde
...
@@ -184,4 +184,23 @@ describe('Diffs Module Getters', () => {
...
@@ -184,4 +184,23 @@ describe('Diffs Module Getters', () => {
).
toEqual
(
0
);
).
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