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
d6f92dc5
Commit
d6f92dc5
authored
Sep 14, 2020
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update apollo mutations to be immutable
- use immer library
parent
4fd889b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
ee/app/assets/javascripts/security_dashboard/components/first_class_project_manager/project_manager.vue
...omponents/first_class_project_manager/project_manager.vue
+21
-9
No files found.
ee/app/assets/javascripts/security_dashboard/components/first_class_project_manager/project_manager.vue
View file @
d6f92dc5
<
script
>
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
produce
from
'
immer
'
;
import
getProjects
from
'
ee/security_dashboard/graphql/get_projects.query.graphql
'
;
import
projectsQuery
from
'
ee/security_dashboard/graphql/get_instance_security_dashboard_projects.query.graphql
'
;
import
addProjectToSecurityDashboard
from
'
ee/security_dashboard/graphql/add_project_to_security_dashboard.mutation.graphql
'
;
...
...
@@ -77,12 +78,20 @@ export default {
return
;
}
const
d
ata
=
store
.
readQuery
({
query
:
projectsQuery
});
const
sourceD
ata
=
store
.
readQuery
({
query
:
projectsQuery
});
const
newProject
=
results
.
addProjectToSecurityDashboard
.
project
;
data
.
instanceSecurityDashboard
.
projects
.
nodes
.
push
({
...
newProject
,
vulnerabilitySeveritiesCount
:
newProject
.
vulnerabilitySeveritiesCount
||
null
,
// This is required to surpress missing field warning in GraphQL.
const
data
=
produce
(
sourceData
,
draftData
=>
{
// eslint-disable-next-line no-param-reassign
draftData
.
instanceSecurityDashboard
.
projects
.
nodes
=
[
...
draftData
.
instanceSecurityDashboard
.
projects
.
nodes
,
{
...
newProject
,
vulnerabilitySeveritiesCount
:
newProject
.
vulnerabilitySeveritiesCount
||
null
,
},
];
});
store
.
writeQuery
({
query
:
projectsQuery
,
data
});
},
})
...
...
@@ -145,12 +154,15 @@ export default {
mutation
:
deleteProjectFromSecurityDashboard
,
variables
:
{
id
},
update
(
store
)
{
const
data
=
store
.
readQuery
({
query
:
projectsQuery
,
const
sourceData
=
store
.
readQuery
({
query
:
projectsQuery
});
const
data
=
produce
(
sourceData
,
draftData
=>
{
// eslint-disable-next-line no-param-reassign
draftData
.
instanceSecurityDashboard
.
projects
.
nodes
=
draftData
.
instanceSecurityDashboard
.
projects
.
nodes
.
filter
(
curr
=>
curr
.
id
!==
id
,
);
});
data
.
instanceSecurityDashboard
.
projects
.
nodes
=
data
.
instanceSecurityDashboard
.
projects
.
nodes
.
filter
(
curr
=>
curr
.
id
!==
id
,
);
store
.
writeQuery
({
query
:
projectsQuery
,
data
});
},
})
...
...
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