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
3584d377
Commit
3584d377
authored
Feb 13, 2020
by
ntepluhina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted immer changes
parent
4376e173
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
75 deletions
+75
-75
ee/app/assets/javascripts/design_management/graphql.js
ee/app/assets/javascripts/design_management/graphql.js
+0
-1
ee/app/assets/javascripts/design_management/utils/cache_update.js
...ssets/javascripts/design_management/utils/cache_update.js
+75
-74
No files found.
ee/app/assets/javascripts/design_management/graphql.js
View file @
3584d377
...
...
@@ -20,7 +20,6 @@ const defaultClient = createDefaultClient(
return
defaultDataIdFromObject
(
object
);
},
},
assumeImmutableResults
:
true
,
},
);
...
...
ee/app/assets/javascripts/design_management/utils/cache_update.js
View file @
3584d377
/* eslint no-param-reassign: ["error", { "props": false }] */
import
produce
from
'
immer
'
;
import
createFlash
from
'
~/flash
'
;
import
{
extractCurrentDiscussion
,
extractDesign
}
from
'
./design_management_utils
'
;
import
{
...
...
@@ -10,20 +7,13 @@ import {
designDeletionError
,
}
from
'
./error_messages
'
;
const
designsOf
=
data
=>
data
.
project
.
issue
.
designCollection
.
designs
;
const
isParticipating
=
(
design
,
username
)
=>
design
.
issue
.
participants
.
edges
.
some
(
participant
=>
participant
.
node
.
username
===
username
);
const
deleteDesignsFromStore
=
(
store
,
query
,
selectedDesigns
)
=>
{
const
sourceD
ata
=
store
.
readQuery
(
query
);
const
d
ata
=
store
.
readQuery
(
query
);
const
data
=
produce
(
sourceData
,
draftData
=>
{
const
changedDesigns
=
designsOf
(
sourceData
).
edges
.
filter
(
const
changedDesigns
=
data
.
project
.
issue
.
designCollection
.
designs
.
edges
.
filter
(
({
node
})
=>
!
selectedDesigns
.
includes
(
node
.
filename
),
);
designsOf
(
draftData
).
edges
=
[...
changedDesigns
];
});
data
.
project
.
issue
.
designCollection
.
designs
.
edges
=
[...
changedDesigns
];
store
.
writeQuery
({
...
query
,
...
...
@@ -41,13 +31,13 @@ const deleteDesignsFromStore = (store, query, selectedDesigns) => {
const
addNewVersionToStore
=
(
store
,
query
,
version
)
=>
{
if
(
!
version
)
return
;
const
sourceData
=
store
.
readQuery
(
query
);
const
newVersion
=
{
node
:
version
,
__typename
:
'
DesignVersionEdge
'
};
const
data
=
store
.
readQuery
(
query
);
const
newEdge
=
{
node
:
version
,
__typename
:
'
DesignVersionEdge
'
};
const
data
=
produce
(
sourceData
,
draftData
=>
{
draftData
.
project
.
issue
.
designCollection
.
versions
.
edges
.
unshift
(
newVersion
);
});
data
.
project
.
issue
.
designCollection
.
versions
.
edges
=
[
newEdge
,
...
data
.
project
.
issue
.
designCollection
.
versions
.
edges
,
];
store
.
writeQuery
({
...
query
,
...
...
@@ -56,48 +46,56 @@ const addNewVersionToStore = (store, query, version) => {
};
const
addDiscussionCommentToStore
=
(
store
,
createNote
,
query
,
queryVariables
,
discussionId
)
=>
{
const
sourceD
ata
=
store
.
readQuery
({
const
d
ata
=
store
.
readQuery
({
query
,
variables
:
queryVariables
,
});
const
newParticipant
=
{
const
design
=
extractDesign
(
data
);
const
currentDiscussion
=
extractCurrentDiscussion
(
design
.
discussions
,
discussionId
);
currentDiscussion
.
node
.
notes
.
edges
=
[
...
currentDiscussion
.
node
.
notes
.
edges
,
{
__typename
:
'
NoteEdge
'
,
node
:
createNote
.
note
,
},
];
design
.
notesCount
+=
1
;
if
(
!
design
.
issue
.
participants
.
edges
.
some
(
participant
=>
participant
.
node
.
username
===
createNote
.
note
.
author
.
username
,
)
)
{
design
.
issue
.
participants
.
edges
=
[
...
design
.
issue
.
participants
.
edges
,
{
__typename
:
'
UserEdge
'
,
node
:
{
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
__typename
:
'
User
'
,
...
createNote
.
note
.
author
,
},
};
const
data
=
produce
(
sourceData
,
draftData
=>
{
const
design
=
extractDesign
(
draftData
);
const
currentDiscussion
=
extractCurrentDiscussion
(
design
.
discussions
,
discussionId
);
currentDiscussion
.
node
.
notes
.
edges
.
push
({
__typename
:
'
NoteEdge
'
,
node
:
createNote
.
note
,
});
if
(
!
isParticipating
(
design
,
createNote
.
note
.
author
.
username
))
{
design
.
issue
.
participants
.
edges
.
push
(
newParticipant
);
},
];
}
design
.
notesCount
+=
1
;
});
store
.
writeQuery
({
query
,
variables
:
queryVariables
,
data
,
data
:
{
...
data
,
design
:
{
...
design
,
},
},
});
};
const
addImageDiffNoteToStore
=
(
store
,
createImageDiffNote
,
query
,
variables
)
=>
{
const
sourceD
ata
=
store
.
readQuery
({
const
d
ata
=
store
.
readQuery
({
query
,
variables
,
});
const
newDiscussion
=
{
__typename
:
'
DiscussionEdge
'
,
node
:
{
...
...
@@ -117,38 +115,43 @@ const addImageDiffNoteToStore = (store, createImageDiffNote, query, variables) =
},
},
};
const
newParticipant
=
{
const
design
=
extractDesign
(
data
);
const
notesCount
=
design
.
notesCount
+
1
;
design
.
discussions
.
edges
=
[...
design
.
discussions
.
edges
,
newDiscussion
];
if
(
!
design
.
issue
.
participants
.
edges
.
some
(
participant
=>
participant
.
node
.
username
===
createImageDiffNote
.
note
.
author
.
username
,
)
)
{
design
.
issue
.
participants
.
edges
=
[
...
design
.
issue
.
participants
.
edges
,
{
__typename
:
'
UserEdge
'
,
node
:
{
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
__typename
:
'
User
'
,
...
createImageDiffNote
.
note
.
author
,
},
};
const
data
=
produce
(
sourceData
,
draftData
=>
{
const
design
=
extractDesign
(
draftData
);
design
.
discussions
.
edges
.
push
(
newDiscussion
);
if
(
!
isParticipating
(
design
,
createImageDiffNote
.
note
.
author
.
username
))
{
design
.
issue
.
participants
.
edges
.
push
(
newParticipant
);
},
];
}
design
.
notesCount
+=
1
;
});
store
.
writeQuery
({
query
,
variables
,
data
,
data
:
{
...
data
,
design
:
{
...
design
,
notesCount
,
},
},
});
};
const
addNewDesignToStore
=
(
store
,
designManagementUpload
,
query
)
=>
{
const
sourceD
ata
=
store
.
readQuery
(
query
);
const
d
ata
=
store
.
readQuery
(
query
);
const
newDesigns
=
d
esignsOf
(
sourceData
)
.
edges
.
reduce
((
acc
,
design
)
=>
{
const
newDesigns
=
d
ata
.
project
.
issue
.
designCollection
.
designs
.
edges
.
reduce
((
acc
,
design
)
=>
{
if
(
!
acc
.
find
(
d
=>
d
.
filename
===
design
.
node
.
filename
))
{
acc
.
push
(
design
.
node
);
}
...
...
@@ -169,7 +172,7 @@ const addNewDesignToStore = (store, designManagementUpload, query) => {
const
newVersions
=
[
...(
newVersionNode
||
[]),
...
sourceD
ata
.
project
.
issue
.
designCollection
.
versions
.
edges
,
...
d
ata
.
project
.
issue
.
designCollection
.
versions
.
edges
,
];
const
updatedDesigns
=
{
...
...
@@ -187,9 +190,7 @@ const addNewDesignToStore = (store, designManagementUpload, query) => {
},
};
const
data
=
produce
(
sourceData
,
draftData
=>
{
draftData
.
project
.
issue
.
designCollection
=
updatedDesigns
;
});
data
.
project
.
issue
.
designCollection
=
updatedDesigns
;
store
.
writeQuery
({
...
query
,
...
...
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