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
a54a3986
Commit
a54a3986
authored
Nov 23, 2020
by
Savas Vedova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix functionality to add comments
- Improve the UX around editing comments - Add changelog
parent
651e8d4b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
17 deletions
+36
-17
ee/app/assets/javascripts/vulnerabilities/components/footer.vue
.../assets/javascripts/vulnerabilities/components/footer.vue
+1
-1
ee/app/assets/javascripts/vulnerabilities/components/history_comment.vue
...avascripts/vulnerabilities/components/history_comment.vue
+21
-7
ee/changelogs/unreleased/287666-fix-adding-comments.yml
ee/changelogs/unreleased/287666-fix-adding-comments.yml
+5
-0
ee/spec/frontend/vulnerabilities/history_comment_spec.js
ee/spec/frontend/vulnerabilities/history_comment_spec.js
+9
-9
No files found.
ee/app/assets/javascripts/vulnerabilities/components/footer.vue
View file @
a54a3986
...
...
@@ -107,7 +107,7 @@ export default {
.
get
(
this
.
vulnerability
.
discussionsUrl
)
.
then
(({
data
,
headers
:
{
date
}
})
=>
{
this
.
discussionsDictionary
=
data
.
reduce
((
acc
,
discussion
)
=>
{
acc
[
discussion
.
id
]
=
discussion
;
acc
[
discussion
.
id
]
=
convertObjectPropsToCamelCase
(
discussion
,
{
deep
:
true
})
;
return
acc
;
},
{});
...
...
ee/app/assets/javascripts/vulnerabilities/components/history_comment.vue
View file @
a54a3986
<
script
>
import
{
GlButton
,
GlSafeHtmlDirective
as
SafeHtml
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlSafeHtmlDirective
as
SafeHtml
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
EventItem
from
'
ee/vue_shared/security_reports/components/event_item.vue
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
...
...
@@ -9,6 +9,7 @@ import HistoryCommentEditor from './history_comment_editor.vue';
export
default
{
components
:
{
GlButton
,
GlLoadingIcon
,
EventItem
,
HistoryCommentEditor
,
},
...
...
@@ -61,6 +62,20 @@ export default {
initialComment
()
{
return
this
.
comment
&&
this
.
comment
.
note
;
},
canEditComment
()
{
return
this
.
comment
.
currentUser
?.
canEdit
;
},
noteHtml
()
{
return
this
.
isSavingComment
?
undefined
:
this
.
comment
.
noteHtml
;
},
},
watch
:
{
'
comment.updatedAt
'
:
{
handler
()
{
this
.
isSavingComment
=
false
;
},
},
},
methods
:
{
...
...
@@ -96,9 +111,6 @@ export default {
'
VulnerabilityManagement|Something went wrong while trying to save the comment. Please try again later.
'
,
),
);
})
.
finally
(()
=>
{
this
.
isSavingComment
=
false
;
});
},
deleteComment
()
{
...
...
@@ -148,15 +160,17 @@ export default {
v-else-if=
"comment"
:id=
"comment.id"
:author=
"comment.author"
:created-at=
"comment.updated
_a
t"
:show-action-buttons=
"c
omment.current_user.can_edi
t"
:created-at=
"comment.updated
A
t"
:show-action-buttons=
"c
anEditCommen
t"
:show-right-slot=
"isConfirmingDeletion"
:action-buttons=
"actionButtons"
icon-name=
"comment"
icon-class=
"timeline-icon m-0"
class=
"m-3"
>
<div
v-safe-html=
"comment.note_html"
class=
"md"
></div>
<div
v-safe-html=
"noteHtml"
class=
"md"
>
<gl-loading-icon
/>
</div>
<template
#right-content
>
<gl-button
...
...
ee/changelogs/unreleased/287666-fix-adding-comments.yml
0 → 100644
View file @
a54a3986
---
title
:
Fix functionality to add comments in the vulnerability details page
merge_request
:
48375
author
:
type
:
fixed
ee/spec/frontend/vulnerabilities/history_comment_spec.js
View file @
a54a3986
...
...
@@ -24,11 +24,11 @@ describe('History Comment', () => {
const
comment
=
{
id
:
'
id
'
,
note
:
'
note
'
,
note
_h
tml
:
'
<p>note</p>
'
,
note
H
tml
:
'
<p>note</p>
'
,
author
:
{},
updated
_a
t
:
new
Date
().
toISOString
(),
current
_u
ser
:
{
can
_e
dit
:
true
,
updated
A
t
:
new
Date
().
toISOString
(),
current
U
ser
:
{
can
E
dit
:
true
,
},
};
...
...
@@ -142,8 +142,8 @@ describe('History Comment', () => {
it
(
'
shows the comment with the correct user author and timestamp and the edit/delete buttons
'
,
()
=>
{
expectExistingCommentView
();
expect
(
eventItem
().
props
(
'
author
'
)).
toBe
(
comment
.
author
);
expect
(
eventItem
().
props
(
'
createdAt
'
)).
toBe
(
comment
.
updated
_a
t
);
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
_h
tml
);
expect
(
eventItem
().
props
(
'
createdAt
'
)).
toBe
(
comment
.
updated
A
t
);
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
H
tml
);
});
it
(
'
shows the comment editor when the edit button is clicked
'
,
()
=>
{
...
...
@@ -161,7 +161,7 @@ describe('History Comment', () => {
})
.
then
(()
=>
{
expectExistingCommentView
();
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
_h
tml
);
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
H
tml
);
});
});
...
...
@@ -182,7 +182,7 @@ describe('History Comment', () => {
})
.
then
(()
=>
{
expectExistingCommentView
();
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
_h
tml
);
expect
(
eventItem
().
element
.
innerHTML
).
toContain
(
comment
.
note
H
tml
);
});
});
...
...
@@ -262,7 +262,7 @@ describe('History Comment', () => {
describe
(
'
no permission to edit existing comment
'
,
()
=>
{
it
(
'
does not show the edit/delete buttons if the current user has no edit permissions
'
,
()
=>
{
createWrapper
({
...
comment
,
current
_user
:
{
can_e
dit
:
false
}
});
createWrapper
({
...
comment
,
current
User
:
{
canE
dit
:
false
}
});
expect
(
editButton
().
exists
()).
toBe
(
false
);
expect
(
deleteButton
().
exists
()).
toBe
(
false
);
...
...
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