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
4cd8ae32
Commit
4cd8ae32
authored
Sep 10, 2020
by
Tom Quirk
Committed by
Natalia Tepluhina
Sep 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Part 2: Add todo-related queries/resolvers to Design Management
parent
7c655802
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
7 deletions
+49
-7
app/assets/javascripts/design_management/graphql/fragments/design_list.fragment.graphql
...management/graphql/fragments/design_list.fragment.graphql
+5
-0
app/assets/javascripts/design_management/utils/cache_update.js
...ssets/javascripts/design_management/utils/cache_update.js
+26
-7
spec/frontend/design_management/mock_data/apollo_mock.js
spec/frontend/design_management/mock_data/apollo_mock.js
+18
-0
No files found.
app/assets/javascripts/design_management/graphql/fragments/design_list.fragment.graphql
View file @
4cd8ae32
...
...
@@ -5,4 +5,9 @@ fragment DesignListItem on Design {
notesCount
image
imageV432x230
currentUserTodos
(
state
:
pending
)
{
nodes
{
id
}
}
}
app/assets/javascripts/design_management/utils/cache_update.js
View file @
4cd8ae32
...
...
@@ -190,25 +190,44 @@ const moveDesignInStore = (store, designManagementMove, query) => {
};
export
const
addPendingTodoToStore
=
(
store
,
pendingTodo
,
query
,
queryVariables
)
=>
{
const
d
ata
=
store
.
readQuery
({
const
sourceD
ata
=
store
.
readQuery
({
query
,
variables
:
queryVariables
,
});
// TODO produce new version of data that includes the new pendingTodo.
// This is only possible after BE MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40555
const
data
=
produce
(
sourceData
,
draftData
=>
{
const
design
=
extractDesign
(
draftData
);
const
existingTodos
=
design
.
currentUserTodos
?.
nodes
||
[];
const
newTodoNodes
=
[...
existingTodos
,
{
...
pendingTodo
,
__typename
:
'
Todo
'
}];
if
(
!
design
.
currentUserTodos
)
{
design
.
currentUserTodos
=
{
__typename
:
'
TodoConnection
'
,
nodes
:
newTodoNodes
,
};
}
else
{
design
.
currentUserTodos
.
nodes
=
newTodoNodes
;
}
});
store
.
writeQuery
({
query
,
variables
:
queryVariables
,
data
});
};
export
const
deletePendingTodoFromStore
=
(
store
,
pendingTodo
,
query
,
queryVariables
)
=>
{
const
d
ata
=
store
.
readQuery
({
export
const
deletePendingTodoFromStore
=
(
store
,
todoMarkDone
,
query
,
queryVariables
)
=>
{
const
sourceD
ata
=
store
.
readQuery
({
query
,
variables
:
queryVariables
,
});
// TODO produce new version of data without the pendingTodo.
// This is only possible after BE MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40555
const
{
todo
:
{
id
:
todoId
},
}
=
todoMarkDone
;
const
data
=
produce
(
sourceData
,
draftData
=>
{
const
design
=
extractDesign
(
draftData
);
const
existingTodos
=
design
.
currentUserTodos
?.
nodes
||
[];
design
.
currentUserTodos
.
nodes
=
existingTodos
.
filter
(({
id
})
=>
id
!==
todoId
);
});
store
.
writeQuery
({
query
,
variables
:
queryVariables
,
data
});
};
...
...
spec/frontend/design_management/mock_data/apollo_mock.js
View file @
4cd8ae32
...
...
@@ -13,6 +13,9 @@ export const designListQueryResponse = {
notesCount
:
3
,
image
:
'
image-1
'
,
imageV432x230
:
'
image-1
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
{
id
:
'
2
'
,
...
...
@@ -21,6 +24,9 @@ export const designListQueryResponse = {
notesCount
:
2
,
image
:
'
image-2
'
,
imageV432x230
:
'
image-2
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
{
id
:
'
3
'
,
...
...
@@ -29,6 +35,9 @@ export const designListQueryResponse = {
notesCount
:
1
,
image
:
'
image-3
'
,
imageV432x230
:
'
image-3
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
],
},
...
...
@@ -60,6 +69,9 @@ export const reorderedDesigns = [
notesCount
:
2
,
image
:
'
image-2
'
,
imageV432x230
:
'
image-2
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
{
id
:
'
1
'
,
...
...
@@ -68,6 +80,9 @@ export const reorderedDesigns = [
notesCount
:
3
,
image
:
'
image-1
'
,
imageV432x230
:
'
image-1
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
{
id
:
'
3
'
,
...
...
@@ -76,6 +91,9 @@ export const reorderedDesigns = [
notesCount
:
1
,
image
:
'
image-3
'
,
imageV432x230
:
'
image-3
'
,
currentUserTodos
:
{
nodes
:
[],
},
},
];
...
...
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