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
3a7bf9c3
Commit
3a7bf9c3
authored
May 14, 2020
by
Natalia Tepluhina
Committed by
Mark Florian
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow only users with `adminNote` permission to edit the design note
parent
52cdad05
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
48 deletions
+66
-48
app/assets/javascripts/design_management/components/design_notes/design_note.vue
...design_management/components/design_notes/design_note.vue
+1
-1
app/assets/javascripts/design_management/components/toolbar/index.vue
...avascripts/design_management/components/toolbar/index.vue
+1
-1
app/assets/javascripts/design_management/graphql/fragments/designNote.fragment.graphql
..._management/graphql/fragments/designNote.fragment.graphql
+1
-1
app/assets/javascripts/design_management/graphql/fragments/note_permissions.fragment.graphql
...ement/graphql/fragments/note_permissions.fragment.graphql
+1
-1
app/assets/javascripts/design_management/graphql/queries/design_permissions.query.graphql
...nagement/graphql/queries/design_permissions.query.graphql
+0
-0
app/assets/javascripts/design_management/pages/index.vue
app/assets/javascripts/design_management/pages/index.vue
+1
-1
changelogs/unreleased/ntepluhina-edit-note-fix.yml
changelogs/unreleased/ntepluhina-edit-note-fix.yml
+5
-0
spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap
...nents/design_notes/__snapshots__/design_note_spec.js.snap
+1
-11
spec/frontend/design_management/components/design_notes/design_note_spec.js
...gn_management/components/design_notes/design_note_spec.js
+55
-32
No files found.
app/assets/javascripts/design_management/components/design_notes/design_note.vue
View file @
3a7bf9c3
...
...
@@ -108,7 +108,7 @@ export default {
</span>
</div>
<button
v-if=
"!isEditing"
v-if=
"!isEditing
&& note.userPermissions.adminNote
"
v-gl-tooltip
type=
"button"
title=
"Edit comment"
...
...
app/assets/javascripts/design_management/components/toolbar/index.vue
View file @
3a7bf9c3
...
...
@@ -5,7 +5,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import
timeagoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
Pagination
from
'
./pagination.vue
'
;
import
DeleteButton
from
'
../delete_button.vue
'
;
import
permissionsQuery
from
'
../../graphql/queries/permissions.query.graphql
'
;
import
permissionsQuery
from
'
../../graphql/queries/
design_
permissions.query.graphql
'
;
import
appDataQuery
from
'
../../graphql/queries/appData.query.graphql
'
;
import
{
DESIGNS_ROUTE_NAME
}
from
'
../../router/constants
'
;
...
...
app/assets/javascripts/design_management/graphql/fragments/designNote.fragment.graphql
View file @
3a7bf9c3
#import "./diffRefs.fragment.graphql"
#import "~/graphql_shared/fragments/author.fragment.graphql"
#import "./note
P
ermissions.fragment.graphql"
#import "./note
_p
ermissions.fragment.graphql"
fragment
DesignNote
on
Note
{
id
...
...
app/assets/javascripts/design_management/graphql/fragments/note
P
ermissions.fragment.graphql
→
app/assets/javascripts/design_management/graphql/fragments/note
_p
ermissions.fragment.graphql
View file @
3a7bf9c3
fragment
DesignNotePermissions
on
NotePermissions
{
adminNote
}
\ No newline at end of file
}
app/assets/javascripts/design_management/graphql/queries/permissions.query.graphql
→
app/assets/javascripts/design_management/graphql/queries/
design_
permissions.query.graphql
View file @
3a7bf9c3
File moved
app/assets/javascripts/design_management/pages/index.vue
View file @
3a7bf9c3
...
...
@@ -9,7 +9,7 @@ import DesignDestroyer from '../components/design_destroyer.vue';
import
DesignVersionDropdown
from
'
../components/upload/design_version_dropdown.vue
'
;
import
DesignDropzone
from
'
../components/upload/design_dropzone.vue
'
;
import
uploadDesignMutation
from
'
../graphql/mutations/uploadDesign.mutation.graphql
'
;
import
permissionsQuery
from
'
../graphql/queries/permissions.query.graphql
'
;
import
permissionsQuery
from
'
../graphql/queries/
design_
permissions.query.graphql
'
;
import
getDesignListQuery
from
'
../graphql/queries/get_design_list.query.graphql
'
;
import
allDesignsMixin
from
'
../mixins/all_designs
'
;
import
{
...
...
changelogs/unreleased/ntepluhina-edit-note-fix.yml
0 → 100644
View file @
3a7bf9c3
---
title
:
Allow only users with `adminNote` permission to edit the design note
merge_request
:
32035
author
:
type
:
fixed
spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap
View file @
3a7bf9c3
...
...
@@ -50,17 +50,7 @@ exports[`Design note component should match the snapshot 1`] = `
</span>
</div>
<button
class="note-action-button js-note-edit btn btn-transparent qa-note-edit-button"
title="Edit comment"
type="button"
>
<gl-icon-stub
class="link-highlight"
name="pencil"
size="16"
/>
</button>
<!---->
</div>
<div
...
...
spec/frontend/design_management/components/design_notes/design_note_spec.js
View file @
3a7bf9c3
...
...
@@ -12,6 +12,9 @@ const note = {
id
:
'
author-id
'
,
},
body
:
'
test
'
,
userPermissions
:
{
adminNote
:
false
,
},
};
HTMLElement
.
prototype
.
scrollIntoView
=
scrollIntoViewMock
;
...
...
@@ -93,55 +96,75 @@ describe('Design note component', () => {
expect
(
scrollIntoViewMock
).
toHaveBeenCalled
();
});
it
(
'
should
open an edit form on edit button click
'
,
()
=>
{
it
(
'
should
not render edit icon when user does not have a permission
'
,
()
=>
{
createComponent
({
note
,
});
findEditButton
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
findReplyForm
().
exists
()).
toBe
(
true
);
expect
(
findNoteContent
().
exists
()).
toBe
(
false
);
});
expect
(
findEditButton
().
exists
()).
toBe
(
false
);
});
describe
(
'
when edit form is rendered
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
{
note
,
describe
(
'
when user has a permission to edit note
'
,
()
=>
{
it
(
'
should open an edit form on edit button click
'
,
()
=>
{
createComponent
({
note
:
{
...
note
,
userPermissions
:
{
adminNote
:
true
,
},
},
{
isEditing
:
true
},
);
});
it
(
'
should not render note content and should render reply form
'
,
()
=>
{
expect
(
findNoteContent
().
exists
()).
toBe
(
false
);
expect
(
findReplyForm
().
exists
()).
toBe
(
true
);
});
});
it
(
'
hides the form on hideForm event
'
,
()
=>
{
findReplyForm
().
vm
.
$emit
(
'
cancelForm
'
);
findEditButton
().
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
findReplyForm
().
exists
()).
toBe
(
fals
e
);
expect
(
findNoteContent
().
exists
()).
toBe
(
tru
e
);
expect
(
findReplyForm
().
exists
()).
toBe
(
tru
e
);
expect
(
findNoteContent
().
exists
()).
toBe
(
fals
e
);
});
});
it
(
'
calls a mutation on submitForm event and hides a form
'
,
()
=>
{
findReplyForm
().
vm
.
$emit
(
'
submitForm
'
);
expect
(
mutate
).
toHaveBeenCalled
();
describe
(
'
when edit form is rendered
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
{
note
:
{
...
note
,
userPermissions
:
{
adminNote
:
true
,
},
},
},
{
isEditing
:
true
},
);
});
it
(
'
should not render note content and should render reply form
'
,
()
=>
{
expect
(
findNoteContent
().
exists
()).
toBe
(
false
);
expect
(
findReplyForm
().
exists
()).
toBe
(
true
);
});
it
(
'
hides the form on hideForm event
'
,
()
=>
{
findReplyForm
().
vm
.
$emit
(
'
cancelForm
'
);
return
mutate
()
.
then
(()
=>
{
return
wrapper
.
vm
.
$nextTick
();
})
.
then
(()
=>
{
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
findReplyForm
().
exists
()).
toBe
(
false
);
expect
(
findNoteContent
().
exists
()).
toBe
(
true
);
});
});
it
(
'
calls a mutation on submitForm event and hides a form
'
,
()
=>
{
findReplyForm
().
vm
.
$emit
(
'
submitForm
'
);
expect
(
mutate
).
toHaveBeenCalled
();
return
mutate
()
.
then
(()
=>
{
return
wrapper
.
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
findReplyForm
().
exists
()).
toBe
(
false
);
expect
(
findNoteContent
().
exists
()).
toBe
(
true
);
});
});
});
});
});
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