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
Boxiang Sun
gitlab-ce
Commits
23abdf3e
Commit
23abdf3e
authored
Aug 06, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only rendering diff for now
parent
e8311419
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
140 deletions
+88
-140
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+10
-21
app/assets/javascripts/diffs/components/diff_table_cell.vue
app/assets/javascripts/diffs/components/diff_table_cell.vue
+7
-30
app/assets/javascripts/diffs/components/parallel_diff_table_row.vue
.../javascripts/diffs/components/parallel_diff_table_row.vue
+58
-61
app/assets/javascripts/diffs/components/parallel_diff_view.vue
...ssets/javascripts/diffs/components/parallel_diff_view.vue
+3
-26
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+7
-2
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+1
-0
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+2
-0
No files found.
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
View file @
23abdf3e
...
@@ -13,6 +13,10 @@ export default {
...
@@ -13,6 +13,10 @@ export default {
Icon
,
Icon
,
},
},
props
:
{
props
:
{
line
:
{
type
:
Object
,
required
:
true
,
},
fileHash
:
{
fileHash
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -21,31 +25,16 @@ export default {
...
@@ -21,31 +25,16 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
lineType
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
lineNumber
:
{
lineNumber
:
{
type
:
Number
,
type
:
Number
,
required
:
false
,
required
:
false
,
default
:
0
,
default
:
0
,
},
},
lineCode
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
linePosition
:
{
linePosition
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
metaData
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
showCommentButton
:
{
showCommentButton
:
{
type
:
Boolean
,
type
:
Boolean
,
required
:
false
,
required
:
false
,
...
@@ -89,7 +78,7 @@ export default {
...
@@ -89,7 +78,7 @@ export default {
}),
}),
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
lineHref
()
{
lineHref
()
{
return
this
.
line
Code
?
`#
${
this
.
lineC
ode
}
`
:
'
#
'
;
return
this
.
line
.
code
?
`#
${
this
.
line
.
c
ode
}
`
:
'
#
'
;
},
},
shouldShowCommentButton
()
{
shouldShowCommentButton
()
{
return
(
return
(
...
@@ -103,10 +92,10 @@ export default {
...
@@ -103,10 +92,10 @@ export default {
);
);
},
},
hasDiscussions
()
{
hasDiscussions
()
{
return
this
.
discussions
.
length
>
0
;
return
this
.
line
.
discussions
&&
this
.
line
.
discussions
.
length
>
0
;
},
},
shouldShowAvatarsOnGutter
()
{
shouldShowAvatarsOnGutter
()
{
if
(
!
this
.
line
T
ype
&&
this
.
linePosition
===
LINE_POSITION_RIGHT
)
{
if
(
!
this
.
line
.
t
ype
&&
this
.
linePosition
===
LINE_POSITION_RIGHT
)
{
return
false
;
return
false
;
}
}
...
@@ -116,7 +105,7 @@ export default {
...
@@ -116,7 +105,7 @@ export default {
methods
:
{
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
loadMoreLines
'
,
'
showCommentForm
'
]),
...
mapActions
(
'
diffs
'
,
[
'
loadMoreLines
'
,
'
showCommentForm
'
]),
handleCommentButton
()
{
handleCommentButton
()
{
this
.
showCommentForm
({
lineCode
:
this
.
line
C
ode
});
this
.
showCommentForm
({
lineCode
:
this
.
line
.
c
ode
});
},
},
handleLoadMoreLines
()
{
handleLoadMoreLines
()
{
if
(
this
.
isRequesting
)
{
if
(
this
.
isRequesting
)
{
...
@@ -125,8 +114,8 @@ export default {
...
@@ -125,8 +114,8 @@ export default {
this
.
isRequesting
=
true
;
this
.
isRequesting
=
true
;
const
endpoint
=
this
.
contextLinesPath
;
const
endpoint
=
this
.
contextLinesPath
;
const
oldLineNumber
=
this
.
metaData
.
oldPos
||
0
;
const
oldLineNumber
=
this
.
line
.
metaData
.
oldPos
||
0
;
const
newLineNumber
=
this
.
metaData
.
newPos
||
0
;
const
newLineNumber
=
this
.
line
.
metaData
.
newPos
||
0
;
const
offset
=
newLineNumber
-
oldLineNumber
;
const
offset
=
newLineNumber
-
oldLineNumber
;
const
bottom
=
this
.
isBottom
;
const
bottom
=
this
.
isBottom
;
const
{
fileHash
}
=
this
;
const
{
fileHash
}
=
this
;
...
...
app/assets/javascripts/diffs/components/diff_table_cell.vue
View file @
23abdf3e
...
@@ -11,8 +11,6 @@ import {
...
@@ -11,8 +11,6 @@ import {
LINE_HOVER_CLASS_NAME
,
LINE_HOVER_CLASS_NAME
,
LINE_UNFOLD_CLASS_NAME
,
LINE_UNFOLD_CLASS_NAME
,
INLINE_DIFF_VIEW_TYPE
,
INLINE_DIFF_VIEW_TYPE
,
LINE_POSITION_LEFT
,
LINE_POSITION_RIGHT
,
}
from
'
../constants
'
;
}
from
'
../constants
'
;
export
default
{
export
default
{
...
@@ -67,42 +65,24 @@ export default {
...
@@ -67,42 +65,24 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
discussions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'
isLoggedIn
'
]),
...
mapGetters
([
'
isLoggedIn
'
]),
normalizedLine
()
{
let
normalizedLine
;
if
(
this
.
diffViewType
===
INLINE_DIFF_VIEW_TYPE
)
{
normalizedLine
=
this
.
line
;
}
else
if
(
this
.
linePosition
===
LINE_POSITION_LEFT
)
{
normalizedLine
=
this
.
line
.
left
;
}
else
if
(
this
.
linePosition
===
LINE_POSITION_RIGHT
)
{
normalizedLine
=
this
.
line
.
right
;
}
return
normalizedLine
;
},
isMatchLine
()
{
isMatchLine
()
{
return
this
.
normalizedL
ine
.
type
===
MATCH_LINE_TYPE
;
return
this
.
l
ine
.
type
===
MATCH_LINE_TYPE
;
},
},
isContextLine
()
{
isContextLine
()
{
return
this
.
normalizedL
ine
.
type
===
CONTEXT_LINE_TYPE
;
return
this
.
l
ine
.
type
===
CONTEXT_LINE_TYPE
;
},
},
isMetaLine
()
{
isMetaLine
()
{
const
{
type
}
=
this
.
normalizedL
ine
;
const
{
type
}
=
this
.
l
ine
;
return
(
return
(
type
===
OLD_NO_NEW_LINE_TYPE
||
type
===
NEW_NO_NEW_LINE_TYPE
||
type
===
EMPTY_CELL_TYPE
type
===
OLD_NO_NEW_LINE_TYPE
||
type
===
NEW_NO_NEW_LINE_TYPE
||
type
===
EMPTY_CELL_TYPE
);
);
},
},
classNameMap
()
{
classNameMap
()
{
const
{
type
}
=
this
.
normalizedL
ine
;
const
{
type
}
=
this
.
l
ine
;
return
{
return
{
[
type
]:
type
,
[
type
]:
type
,
...
@@ -116,9 +96,9 @@ export default {
...
@@ -116,9 +96,9 @@ export default {
};
};
},
},
lineNumber
()
{
lineNumber
()
{
const
{
lineType
,
normalizedLine
}
=
this
;
const
{
lineType
}
=
this
;
return
lineType
===
OLD_LINE_TYPE
?
normalizedLine
.
oldLine
:
normalizedL
ine
.
newLine
;
return
lineType
===
OLD_LINE_TYPE
?
this
.
line
.
oldLine
:
this
.
l
ine
.
newLine
;
},
},
},
},
};
};
...
@@ -129,20 +109,17 @@ export default {
...
@@ -129,20 +109,17 @@ export default {
:class=
"classNameMap"
:class=
"classNameMap"
>
>
<diff-line-gutter-content
<diff-line-gutter-content
:line=
"line"
:file-hash=
"fileHash"
:file-hash=
"fileHash"
:context-lines-path=
"contextLinesPath"
:context-lines-path=
"contextLinesPath"
:line-type=
"normalizedLine.type"
:line-code=
"normalizedLine.lineCode"
:line-position=
"linePosition"
:line-position=
"linePosition"
:line-number=
"lineNumber"
:line-number=
"lineNumber"
:meta-data=
"normalizedLine.metaData"
:show-comment-button=
"showCommentButton"
:show-comment-button=
"showCommentButton"
:is-hover=
"isHover"
: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/parallel_diff_table_row.vue
View file @
23abdf3e
...
@@ -10,8 +10,7 @@ import {
...
@@ -10,8 +10,7 @@ import {
OLD_NO_NEW_LINE_TYPE
,
OLD_NO_NEW_LINE_TYPE
,
PARALLEL_DIFF_VIEW_TYPE
,
PARALLEL_DIFF_VIEW_TYPE
,
NEW_NO_NEW_LINE_TYPE
,
NEW_NO_NEW_LINE_TYPE
,
LINE_POSITION_LEFT
,
EMPTY_CELL_TYPE
,
LINE_POSITION_RIGHT
,
}
from
'
../constants
'
;
}
from
'
../constants
'
;
export
default
{
export
default
{
...
@@ -36,16 +35,6 @@ export default {
...
@@ -36,16 +35,6 @@ 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
{
...
@@ -54,29 +43,27 @@ export default {
...
@@ -54,29 +43,27 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
isParallelView
'
]),
isContextLine
()
{
isContextLine
()
{
return
this
.
line
.
left
.
type
===
CONTEXT_LINE_TYPE
;
return
this
.
line
.
left
&&
this
.
line
.
left
.
type
===
CONTEXT_LINE_TYPE
;
},
},
classNameMap
()
{
classNameMap
()
{
return
{
return
{
[
CONTEXT_LINE_CLASS_NAME
]:
this
.
isContextLine
,
[
CONTEXT_LINE_CLASS_NAME
]:
this
.
isContextLine
,
[
PARALLEL_DIFF_VIEW_TYPE
]:
t
his
.
isParallelView
,
[
PARALLEL_DIFF_VIEW_TYPE
]:
t
rue
,
};
};
},
},
parallelViewLeftLineType
()
{
parallelViewLeftLineType
()
{
if
(
this
.
line
.
right
.
type
===
NEW_NO_NEW_LINE_TYPE
)
{
if
(
this
.
line
.
right
&&
this
.
line
.
right
.
type
===
NEW_NO_NEW_LINE_TYPE
)
{
return
OLD_NO_NEW_LINE_TYPE
;
return
OLD_NO_NEW_LINE_TYPE
;
}
}
return
this
.
line
.
left
.
type
;
return
this
.
line
.
left
?
this
.
line
.
left
.
type
:
EMPTY_CELL_TYPE
;
},
},
},
},
created
()
{
created
()
{
// console.log('LINE : ', this.line);
this
.
newLineType
=
NEW_LINE_TYPE
;
this
.
newLineType
=
NEW_LINE_TYPE
;
this
.
oldLineType
=
OLD_LINE_TYPE
;
this
.
oldLineType
=
OLD_LINE_TYPE
;
this
.
linePositionLeft
=
LINE_POSITION_LEFT
;
this
.
linePositionRight
=
LINE_POSITION_RIGHT
;
this
.
parallelDiffViewType
=
PARALLEL_DIFF_VIEW_TYPE
;
this
.
parallelDiffViewType
=
PARALLEL_DIFF_VIEW_TYPE
;
},
},
methods
:
{
methods
:
{
...
@@ -116,47 +103,57 @@ export default {
...
@@ -116,47 +103,57 @@ export default {
@
mouseover=
"handleMouseMove"
@
mouseover=
"handleMouseMove"
@
mouseout=
"handleMouseMove"
@
mouseout=
"handleMouseMove"
>
>
<diff-table-cell
<template
v-if=
"line.left"
>
:file-hash=
"fileHash"
<diff-table-cell
:context-lines-path=
"contextLinesPath"
:file-hash=
"fileHash"
:line=
"line"
:context-lines-path=
"contextLinesPath"
:line-type=
"oldLineType"
:line=
"line.left"
:line-position=
"linePositionLeft"
:line-type=
"oldLineType"
:is-bottom=
"isBottom"
:is-bottom=
"isBottom"
:is-hover=
"isLeftHover"
:is-hover=
"isLeftHover"
:show-comment-button=
"true"
:show-comment-button=
"true"
:diff-view-type=
"parallelDiffViewType"
:diff-view-type=
"parallelDiffViewType"
:discussions=
"leftDiscussions"
line-position=
"left"
class=
"diff-line-num old_line"
class=
"diff-line-num old_line"
/>
/>
<td
<td
:id=
"line.left.lineCode"
:id=
"line.left.lineCode"
:class=
"parallelViewLeftLineType"
:class=
"parallelViewLeftLineType"
class=
"line_content parallel left-side"
class=
"line_content parallel left-side"
@
mousedown.native=
"handleParallelLineMouseDown"
@
mousedown.native=
"handleParallelLineMouseDown"
v-html=
"line.left.richText"
v-html=
"line.left.richText"
>
>
</td>
</td>
<diff-table-cell
</
template
>
:file-hash=
"fileHash"
<
template
v-else
>
:context-lines-path=
"contextLinesPath"
<td
class=
"diff-line-num old_line empty-cell"
></td>
:line=
"line"
<td
class=
"line_content parallel left-side empty-cell"
></td>
:line-type=
"newLineType"
</
template
>
:line-position=
"linePositionRight"
<
template
v-if=
"line.right"
>
:is-bottom=
"isBottom"
<diff-table-cell
:is-hover=
"isRightHover"
:file-hash=
"fileHash"
:show-comment-button=
"true"
:context-lines-path=
"contextLinesPath"
:diff-view-type=
"parallelDiffViewType"
:line=
"line.right"
:discussions=
"rightDiscussions"
:line-type=
"newLineType"
class=
"diff-line-num new_line"
:is-bottom=
"isBottom"
/>
:is-hover=
"isRightHover"
<td
:show-comment-button=
"true"
:id=
"line.right.lineCode"
:diff-view-type=
"parallelDiffViewType"
:class=
"line.right.type"
line-position=
"right"
class=
"line_content parallel right-side"
class=
"diff-line-num new_line"
@
mousedown.native=
"handleParallelLineMouseDown"
/>
v-html=
"line.right.richText"
<td
>
:id=
"line.right.lineCode"
</td>
:class=
"line.right.type"
class=
"line_content parallel right-side"
@
mousedown.native=
"handleParallelLineMouseDown"
v-html=
"line.right.richText"
>
</td>
</
template
>
<
template
v-else
>
<td
class=
"diff-line-num old_line empty-cell"
></td>
<td
class=
"line_content parallel right-side empty-cell"
></td>
</
template
>
</tr>
</tr>
</template>
</template>
app/assets/javascripts/diffs/components/parallel_diff_view.vue
View file @
23abdf3e
...
@@ -21,35 +21,12 @@ export default {
...
@@ -21,35 +21,12 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
...
mapGetters
(
'
diffs
'
,
[
'
commitId
'
,
'
shouldRenderParallelCommentRow
'
]),
'
commitId
'
,
'
singleDiscussionByLineCode
'
,
'
shouldRenderParallelCommentRow
'
,
]),
...
mapState
({
...
mapState
({
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
diffLineCommentForms
:
state
=>
state
.
diffs
.
diffLineCommentForms
,
}),
}),
parallelDiffLines
()
{
return
this
.
diffLines
.
map
(
line
=>
{
const
parallelLine
=
Object
.
assign
({},
line
);
if
(
line
.
left
)
{
parallelLine
.
left
=
trimFirstCharOfLineContent
(
line
.
left
);
}
else
{
parallelLine
.
left
=
{
type
:
EMPTY_CELL_TYPE
};
}
if
(
line
.
right
)
{
parallelLine
.
right
=
trimFirstCharOfLineContent
(
line
.
right
);
}
else
{
parallelLine
.
right
=
{
type
:
EMPTY_CELL_TYPE
};
}
return
parallelLine
;
});
},
diffLinesLength
()
{
diffLinesLength
()
{
return
this
.
parallelD
iffLines
.
length
;
return
this
.
d
iffLines
.
length
;
},
},
userColorScheme
()
{
userColorScheme
()
{
return
window
.
gon
.
user_color_scheme
;
return
window
.
gon
.
user_color_scheme
;
...
@@ -92,7 +69,7 @@ export default {
...
@@ -92,7 +69,7 @@ export default {
:line-index="index"
:line-index="index"
:left-discussions="discussionsByLine(line, 'left')"
:left-discussions="discussionsByLine(line, 'left')"
:right-discussions="discussionsByLine(line, 'right')"
:right-discussions="discussionsByLine(line, 'right')"
/>
/>
-->
</
template
>
</
template
>
</tbody>
</tbody>
</table>
</table>
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
23abdf3e
...
@@ -64,13 +64,18 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
...
@@ -64,13 +64,18 @@ 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
=>
{
export
const
singleDiscussionByLineCodeOld
=
(
state
,
getters
,
rootState
,
rootGetters
,
)
=>
lineCode
=>
{
if
(
!
lineCode
||
lineCode
===
undefined
)
return
[];
if
(
!
lineCode
||
lineCode
===
undefined
)
return
[];
const
discussions
=
rootGetters
.
discussionsByLineCode
;
const
discussions
=
rootGetters
.
discussionsByLineCode
;
return
discussions
[
lineCode
]
||
[];
return
discussions
[
lineCode
]
||
[];
};
};
export
const
shouldRenderParallelCommentRow
=
(
state
,
getters
)
=>
line
=>
{
export
const
shouldRenderParallelCommentRow
Old
=
(
state
,
getters
)
=>
line
=>
{
const
leftLineCode
=
line
.
left
.
lineCode
;
const
leftLineCode
=
line
.
left
.
lineCode
;
const
rightLineCode
=
line
.
right
.
lineCode
;
const
rightLineCode
=
line
.
right
.
lineCode
;
const
leftDiscussions
=
getters
.
singleDiscussionByLineCode
(
leftLineCode
);
const
leftDiscussions
=
getters
.
singleDiscussionByLineCode
(
leftLineCode
);
...
...
app/assets/javascripts/diffs/store/mutations.js
View file @
23abdf3e
...
@@ -3,6 +3,7 @@ import _ from 'underscore';
...
@@ -3,6 +3,7 @@ import _ from 'underscore';
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
findDiffFile
,
addLineReferences
,
removeMatchLine
,
addContextLines
}
from
'
./utils
'
;
import
{
findDiffFile
,
addLineReferences
,
removeMatchLine
,
addContextLines
}
from
'
./utils
'
;
import
{
LINES_TO_BE_RENDERED_DIRECTLY
,
MAX_LINES_TO_BE_RENDERED
}
from
'
../constants
'
;
import
{
LINES_TO_BE_RENDERED_DIRECTLY
,
MAX_LINES_TO_BE_RENDERED
}
from
'
../constants
'
;
import
{
trimFirstCharOfLineContent
}
from
'
../store/utils
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
default
{
export
default
{
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
23abdf3e
...
@@ -161,6 +161,8 @@ export function addContextLines(options) {
...
@@ -161,6 +161,8 @@ export function addContextLines(options) {
* @returns {Object}
* @returns {Object}
*/
*/
export
function
trimFirstCharOfLineContent
(
line
=
{})
{
export
function
trimFirstCharOfLineContent
(
line
=
{})
{
delete
line
.
text
;
const
parsedLine
=
Object
.
assign
({},
line
);
const
parsedLine
=
Object
.
assign
({},
line
);
if
(
line
.
richText
)
{
if
(
line
.
richText
)
{
...
...
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