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 {
...
@@ -112,9 +112,9 @@ export default {
},
},
canMoveNote
(
note
)
{
canMoveNote
(
note
)
{
const
{
userPermissions
}
=
note
;
const
{
userPermissions
}
=
note
;
const
{
admi
nNote
}
=
userPermissions
||
{};
const
{
repositio
nNote
}
=
userPermissions
||
{};
return
Boolean
(
admi
nNote
);
return
Boolean
(
repositio
nNote
);
},
},
isPositionInOverlay
(
position
)
{
isPositionInOverlay
(
position
)
{
const
{
top
,
left
}
=
this
.
getNoteRelativePosition
(
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
{
fragment
DesignNotePermissions
on
NotePermissions
{
adminNote
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"
#import "../fragments/design_note.fragment.graphql"
mutation
updateImageDiffNote
(
$input
:
Update
ImageDiffNoteInput
!)
{
mutation
repositionImageDiffNote
(
$input
:
Reposition
ImageDiffNoteInput
!)
{
update
ImageDiffNote
(
input
:
$input
)
{
reposition
ImageDiffNote
(
input
:
$input
)
{
errors
errors
note
{
note
{
...
DesignNote
...
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
...
@@ -13,19 +13,19 @@ import DesignReplyForm from '../../components/design_notes/design_reply_form.vue
import
DesignSidebar
from
'
../../components/design_sidebar.vue
'
;
import
DesignSidebar
from
'
../../components/design_sidebar.vue
'
;
import
getDesignQuery
from
'
../../graphql/queries/get_design.query.graphql
'
;
import
getDesignQuery
from
'
../../graphql/queries/get_design.query.graphql
'
;
import
createImageDiffNoteMutation
from
'
../../graphql/mutations/create_image_diff_note.mutation.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
updateActiveDiscussionMutation
from
'
../../graphql/mutations/update_active_discussion.mutation.graphql
'
;
import
{
import
{
extractDiscussions
,
extractDiscussions
,
extractDesign
,
extractDesign
,
update
ImageDiffNoteOptimisticResponse
,
reposition
ImageDiffNoteOptimisticResponse
,
toDiffNoteGid
,
toDiffNoteGid
,
extractDesignNoteId
,
extractDesignNoteId
,
getPageLayoutElement
,
getPageLayoutElement
,
}
from
'
../../utils/design_management_utils
'
;
}
from
'
../../utils/design_management_utils
'
;
import
{
import
{
updateStoreAfterAddImageDiffNote
,
updateStoreAfterAddImageDiffNote
,
updateStoreAfter
Update
ImageDiffNote
,
updateStoreAfter
Reposition
ImageDiffNote
,
}
from
'
../../utils/cache_update
'
;
}
from
'
../../utils/cache_update
'
;
import
{
import
{
ADD_DISCUSSION_COMMENT_ERROR
,
ADD_DISCUSSION_COMMENT_ERROR
,
...
@@ -182,12 +182,12 @@ export default {
...
@@ -182,12 +182,12 @@ export default {
updateImageDiffNoteInStore
(
updateImageDiffNoteInStore
(
store
,
store
,
{
{
data
:
{
update
ImageDiffNote
},
data
:
{
reposition
ImageDiffNote
},
},
},
)
{
)
{
return
updateStoreAfter
Update
ImageDiffNote
(
return
updateStoreAfter
Reposition
ImageDiffNote
(
store
,
store
,
update
ImageDiffNote
,
reposition
ImageDiffNote
,
getDesignQuery
,
getDesignQuery
,
this
.
designVariables
,
this
.
designVariables
,
);
);
...
@@ -199,7 +199,7 @@ export default {
...
@@ -199,7 +199,7 @@ export default {
);
);
const
mutationPayload
=
{
const
mutationPayload
=
{
optimisticResponse
:
update
ImageDiffNoteOptimisticResponse
(
note
,
{
optimisticResponse
:
reposition
ImageDiffNoteOptimisticResponse
(
note
,
{
position
,
position
,
}),
}),
variables
:
{
variables
:
{
...
@@ -208,7 +208,7 @@ export default {
...
@@ -208,7 +208,7 @@ export default {
position
,
position
,
},
},
},
},
mutation
:
update
ImageDiffNoteMutation
,
mutation
:
reposition
ImageDiffNoteMutation
,
update
:
this
.
updateImageDiffNoteInStore
,
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) =
...
@@ -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
({
const
sourceData
=
store
.
readQuery
({
query
,
query
,
variables
,
variables
,
...
@@ -111,12 +111,12 @@ const updateImageDiffNoteInStore = (store, updateImageDiffNote, query, variables
...
@@ -111,12 +111,12 @@ const updateImageDiffNoteInStore = (store, updateImageDiffNote, query, variables
const
design
=
extractDesign
(
draftData
);
const
design
=
extractDesign
(
draftData
);
const
discussion
=
extractCurrentDiscussion
(
const
discussion
=
extractCurrentDiscussion
(
design
.
discussions
,
design
.
discussions
,
update
ImageDiffNote
.
note
.
discussion
.
id
,
reposition
ImageDiffNote
.
note
.
discussion
.
id
,
);
);
discussion
.
notes
=
{
discussion
.
notes
=
{
...
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
...
@@ -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
))
{
if
(
hasErrors
(
data
))
{
onError
(
data
,
UPDATE_IMAGE_DIFF_NOTE_ERROR
);
onError
(
data
,
UPDATE_IMAGE_DIFF_NOTE_ERROR
);
}
else
{
}
else
{
...
...
app/assets/javascripts/design_management/utils/design_management_utils.js
View file @
3d6713f6
...
@@ -107,12 +107,12 @@ export const designUploadOptimisticResponse = files => {
...
@@ -107,12 +107,12 @@ export const designUploadOptimisticResponse = files => {
* @param {Object} note
* @param {Object} note
* @param {Object} position
* @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
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/require-i18n-strings
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename
:
'
Mutation
'
,
__typename
:
'
Mutation
'
,
update
ImageDiffNote
:
{
reposition
ImageDiffNote
:
{
__typename
:
'
Update
ImageDiffNotePayload
'
,
__typename
:
'
Reposition
ImageDiffNotePayload
'
,
note
:
{
note
:
{
...
note
,
...
note
,
position
:
{
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', () => {
...
@@ -243,11 +243,11 @@ describe('Design overlay component', () => {
});
});
});
});
describe
(
'
without [
admi
nNote] permission
'
,
()
=>
{
describe
(
'
without [
repositio
nNote] permission
'
,
()
=>
{
const
mockNoteNotAuthorised
=
{
const
mockNoteNotAuthorised
=
{
...
notes
[
0
],
...
notes
[
0
],
userPermissions
:
{
userPermissions
:
{
admi
nNote
:
false
,
repositio
nNote
:
false
,
},
},
};
};
...
@@ -412,18 +412,18 @@ describe('Design overlay component', () => {
...
@@ -412,18 +412,18 @@ describe('Design overlay component', () => {
describe
(
'
canMoveNote
'
,
()
=>
{
describe
(
'
canMoveNote
'
,
()
=>
{
it
.
each
`
it
.
each
`
admi
nNotePermission | canMoveNoteResult
repositio
nNotePermission | canMoveNoteResult
${
true
}
|
${
true
}
${
true
}
|
${
true
}
${
false
}
|
${
false
}
${
false
}
|
${
false
}
${
undefined
}
|
${
false
}
${
undefined
}
|
${
false
}
`
(
`
(
'
returns [$canMoveNoteResult] when [
adminNote permission] is [$admi
nNotePermission]
'
,
'
returns [$canMoveNoteResult] when [
repositionNote permission] is [$repositio
nNotePermission]
'
,
({
admi
nNotePermission
,
canMoveNoteResult
})
=>
{
({
repositio
nNotePermission
,
canMoveNoteResult
})
=>
{
createComponent
();
createComponent
();
const
note
=
{
const
note
=
{
userPermissions
:
{
userPermissions
:
{
adminNote
:
admi
nNotePermission
,
repositionNote
:
repositio
nNotePermission
,
},
},
};
};
expect
(
wrapper
.
vm
.
canMoveNote
(
note
)).
toBe
(
canMoveNoteResult
);
expect
(
wrapper
.
vm
.
canMoveNote
(
note
)).
toBe
(
canMoveNoteResult
);
...
...
spec/frontend/design_management/mock_data/discussion.js
View file @
3d6713f6
...
@@ -18,7 +18,7 @@ export default {
...
@@ -18,7 +18,7 @@ export default {
},
},
createdAt
:
'
2020-05-08T07:10:45Z
'
,
createdAt
:
'
2020-05-08T07:10:45Z
'
,
userPermissions
:
{
userPermissions
:
{
admi
nNote
:
true
,
repositio
nNote
:
true
,
},
},
resolved
:
false
,
resolved
:
false
,
},
},
...
...
spec/frontend/design_management/utils/cache_update_spec.js
View file @
3d6713f6
...
@@ -3,7 +3,7 @@ import {
...
@@ -3,7 +3,7 @@ import {
updateStoreAfterDesignsDelete
,
updateStoreAfterDesignsDelete
,
updateStoreAfterAddImageDiffNote
,
updateStoreAfterAddImageDiffNote
,
updateStoreAfterUploadDesign
,
updateStoreAfterUploadDesign
,
updateStoreAfter
Update
ImageDiffNote
,
updateStoreAfter
Reposition
ImageDiffNote
,
}
from
'
~/design_management/utils/cache_update
'
;
}
from
'
~/design_management/utils/cache_update
'
;
import
{
import
{
designDeletionError
,
designDeletionError
,
...
@@ -26,11 +26,11 @@ describe('Design Management cache update', () => {
...
@@ -26,11 +26,11 @@ describe('Design Management cache update', () => {
describe
(
'
error handling
'
,
()
=>
{
describe
(
'
error handling
'
,
()
=>
{
it
.
each
`
it
.
each
`
fnName | subject | errorMessage | extraArgs
fnName | subject
| errorMessage | extraArgs
${
'
updateStoreAfterDesignsDelete
'
}
|
${
updateStoreAfterDesignsDelete
}
|
${
designDeletionError
({
singular
:
true
})}
|
${[[
design
]]}
${
'
updateStoreAfterDesignsDelete
'
}
|
${
updateStoreAfterDesignsDelete
}
|
${
designDeletionError
({
singular
:
true
})}
|
${[[
design
]]}
${
'
updateStoreAfterAddImageDiffNote
'
}
|
${
updateStoreAfterAddImageDiffNote
}
|
${
ADD_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
${
'
updateStoreAfterAddImageDiffNote
'
}
|
${
updateStoreAfterAddImageDiffNote
}
|
${
ADD_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
${
'
updateStoreAfterUploadDesign
'
}
|
${
updateStoreAfterUploadDesign
}
|
${
mockErrors
[
0
]}
|
${[]}
${
'
updateStoreAfterUploadDesign
'
}
|
${
updateStoreAfterUploadDesign
}
|
${
mockErrors
[
0
]}
|
${[]}
${
'
updateStoreAfterUpdateImageDiffNote
'
}
|
${
updateStoreAfter
Update
ImageDiffNote
}
|
${
UPDATE_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
${
'
updateStoreAfterUpdateImageDiffNote
'
}
|
${
updateStoreAfter
Reposition
ImageDiffNote
}
|
${
UPDATE_IMAGE_DIFF_NOTE_ERROR
}
|
${[]}
`
(
'
$fnName handles errors in response
'
,
({
subject
,
extraArgs
,
errorMessage
})
=>
{
`
(
'
$fnName handles errors in response
'
,
({
subject
,
extraArgs
,
errorMessage
})
=>
{
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(()
=>
subject
(
mockStore
,
{
errors
:
mockErrors
},
{},
...
extraArgs
)).
toThrow
();
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 {
...
@@ -3,7 +3,7 @@ import {
extractDiscussions
,
extractDiscussions
,
findVersionId
,
findVersionId
,
designUploadOptimisticResponse
,
designUploadOptimisticResponse
,
update
ImageDiffNoteOptimisticResponse
,
reposition
ImageDiffNoteOptimisticResponse
,
isValidDesignFile
,
isValidDesignFile
,
extractDesign
,
extractDesign
,
extractDesignNoteId
,
extractDesignNoteId
,
...
@@ -112,7 +112,7 @@ describe('optimistic responses', () => {
...
@@ -112,7 +112,7 @@ describe('optimistic responses', () => {
expect
(
designUploadOptimisticResponse
([{
name
:
'
test
'
}])).
toEqual
(
expectedResponse
);
expect
(
designUploadOptimisticResponse
([{
name
:
'
test
'
}])).
toEqual
(
expectedResponse
);
});
});
it
(
'
correctly generated for
update
ImageDiffNoteOptimisticResponse
'
,
()
=>
{
it
(
'
correctly generated for
reposition
ImageDiffNoteOptimisticResponse
'
,
()
=>
{
const
mockNote
=
{
const
mockNote
=
{
id
:
'
test-note-id
'
,
id
:
'
test-note-id
'
,
};
};
...
@@ -126,8 +126,8 @@ describe('optimistic responses', () => {
...
@@ -126,8 +126,8 @@ describe('optimistic responses', () => {
const
expectedResponse
=
{
const
expectedResponse
=
{
__typename
:
'
Mutation
'
,
__typename
:
'
Mutation
'
,
update
ImageDiffNote
:
{
reposition
ImageDiffNote
:
{
__typename
:
'
Update
ImageDiffNotePayload
'
,
__typename
:
'
Reposition
ImageDiffNotePayload
'
,
note
:
{
note
:
{
...
mockNote
,
...
mockNote
,
position
:
mockPosition
,
position
:
mockPosition
,
...
@@ -135,7 +135,7 @@ describe('optimistic responses', () => {
...
@@ -135,7 +135,7 @@ describe('optimistic responses', () => {
errors
:
[],
errors
:
[],
},
},
};
};
expect
(
update
ImageDiffNoteOptimisticResponse
(
mockNote
,
{
position
:
mockPosition
})).
toEqual
(
expect
(
reposition
ImageDiffNoteOptimisticResponse
(
mockNote
,
{
position
:
mockPosition
})).
toEqual
(
expectedResponse
,
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