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
a3665cff
Commit
a3665cff
authored
Aug 09, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Vue.$emit with single arg in notes
parent
134afafa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
+25
-12
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_body.vue
+3
-3
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+2
-2
spec/frontend/notes/components/noteable_note_spec.js
spec/frontend/notes/components/noteable_note_spec.js
+20
-7
No files found.
app/assets/javascripts/notes/components/note_body.vue
View file @
a3665cff
...
@@ -115,11 +115,11 @@ export default {
...
@@ -115,11 +115,11 @@ export default {
renderGFM
()
{
renderGFM
()
{
$
(
this
.
$refs
[
'
note-body
'
]).
renderGFM
();
$
(
this
.
$refs
[
'
note-body
'
]).
renderGFM
();
},
},
handleFormUpdate
(
note
,
parentElement
,
callback
,
resolveDiscussion
)
{
handleFormUpdate
(
note
Text
,
parentElement
,
callback
,
resolveDiscussion
)
{
this
.
$emit
(
'
handleFormUpdate
'
,
note
,
parentElement
,
callback
,
resolveDiscussion
);
this
.
$emit
(
'
handleFormUpdate
'
,
{
noteText
,
parentElement
,
callback
,
resolveDiscussion
}
);
},
},
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
this
.
$emit
(
'
cancelForm
'
,
shouldConfirm
,
isDirty
);
this
.
$emit
(
'
cancelForm
'
,
{
shouldConfirm
,
isDirty
}
);
},
},
applySuggestion
({
suggestionId
,
flashContainer
,
callback
=
()
=>
{},
message
})
{
applySuggestion
({
suggestionId
,
flashContainer
,
callback
=
()
=>
{},
message
})
{
const
{
discussion_id
:
discussionId
,
id
:
noteId
}
=
this
.
note
;
const
{
discussion_id
:
discussionId
,
id
:
noteId
}
=
this
.
note
;
...
...
app/assets/javascripts/notes/components/noteable_note.vue
View file @
a3665cff
...
@@ -263,7 +263,7 @@ export default {
...
@@ -263,7 +263,7 @@ export default {
this
.
$refs
.
noteBody
.
resetAutoSave
();
this
.
$refs
.
noteBody
.
resetAutoSave
();
this
.
$emit
(
'
updateSuccess
'
);
this
.
$emit
(
'
updateSuccess
'
);
},
},
formUpdateHandler
(
noteText
,
parentElement
,
callback
,
resolveDiscussion
)
{
formUpdateHandler
(
{
noteText
,
callback
,
resolveDiscussion
}
)
{
const
position
=
{
const
position
=
{
...
this
.
note
.
position
,
...
this
.
note
.
position
,
};
};
...
@@ -329,7 +329,7 @@ export default {
...
@@ -329,7 +329,7 @@ export default {
}
}
});
});
},
},
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
formCancelHandler
(
{
shouldConfirm
,
isDirty
}
)
{
if
(
shouldConfirm
&&
isDirty
)
{
if
(
shouldConfirm
&&
isDirty
)
{
// eslint-disable-next-line no-alert
// eslint-disable-next-line no-alert
if
(
!
window
.
confirm
(
__
(
'
Are you sure you want to cancel editing this comment?
'
)))
return
;
if
(
!
window
.
confirm
(
__
(
'
Are you sure you want to cancel editing this comment?
'
)))
return
;
...
...
spec/frontend/notes/components/noteable_note_spec.js
View file @
a3665cff
...
@@ -258,7 +258,11 @@ describe('issue_note', () => {
...
@@ -258,7 +258,11 @@ describe('issue_note', () => {
},
},
});
});
noteBodyComponent
.
vm
.
$emit
(
'
handleFormUpdate
'
,
noteBody
,
null
,
()
=>
{});
noteBodyComponent
.
vm
.
$emit
(
'
handleFormUpdate
'
,
{
noteText
:
noteBody
,
parentElement
:
null
,
callback
:
()
=>
{},
});
await
waitForPromises
();
await
waitForPromises
();
expect
(
alertSpy
).
not
.
toHaveBeenCalled
();
expect
(
alertSpy
).
not
.
toHaveBeenCalled
();
...
@@ -287,14 +291,18 @@ describe('issue_note', () => {
...
@@ -287,14 +291,18 @@ describe('issue_note', () => {
const
noteBody
=
wrapper
.
findComponent
(
NoteBody
);
const
noteBody
=
wrapper
.
findComponent
(
NoteBody
);
noteBody
.
vm
.
resetAutoSave
=
()
=>
{};
noteBody
.
vm
.
resetAutoSave
=
()
=>
{};
noteBody
.
vm
.
$emit
(
'
handleFormUpdate
'
,
updatedText
,
null
,
()
=>
{});
noteBody
.
vm
.
$emit
(
'
handleFormUpdate
'
,
{
noteText
:
updatedText
,
parentElement
:
null
,
callback
:
()
=>
{},
});
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
let
noteBodyProps
=
noteBody
.
props
();
let
noteBodyProps
=
noteBody
.
props
();
expect
(
noteBodyProps
.
note
.
note_html
).
toBe
(
`<p>
${
updatedText
}
</p>\n`
);
expect
(
noteBodyProps
.
note
.
note_html
).
toBe
(
`<p>
${
updatedText
}
</p>\n`
);
noteBody
.
vm
.
$emit
(
'
cancelForm
'
);
noteBody
.
vm
.
$emit
(
'
cancelForm
'
,
{}
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
noteBodyProps
=
noteBody
.
props
();
noteBodyProps
=
noteBody
.
props
();
...
@@ -305,7 +313,12 @@ describe('issue_note', () => {
...
@@ -305,7 +313,12 @@ describe('issue_note', () => {
describe
(
'
formUpdateHandler
'
,
()
=>
{
describe
(
'
formUpdateHandler
'
,
()
=>
{
const
updateNote
=
jest
.
fn
();
const
updateNote
=
jest
.
fn
();
const
params
=
[
''
,
null
,
jest
.
fn
(),
''
];
const
params
=
{
noteText
:
''
,
parentElement
:
null
,
callback
:
jest
.
fn
(),
resolveDiscussion
:
false
,
};
const
updateActions
=
()
=>
{
const
updateActions
=
()
=>
{
store
.
hotUpdate
({
store
.
hotUpdate
({
...
@@ -325,14 +338,14 @@ describe('issue_note', () => {
...
@@ -325,14 +338,14 @@ describe('issue_note', () => {
it
(
'
responds to handleFormUpdate
'
,
()
=>
{
it
(
'
responds to handleFormUpdate
'
,
()
=>
{
createWrapper
();
createWrapper
();
updateActions
();
updateActions
();
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
...
params
);
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
params
);
expect
(
wrapper
.
emitted
(
'
handleUpdateNote
'
)).
toBeTruthy
();
expect
(
wrapper
.
emitted
(
'
handleUpdateNote
'
)).
toBeTruthy
();
});
});
it
(
'
does not stringify empty position
'
,
()
=>
{
it
(
'
does not stringify empty position
'
,
()
=>
{
createWrapper
();
createWrapper
();
updateActions
();
updateActions
();
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
...
params
);
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
params
);
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBeUndefined
();
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBeUndefined
();
});
});
...
@@ -341,7 +354,7 @@ describe('issue_note', () => {
...
@@ -341,7 +354,7 @@ describe('issue_note', () => {
const
expectation
=
JSON
.
stringify
(
position
);
const
expectation
=
JSON
.
stringify
(
position
);
createWrapper
({
note
:
{
...
note
,
position
}
});
createWrapper
({
note
:
{
...
note
,
position
}
});
updateActions
();
updateActions
();
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
...
params
);
wrapper
.
findComponent
(
NoteBody
).
vm
.
$emit
(
'
handleFormUpdate
'
,
params
);
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBe
(
expectation
);
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBe
(
expectation
);
});
});
});
});
...
...
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