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
Léo-Paul Géneau
gitlab-ce
Commits
682cfbb4
Commit
682cfbb4
authored
7 years ago
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix system note comparison and standardize note setup
Fix
https://gitlab.com/gitlab-org/gitlab-ce/issues/32551
parent
e4eec191
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
17 deletions
+32
-17
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+11
-11
app/views/shared/notes/_note.html.haml
app/views/shared/notes/_note.html.haml
+0
-2
spec/features/issues/note_polling_spec.rb
spec/features/issues/note_polling_spec.rb
+20
-4
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+1
-0
No files found.
app/assets/javascripts/notes.js
View file @
682cfbb4
...
...
@@ -287,6 +287,13 @@ const normalizeNewlines = function(str) {
}
};
Notes
.
prototype
.
setupNewNote
=
function
(
$note
)
{
// Update datetime format on the recent note
gl
.
utils
.
localTimeAgo
(
$note
.
find
(
'
.js-timeago
'
),
false
);
this
.
collapseLongCommitList
();
this
.
taskList
.
init
();
};
/*
Render note in main comments area.
...
...
@@ -312,10 +319,7 @@ const normalizeNewlines = function(str) {
const
$newNote
=
Notes
.
animateAppendNote
(
noteEntity
.
html
,
$notesList
);
// Update datetime format on the recent note
gl
.
utils
.
localTimeAgo
(
$newNote
.
find
(
'
.js-timeago
'
),
false
);
this
.
collapseLongCommitList
();
this
.
taskList
.
init
();
this
.
setupNewNote
(
$newNote
);
this
.
refresh
();
return
this
.
updateNotesCount
(
1
);
}
...
...
@@ -341,9 +345,7 @@ const normalizeNewlines = function(str) {
}
else
{
const
$updatedNote
=
Notes
.
animateUpdateNote
(
noteEntity
.
html
,
$note
);
// Update datetime format on the recent note
gl
.
utils
.
localTimeAgo
(
$updatedNote
.
find
(
'
.js-timeago
'
),
false
);
this
.
setupNewNote
(
$updatedNote
);
}
}
};
...
...
@@ -665,10 +667,8 @@ const normalizeNewlines = function(str) {
if
(
this
.
updatedNotesTrackingMap
[
noteId
])
{
const
$newNote
=
$
(
this
.
updatedNotesTrackingMap
[
noteId
].
html
);
$note
.
replaceWith
(
$newNote
);
this
.
setupNewNote
(
$newNote
);
this
.
updatedNotesTrackingMap
[
noteId
]
=
null
;
// Update datetime format on the recent note
gl
.
utils
.
localTimeAgo
(
$newNote
.
find
(
'
.js-timeago
'
),
false
);
}
else
{
$note
.
find
(
'
.js-finish-edit-warning
'
).
hide
();
...
...
@@ -1144,7 +1144,7 @@ const normalizeNewlines = function(str) {
// There can be CRLF vs LF mismatches if we don't sanitize and compare the same way
const
sanitizedNoteEntityText
=
normalizeNewlines
(
noteEntity
.
note
.
trim
());
const
currentNoteText
=
normalizeNewlines
(
$note
.
find
(
'
.original-note-content
'
).
text
().
trim
()
$note
.
find
(
'
.original-note-content
'
).
first
().
text
().
trim
()
);
return
sanitizedNoteEntityText
!==
currentNoteText
;
};
...
...
This diff is collapsed.
Click to expand it.
app/views/shared/notes/_note.html.haml
View file @
682cfbb4
...
...
@@ -29,8 +29,6 @@
-
if
note
.
system
%span
.system-note-message
=
note
.
redacted_note_html
.original-note-content.hidden
=
note
.
note
%a
{
href:
"##{dom_id(note)}"
}
=
time_ago_with_tooltip
(
note
.
created_at
,
placement:
'bottom'
,
html_class:
'note-created-ago'
)
-
unless
note
.
system?
...
...
This diff is collapsed.
Click to expand it.
spec/features/issues/note_polling_spec.rb
View file @
682cfbb4
...
...
@@ -31,12 +31,12 @@ feature 'Issue notes polling', :feature, :js do
it
'has .original-note-content to compare against'
do
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
note_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
visible:
false
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
update_note
(
existing_note
,
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
visible:
false
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
end
it
'displays the updated content'
do
...
...
@@ -98,12 +98,28 @@ feature 'Issue notes polling', :feature, :js do
it
'has .original-note-content to compare against'
do
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
note_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
visible:
false
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
update_note
(
existing_note
,
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
"
,
text:
updated_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
visible:
false
)
expect
(
page
).
to
have_selector
(
"#note_
#{
existing_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
end
end
context
'system notes'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:note_text
)
{
"Some system note"
}
let!
(
:system_note
)
{
create
(
:system_note
,
noteable:
issue
,
project:
project
,
author:
user
,
note:
note_text
)
}
before
do
login_as
(
user
)
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
end
it
'has .original-note-content to compare against'
do
expect
(
page
).
to
have_selector
(
"#note_
#{
system_note
.
id
}
"
,
text:
note_text
)
expect
(
page
).
to
have_selector
(
"#note_
#{
system_note
.
id
}
.original-note-content"
,
count:
1
,
visible:
false
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/javascripts/notes_spec.js
View file @
682cfbb4
...
...
@@ -139,6 +139,7 @@ import '~/notes';
]);
notes
=
jasmine
.
createSpyObj
(
'
notes
'
,
[
'
setupNewNote
'
,
'
refresh
'
,
'
collapseLongCommitList
'
,
'
updateNotesCount
'
,
...
...
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