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
f0071603
Commit
f0071603
authored
Jun 03, 2021
by
Furkan Ayhan
Committed by
Miguel Rincon
Jun 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle enter action of MR comment form
parent
546267fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
app/assets/javascripts/notes/components/comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+9
-2
spec/frontend/notes/components/comment_form_spec.js
spec/frontend/notes/components/comment_form_spec.js
+33
-8
No files found.
app/assets/javascripts/notes/components/comment_form.vue
View file @
f0071603
...
@@ -273,6 +273,13 @@ export default {
...
@@ -273,6 +273,13 @@ export default {
this
.
toggleIssueState
();
this
.
toggleIssueState
();
}
}
},
},
handleEnter
()
{
if
(
this
.
hasDrafts
)
{
this
.
handleSaveDraft
();
}
else
{
this
.
handleSave
();
}
},
toggleIssueState
()
{
toggleIssueState
()
{
if
(
this
.
isIssue
)
{
if
(
this
.
isIssue
)
{
// We want to invoke the close/reopen logic in the issue header
// We want to invoke the close/reopen logic in the issue header
...
@@ -395,8 +402,8 @@ export default {
...
@@ -395,8 +402,8 @@ export default {
:aria-label=
"$options.i18n.comment"
:aria-label=
"$options.i18n.comment"
:placeholder=
"$options.i18n.bodyPlaceholder"
:placeholder=
"$options.i18n.bodyPlaceholder"
@
keydown.up=
"editCurrentUserLastNote()"
@
keydown.up=
"editCurrentUserLastNote()"
@
keydown.meta.enter=
"handle
Save
()"
@
keydown.meta.enter=
"handle
Enter
()"
@
keydown.ctrl.enter=
"handle
Save
()"
@
keydown.ctrl.enter=
"handle
Enter
()"
></textarea>
></textarea>
</
template
>
</
template
>
</markdown-field>
</markdown-field>
...
...
spec/frontend/notes/components/comment_form_spec.js
View file @
f0071603
...
@@ -328,20 +328,45 @@ describe('issue_comment_form component', () => {
...
@@ -328,20 +328,45 @@ describe('issue_comment_form component', () => {
mountComponent
({
mountFunction
:
mount
});
mountComponent
({
mountFunction
:
mount
});
});
});
it
(
'
should save note when cmd+enter is pressed
'
,
()
=>
{
describe
(
'
when no draft exists
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSave
'
);
it
(
'
should save note when cmd+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSave
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalledWith
();
});
it
(
'
should save note when ctrl+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSave
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
ctrlKey
:
true
});
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalledWith
();
});
});
});
it
(
'
should save note when ctrl+enter is pressed
'
,
()
=>
{
describe
(
'
when a draft exists
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSave
'
);
beforeEach
(()
=>
{
store
.
registerModule
(
'
batchComments
'
,
batchComments
());
store
.
state
.
batchComments
.
drafts
=
[{
note
:
'
A
'
}];
});
it
(
'
should save note draft when cmd+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSaveDraft
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
expect
(
wrapper
.
vm
.
handleSaveDraft
).
toHaveBeenCalledWith
();
});
it
(
'
should save note draft when ctrl+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSaveDraft
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
ctrlKey
:
true
});
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
ctrlKey
:
true
});
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
handleSaveDraft
).
toHaveBeenCalledWith
();
});
});
});
});
});
});
});
...
...
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