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
3d6713f6
Commit
3d6713f6
authored
Nov 10, 2020
by
Natalia Tepluhina
Committed by
Nicolò Maria Mezzopera
Nov 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the mutation and permissions for image note reposition
parent
7a752db3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
54 additions
and
38 deletions
+54
-38
app/assets/javascripts/design_management/components/design_overlay.vue
...vascripts/design_management/components/design_overlay.vue
+2
-2
app/assets/javascripts/design_management/graphql/fragments/note_permissions.fragment.graphql
...ement/graphql/fragments/note_permissions.fragment.graphql
+1
-0
app/assets/javascripts/design_management/graphql/mutations/reposition_image_diff_note.mutation.graphql
...hql/mutations/reposition_image_diff_note.mutation.graphql
+10
-0
app/assets/javascripts/design_management/pages/design/index.vue
...sets/javascripts/design_management/pages/design/index.vue
+8
-8
app/assets/javascripts/design_management/utils/cache_update.js
...ssets/javascripts/design_management/utils/cache_update.js
+4
-4
app/assets/javascripts/design_management/utils/design_management_utils.js
...cripts/design_management/utils/design_management_utils.js
+3
-3
changelogs/unreleased/207334-design-view-relax-permissions-for-updateimagediffnote-mutation.yml
...ew-relax-permissions-for-updateimagediffnote-mutation.yml
+5
-0
spec/frontend/design_management/components/design_overlay_spec.js
...ntend/design_management/components/design_overlay_spec.js
+9
-9
spec/frontend/design_management/mock_data/discussion.js
spec/frontend/design_management/mock_data/discussion.js
+1
-1
spec/frontend/design_management/utils/cache_update_spec.js
spec/frontend/design_management/utils/cache_update_spec.js
+6
-6
spec/frontend/design_management/utils/design_management_utils_spec.js
...d/design_management/utils/design_management_utils_spec.js
+5
-5
No files found.
app/assets/javascripts/design_management/components/design_overlay.vue
View file @
3d6713f6
...
...
@@ -112,9 +112,9 @@ export default {
},
canMoveNote
(
note
)
{
const
{
userPermissions
}
=
note
;
const
{
admi
nNote
}
=
userPermissions
||
{};
const
{
repositio
nNote
}
=
userPermissions
||
{};
return
Boolean
(
admi
nNote
);
return
Boolean
(
repositio
nNote
);
},
isPositionInOverlay
(
position
)
{
const
{
top
,
left
}
=
this
.
getNoteRelativePosition
(
position
);
...
...
app/assets/javascripts/design_management/graphql/fragments/note_permissions.fragment.graphql
View file @
3d6713f6
fragment
DesignNotePermissions
on
NotePermissions
{
adminNote
repositionNote
}
app/assets/javascripts/design_management/graphql/mutations/
update
_image_diff_note.mutation.graphql
→
app/assets/javascripts/design_management/graphql/mutations/
reposition
_image_diff_note.mutation.graphql
View file @
3d6713f6
#import "../fragments/design_note.fragment.graphql"
mutation
updateImageDiffNote
(
$input
:
Update
ImageDiffNoteInput
!)
{
update
ImageDiffNote
(
input
:
$input
)
{
mutation
repositionImageDiffNote
(
$input
:
Reposition
ImageDiffNoteInput
!)
{
reposition
ImageDiffNote
(
input
:
$input
)
{
errors
note
{
...
DesignNote
...
...
app/assets/javascripts/design_management/pages/design/index.vue
View file @
3d6713f6
...
...
@@ -13,19 +13,19 @@ import DesignReplyForm from '../../components/design_notes/design_reply_form.vue
import
DesignSidebar
from
'
../../components/design_sidebar.vue
'
;
import
getDesignQuery
from
'
../../graphql/queries/get_design.query.graphql
'
;
import
createImageDiffNoteMutation
from
'
../../graphql/mutations/create_image_diff_note.mutation.graphql
'
;
import
updateImageDiffNoteMutation
from
'
../../graphql/mutations/update
_image_diff_note.mutation.graphql
'
;
import
repositionImageDiffNoteMutation
from
'
../../graphql/mutations/reposition
_image_diff_note.mutation.graphql
'
;
import
updateActiveDiscussionMutation
from
'
../../graphql/mutations/update_active_discussion.mutation.graphql
'
;
import
{
extractDiscussions
,
extractDesign
,
update
ImageDiffNoteOptimisticResponse
,
reposition
ImageDiffNoteOptimisticResponse
,
toDiffNoteGid
,
extractDesignNoteId
,
getPageLayoutElement
,
}
from
'
../../utils/design_management_utils
'
;
import
{
updateStoreAfterAddImageDiffNote
,
updateStoreAfter
Update
ImageDiffNote
,
updateStoreAfter
Reposition
ImageDiffNote
,
}
from
'
../../utils/cache_update
'
;
import
{
ADD_DISCUSSION_COMMENT_ERROR
,
...
...
@@ -182,12 +182,12 @@ export default {
updateImageDiffNoteInStore
(
store
,
{
data
:
{
update
ImageDiffNote
},
data
:
{
reposition
ImageDiffNote
},
},
)
{
return
updateStoreAfter
Update
ImageDiffNote
(
return
updateStoreAfter
Reposition
ImageDiffNote
(
store
,
update
ImageDiffNote
,
reposition
ImageDiffNote
,
getDesignQuery
,
this
.
designVariables
,
);
...
...
@@ -199,7 +199,7 @@ export default {
);
const
mutationPayload
=
{
optimisticResponse
:
update
ImageDiffNoteOptimisticResponse
(
note
,
{
optimisticResponse
:
reposition
ImageDiffNoteOptimisticResponse
(
note
,
{
position
,
}),
variables
:
{
...
...
@@ -208,7 +208,7 @@ export default {
position
,
},
},
mutation
:
update
ImageDiffNoteMutation
,
mutation
:
reposition
ImageDiffNoteMutation
,
update
:
this
.
updateImageDiffNoteInStore
,
};
...
...
app/assets/javascripts/design_management/utils/cache_update.js
View file @
3d6713f6
...
...
@@ -101,7 +101,7 @@ const addImageDiffNoteToStore = (store, createImageDiffNote, query, variables) =
});
};
const
updateImageDiffNoteInStore
=
(
store
,
update
ImageDiffNote
,
query
,
variables
)
=>
{
const
updateImageDiffNoteInStore
=
(
store
,
reposition
ImageDiffNote
,
query
,
variables
)
=>
{
const
sourceData
=
store
.
readQuery
({
query
,
variables
,
...
...
@@ -111,12 +111,12 @@ const updateImageDiffNoteInStore = (store, updateImageDiffNote, query, variables
const
design
=
extractDesign
(
draftData
);
const
discussion
=
extractCurrentDiscussion
(
design
.
discussions
,
update
ImageDiffNote
.
note
.
discussion
.
id
,
reposition
ImageDiffNote
.
note
.
discussion
.
id
,
);
discussion
.
notes
=
{
...
discussion
.
notes
,
nodes
:
[
update
ImageDiffNote
.
note
,
...
discussion
.
notes
.
nodes
.
slice
(
1
)],
nodes
:
[
reposition
ImageDiffNote
.
note
,
...
discussion
.
notes
.
nodes
.
slice
(
1
)],
};
});
...
...
@@ -268,7 +268,7 @@ export const updateStoreAfterAddImageDiffNote = (store, data, query, queryVariab
}
};
export
const
updateStoreAfter
Update
ImageDiffNote
=
(
store
,
data
,
query
,
queryVariables
)
=>
{
export
const
updateStoreAfter
Reposition
ImageDiffNote
=
(
store
,
data
,
query
,
queryVariables
)
=>
{
if
(
hasErrors
(
data
))
{
onError
(
data
,
UPDATE_IMAGE_DIFF_NOTE_ERROR
);
}
else
{
...
...
app/assets/javascripts/design_management/utils/design_management_utils.js
View file @
3d6713f6
...
...
@@ -107,12 +107,12 @@ export const designUploadOptimisticResponse = files => {
* @param {Object} note
* @param {Object} position
*/
export
const
update
ImageDiffNoteOptimisticResponse
=
(
note
,
{
position
})
=>
({
export
const
reposition
ImageDiffNoteOptimisticResponse
=
(
note
,
{
position
})
=>
({
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename
:
'
Mutation
'
,
update
ImageDiffNote
:
{
__typename
:
'
Update
ImageDiffNotePayload
'
,
reposition
ImageDiffNote
:
{
__typename
:
'
Reposition
ImageDiffNotePayload
'
,
note
:
{
...
note
,
position
:
{
...
...
changelogs/unreleased/207334-design-view-relax-permissions-for-updateimagediffnote-mutation.yml
0 → 100644
View file @
3d6713f6
---
title
:
Change the mutation and permissions for image note reposition
merge_request
:
47161
author
:
type
:
changed
spec/frontend/design_management/components/design_overlay_spec.js
View file @
3d6713f6
...
...
@@ -243,11 +243,11 @@ describe('Design overlay component', () => {
});
});
describe
(
'
without [
admi
nNote] permission
'
,
()
=>
{
describe
(
'
without [
repositio
nNote] permission
'
,
()
=>
{
const
mockNoteNotAuthorised
=
{
...
notes
[
0
],
userPermissions
:
{
admi
nNote
:
false
,
repositio
nNote
:
false
,
},
};
...
...
@@ -412,18 +412,18 @@ describe('Design overlay component', () => {
describe
(
'
canMoveNote
'
,
()
=>
{
it
.
each
`
admi
nNotePermission | canMoveNoteResult
${
true
}
|
${
true
}
${
false
}
|
${
false
}
${
undefined
}
|
${
false
}
repositio
nNotePermission | canMoveNoteResult
${
true
}
|
${
true
}
${
false
}
|
${
false
}
${
undefined
}
|
${
false
}
`
(
'
returns [$canMoveNoteResult] when [
adminNote permission] is [$admi
nNotePermission]
'
,
({
admi
nNotePermission
,
canMoveNoteResult
})
=>
{
'
returns [$canMoveNoteResult] when [
repositionNote permission] is [$repositio
nNotePermission]
'
,
({
repositio
nNotePermission
,
canMoveNoteResult
})
=>
{
createComponent
();
const
note
=
{
userPermissions
:
{
adminNote
:
admi
nNotePermission
,
repositionNote
:
repositio
nNotePermission
,
},
};
expect
(
wrapper
.
vm
.
canMoveNote
(
note
)).
toBe
(
canMoveNoteResult
);
...
...
spec/frontend/design_management/mock_data/discussion.js
View file @
3d6713f6
...
...
@@ -18,7 +18,7 @@ export default {
},
createdAt
:
'
2020-05-08T07:10:45Z
'
,
userPermissions
:
{
admi
nNote
:
true
,
repositio
nNote
:
true
,
},
resolved
:
false
,
},
...
...
spec/frontend/design_management/utils/cache_update_spec.js
View file @
3d6713f6
...
...
@@ -3,7 +3,7 @@ import {
updateStoreAfterDesignsDelete
,
updateStoreAfterAddImageDiffNote
,
updateStoreAfterUploadDesign
,
updateStoreAfter
Update
ImageDiffNote
,
updateStoreAfter
Reposition
ImageDiffNote
,
}
from
'
~/design_management/utils/cache_update
'
;
import
{
designDeletionError
,
...
...
@@ -26,11 +26,11 @@ describe('Design Management cache update', () => {
describe
(
'
error handling
'
,
()
=>
{
it
.
each
`
fnName | subject | errorMessage | extraArgs
${
'
updateStoreAfterDesignsDelete
'
}
|
${
updateStoreAfterDesignsDelete
}
|
${
designDeletionError
({
singular
:
true
})}
|
${[[
design
]]}
${
'
updateStoreAfterAddImageDiffNote
'
}
|
${
updateStoreAfterAddImageDiffNote
}
|
${
ADD_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
${
'
updateStoreAfterUploadDesign
'
}
|
${
updateStoreAfterUploadDesign
}
|
${
mockErrors
[
0
]}
|
${[]}
${
'
updateStoreAfterUpdateImageDiffNote
'
}
|
${
updateStoreAfter
Update
ImageDiffNote
}
|
${
UPDATE_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
fnName | subject
| errorMessage | extraArgs
${
'
updateStoreAfterDesignsDelete
'
}
|
${
updateStoreAfterDesignsDelete
}
|
${
designDeletionError
({
singular
:
true
})}
|
${[[
design
]]}
${
'
updateStoreAfterAddImageDiffNote
'
}
|
${
updateStoreAfterAddImageDiffNote
}
|
${
ADD_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
${
'
updateStoreAfterUploadDesign
'
}
|
${
updateStoreAfterUploadDesign
}
|
${
mockErrors
[
0
]}
|
${[]}
${
'
updateStoreAfterUpdateImageDiffNote
'
}
|
${
updateStoreAfter
Reposition
ImageDiffNote
}
|
${
UPDATE_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
`
(
'
$fnName handles errors in response
'
,
({
subject
,
extraArgs
,
errorMessage
})
=>
{
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(()
=>
subject
(
mockStore
,
{
errors
:
mockErrors
},
{},
...
extraArgs
)).
toThrow
();
...
...
spec/frontend/design_management/utils/design_management_utils_spec.js
View file @
3d6713f6
...
...
@@ -3,7 +3,7 @@ import {
extractDiscussions
,
findVersionId
,
designUploadOptimisticResponse
,
update
ImageDiffNoteOptimisticResponse
,
reposition
ImageDiffNoteOptimisticResponse
,
isValidDesignFile
,
extractDesign
,
extractDesignNoteId
,
...
...
@@ -112,7 +112,7 @@ describe('optimistic responses', () => {
expect
(
designUploadOptimisticResponse
([{
name
:
'
test
'
}])).
toEqual
(
expectedResponse
);
});
it
(
'
correctly generated for
update
ImageDiffNoteOptimisticResponse
'
,
()
=>
{
it
(
'
correctly generated for
reposition
ImageDiffNoteOptimisticResponse
'
,
()
=>
{
const
mockNote
=
{
id
:
'
test-note-id
'
,
};
...
...
@@ -126,8 +126,8 @@ describe('optimistic responses', () => {
const
expectedResponse
=
{
__typename
:
'
Mutation
'
,
update
ImageDiffNote
:
{
__typename
:
'
Update
ImageDiffNotePayload
'
,
reposition
ImageDiffNote
:
{
__typename
:
'
Reposition
ImageDiffNotePayload
'
,
note
:
{
...
mockNote
,
position
:
mockPosition
,
...
...
@@ -135,7 +135,7 @@ describe('optimistic responses', () => {
errors
:
[],
},
};
expect
(
update
ImageDiffNoteOptimisticResponse
(
mockNote
,
{
position
:
mockPosition
})).
toEqual
(
expect
(
reposition
ImageDiffNoteOptimisticResponse
(
mockNote
,
{
position
:
mockPosition
})).
toEqual
(
expectedResponse
,
);
});
...
...
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