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
50dfdf02
Commit
50dfdf02
authored
Jul 03, 2016
by
Luke "Jared" Bennett
Committed by
Paco Guzman
Jul 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix up tests
Added more exceptions Added handling inline view type
parent
914bb05d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
18 deletions
+27
-18
app/assets/javascripts/files_comment_button.js.coffee
app/assets/javascripts/files_comment_button.js.coffee
+17
-7
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+1
-1
features/steps/shared/diff_note.rb
features/steps/shared/diff_note.rb
+8
-9
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+1
-1
No files found.
app/assets/javascripts/files_comment_button.js.coffee
View file @
50dfdf02
...
...
@@ -8,11 +8,16 @@ class @FilesCommentButton
@
LINE_HOLDER_CLASS
=
'.line_holder'
@
LINE_NUMBER_CLASS
=
'diff-line-num'
@
LINE_CONTENT_CLASS
=
'line_content'
@
UNFOLDABLE_LINE_CLASS
=
'js-unfold'
@
EMPTY_CELL_CLASS
=
'empty-cell'
@
OLD_LINE_CLASS
=
'old_line'
@
LINE_COLUMN_CLASSES
=
".
#{
@
LINE_NUMBER_CLASS
}
, .line_content"
@
TEXT_FILE_SELECTOR
=
'.text-file'
@
DEBOUNCE_TIMEOUT_DURATION
=
150
@
VIEW_TYPE
=
$
(
'input#view[type=hidden]'
).
val
()
$
(
document
)
.
on
'mouseover'
,
@
LINE_COLUMN_CLASSES
,
@
debounceRender
.
on
'mouseleave'
,
@
LINE_COLUMN_CLASSES
,
@
destroy
...
...
@@ -38,13 +43,13 @@ class @FilesCommentButton
id
:
noteable
:
textFileElement
.
attr
'data-noteable-id'
commit
:
textFileElement
.
attr
'data-commit-id'
discussion
:
lineContentElement
.
attr
(
'data-discussion-id'
)
||
lineHolderElement
.
attr
(
'data-discussion-id'
)
discussion
:
lineContentElement
.
attr
(
'data-discussion-id'
)
or
lineHolderElement
.
attr
(
'data-discussion-id'
)
type
:
noteable
:
textFileElement
.
attr
'data-noteable-type'
note
:
textFileElement
.
attr
'data-note-type'
line
:
lineContentElement
.
attr
'data-line-type'
code
:
line
:
lineContentElement
.
attr
(
'data-line-code'
)
||
lineHolderElement
.
attr
(
'id'
)
line
:
lineContentElement
.
attr
(
'data-line-code'
)
or
lineHolderElement
.
attr
(
'id'
)
return
destroy
:
(
e
)
=>
...
...
@@ -70,14 +75,17 @@ class @FilesCommentButton
$
(
hoveredElement
.
parent
())
getLineNum
:
(
hoveredElement
)
->
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_NUMBER_CLASS
$
(
hoveredElement
).
prev
(
'.'
+
@
LINE_NUMBER_CLASS
)
if
@
VIEW_TYPE
is
'inline'
and
hoveredElement
.
hasClass
@
OLD_LINE_CLASS
$
(
hoveredElement
).
next
".
#{
@
LINE_NUMBER_CLASS
}
"
else
if
hoveredElement
.
hasClass
@
LINE_NUMBER_CLASS
hoveredElement
else
$
(
hoveredElement
).
prev
".
#{
@
LINE_NUMBER_CLASS
}
"
getLineContent
:
(
hoveredElement
)
->
return
hoveredElement
if
hoveredElement
.
hasClass
@
LINE_CONTENT_CLASS
$
(
hoveredElement
).
next
(
'.'
+
@
LINE_CONTENT_CLASS
)
$
(
hoveredElement
).
next
".
#{
@
LINE_CONTENT_CLASS
}
"
isMovingToSameType
:
(
e
)
->
newLineNum
=
@
getLineNum
(
$
(
e
.
toElement
))
...
...
@@ -85,4 +93,6 @@ class @FilesCommentButton
(
newLineNum
).
is
@
getLineNum
(
$
(
e
.
currentTarget
))
shouldRender
:
(
e
,
buttonParentElement
)
->
(
!
buttonParentElement
.
hasClass
(
'empty-cell'
)
and
$
(
@
COMMENT_BUTTON_CLASS
,
buttonParentElement
).
length
is
0
)
(
!
buttonParentElement
.
hasClass
(
@
EMPTY_CELL_CLASS
)
and
\
!
buttonParentElement
.
hasClass
(
@
UNFOLDABLE_LINE_CLASS
)
and
\
$
(
@
COMMENT_BUTTON_CLASS
,
buttonParentElement
).
length
is
0
)
app/helpers/diff_helper.rb
View file @
50dfdf02
...
...
@@ -39,7 +39,7 @@ module DiffHelper
end
def
unfold_bottom_class
(
bottom
)
bottom
?
'js-unfold-bottom'
:
''
bottom
?
'js-unfold
js-unfold
-bottom'
:
''
end
def
unfold_class
(
unfold
)
...
...
features/steps/shared/diff_note.rb
View file @
50dfdf02
...
...
@@ -25,8 +25,7 @@ module SharedDiffNote
page
.
within
(
"form[id$='
#{
sample_commit
.
line_code
}
-true']"
)
do
fill_in
"note[note]"
,
with:
"Typo, please fix"
find
(
".js-comment-button"
).
trigger
(
"click"
)
sleep
0.05
find
(
".js-comment-button"
).
click
end
end
end
...
...
@@ -35,7 +34,7 @@ module SharedDiffNote
click_parallel_diff_line
(
sample_commit
.
del_line_code
,
'old'
)
page
.
within
(
"
#{
diff_file_selector
}
form[id$='
#{
sample_commit
.
del_line_code
}
-true']"
)
do
fill_in
"note[note]"
,
with:
"Old comment"
find
(
".js-comment-button"
).
trigger
(
"click"
)
find
(
".js-comment-button"
).
click
end
end
...
...
@@ -43,7 +42,7 @@ module SharedDiffNote
click_parallel_diff_line
(
sample_commit
.
line_code
,
'new'
)
page
.
within
(
"
#{
diff_file_selector
}
form[id$='
#{
sample_commit
.
line_code
}
-true']"
)
do
fill_in
"note[note]"
,
with:
"New comment"
find
(
".js-comment-button"
).
trigger
(
"click"
)
find
(
".js-comment-button"
).
click
end
end
...
...
@@ -211,7 +210,7 @@ module SharedDiffNote
end
step
'I click side-by-side diff button'
do
find
(
'#parallel-diff-btn'
).
trigger
(
'click'
)
find
(
'#parallel-diff-btn'
).
click
end
step
'I see side-by-side diff button'
do
...
...
@@ -223,12 +222,12 @@ module SharedDiffNote
end
def
click_diff_line
(
code
)
find
(
".line_holder[id='
#{
code
}
'] td:nth-of-type(1)"
).
hover
find
(
".line_holder[id='
#{
code
}
'] button"
).
trigger
(
'click'
)
find
(
".line_holder[id='
#{
code
}
'] td:nth-of-type(1)"
).
trigger
'mouseover'
find
(
".line_holder[id='
#{
code
}
'] button"
).
trigger
'click'
end
def
click_parallel_diff_line
(
code
,
line_type
)
find
(
".line_content.parallel.
#{
line_type
}
[data-line-code='
#{
code
}
']"
).
trigger
(
'mouseover'
)
find
(
".line_holder.parallel button[data-line-code='
#{
code
}
']"
).
trigger
(
'click'
)
find
(
".line_content.parallel.
#{
line_type
}
[data-line-code='
#{
code
}
']"
).
trigger
'mouseover'
find
(
".line_holder.parallel button[data-line-code='
#{
code
}
']"
).
trigger
'click'
end
end
spec/helpers/diff_helper_spec.rb
View file @
50dfdf02
...
...
@@ -59,7 +59,7 @@ describe DiffHelper do
end
it
'should return js class when bottom lines should be unfolded'
do
expect
(
unfold_bottom_class
(
true
)).
to
eq
(
'js-unfold-bottom'
)
expect
(
unfold_bottom_class
(
true
)).
to
include
(
'js-unfold-bottom'
)
end
end
...
...
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