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
4b9c952d
Commit
4b9c952d
authored
7 years ago
by
Kushal Pandya
Committed by
Phil Hughes
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ability to edit diff notes multiple times
parent
6ca5a989
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+3
-3
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+41
-0
No files found.
app/assets/javascripts/notes.js
View file @
4b9c952d
...
...
@@ -578,12 +578,12 @@ const normalizeNewlines = function(str) {
Updates the current note field.
*/
Notes
.
prototype
.
updateNote
=
function
(
_xhr
,
noteEntity
,
_status
)
{
Notes
.
prototype
.
updateNote
=
function
(
noteEntity
,
$targetNote
)
{
var
$noteEntityEl
,
$note_li
;
// Convert returned HTML to a jQuery object so we can modify it further
$noteEntityEl
=
$
(
noteEntity
.
html
);
$noteEntityEl
.
addClass
(
'
fade-in-full
'
);
this
.
revertNoteEditForm
();
this
.
revertNoteEditForm
(
$targetNote
);
gl
.
utils
.
localTimeAgo
(
$
(
'
.js-timeago
'
,
$noteEntityEl
));
$noteEntityEl
.
renderGFM
();
$noteEntityEl
.
find
(
'
.js-task-list-container
'
).
taskList
(
'
enable
'
);
...
...
@@ -1404,7 +1404,7 @@ const normalizeNewlines = function(str) {
gl
.
utils
.
ajaxPost
(
formAction
,
formData
)
.
then
((
note
)
=>
{
// Submission successful! render final note element
this
.
updateNote
(
n
ull
,
note
,
null
);
this
.
updateNote
(
n
ote
,
$editingNote
);
})
.
fail
(()
=>
{
// Submission failed, revert back to original note
...
...
This diff is collapsed.
Click to expand it.
spec/javascripts/notes_spec.js
View file @
4b9c952d
...
...
@@ -79,6 +79,47 @@ import '~/notes';
});
});
describe
(
'
updateNote
'
,
()
=>
{
let
sampleComment
;
let
noteEntity
;
let
$form
;
let
$notesContainer
;
beforeEach
(()
=>
{
this
.
notes
=
new
Notes
(
''
,
[]);
window
.
gon
.
current_username
=
'
root
'
;
window
.
gon
.
current_user_fullname
=
'
Administrator
'
;
sampleComment
=
'
foo
'
;
noteEntity
=
{
id
:
1234
,
html
:
`<li class="note note-row-1234 timeline-entry" id="note_1234">
<div class="note-text">
${
sampleComment
}
</div>
</li>`
,
note
:
sampleComment
,
valid
:
true
};
$form
=
$
(
'
form.js-main-target-form
'
);
$notesContainer
=
$
(
'
ul.main-notes-list
'
);
$form
.
find
(
'
textarea.js-note-text
'
).
val
(
sampleComment
);
});
it
(
'
updates note and resets edit form
'
,
()
=>
{
const
deferred
=
$
.
Deferred
();
spyOn
(
$
,
'
ajax
'
).
and
.
returnValue
(
deferred
.
promise
());
spyOn
(
this
.
notes
,
'
revertNoteEditForm
'
);
$
(
'
.js-comment-button
'
).
click
();
deferred
.
resolve
(
noteEntity
);
const
$targetNote
=
$notesContainer
.
find
(
`#note_
${
noteEntity
.
id
}
`
);
const
updatedNote
=
Object
.
assign
({},
noteEntity
);
updatedNote
.
note
=
'
bar
'
;
this
.
notes
.
updateNote
(
updatedNote
,
$targetNote
);
expect
(
this
.
notes
.
revertNoteEditForm
).
toHaveBeenCalledWith
(
$targetNote
);
});
});
describe
(
'
renderNote
'
,
()
=>
{
let
notes
;
let
note
;
...
...
This diff is collapsed.
Click to expand it.
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