Commit 159e9869 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '31258-design-management-graphql-uses-deprecated-field-designs-2' into 'master'

Resolve "Design Management GraphQL Uses Deprecated Field `designs`"

See merge request gitlab-org/gitlab!19472
parents a0e07733 30fff052
...@@ -29,7 +29,7 @@ const defaultClient = createDefaultClient( ...@@ -29,7 +29,7 @@ const defaultClient = createDefaultClient(
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
const edge = data.project.issue.designs.designs.edges.find( const edge = data.project.issue.designCollection.designs.edges.find(
({ node }) => node.filename === id, ({ node }) => node.filename === id,
); );
return edge.node; return edge.node;
......
...@@ -5,7 +5,7 @@ query project($fullPath: ID!, $iid: String!, $atVersion: ID) { ...@@ -5,7 +5,7 @@ query project($fullPath: ID!, $iid: String!, $atVersion: ID) {
project(fullPath: $fullPath) { project(fullPath: $fullPath) {
id id
issue(iid: $iid) { issue(iid: $iid) {
designs { designCollection {
designs(atVersion: $atVersion) { designs(atVersion: $atVersion) {
edges { edges {
node { node {
......
...@@ -37,7 +37,7 @@ export default () => { ...@@ -37,7 +37,7 @@ export default () => {
}) })
.subscribe(({ data }) => { .subscribe(({ data }) => {
if (badge) { if (badge) {
badge.textContent = data.project.issue.designs.designs.edges.length; badge.textContent = data.project.issue.designCollection.designs.edges.length;
} }
}); });
......
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}; };
}, },
update: data => { update: data => {
const designEdges = propertyOf(data)(['project', 'issue', 'designs', 'designs']); const designEdges = propertyOf(data)(['project', 'issue', 'designCollection', 'designs']);
if (designEdges) { if (designEdges) {
return extractNodes(designEdges); return extractNodes(designEdges);
} }
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
atVersion: null, atVersion: null,
}; };
}, },
update: data => data.project.issue.designs.versions.edges, update: data => data.project.issue.designCollection.versions.edges,
}, },
}, },
computed: { computed: {
......
...@@ -147,13 +147,16 @@ export default { ...@@ -147,13 +147,16 @@ export default {
update: (store, { data: { designManagementUpload } }) => { update: (store, { data: { designManagementUpload } }) => {
const data = store.readQuery(this.projectQueryBody); const data = store.readQuery(this.projectQueryBody);
const newDesigns = data.project.issue.designs.designs.edges.reduce((acc, design) => { const newDesigns = data.project.issue.designCollection.designs.edges.reduce(
(acc, design) => {
if (!acc.find(d => d.filename === design.node.filename)) { if (!acc.find(d => d.filename === design.node.filename)) {
acc.push(design.node); acc.push(design.node);
} }
return acc; return acc;
}, designManagementUpload.designs); },
designManagementUpload.designs,
);
let newVersionNode; let newVersionNode;
const findNewVersions = designManagementUpload.designs.find(design => design.versions); const findNewVersions = designManagementUpload.designs.find(design => design.versions);
...@@ -168,7 +171,7 @@ export default { ...@@ -168,7 +171,7 @@ export default {
const newVersions = [ const newVersions = [
...(newVersionNode || []), ...(newVersionNode || []),
...data.project.issue.designs.versions.edges, ...data.project.issue.designCollection.versions.edges,
]; ];
const updatedDesigns = { const updatedDesigns = {
...@@ -186,7 +189,7 @@ export default { ...@@ -186,7 +189,7 @@ export default {
}, },
}; };
data.project.issue.designs = updatedDesigns; data.project.issue.designCollection = updatedDesigns;
store.writeQuery({ store.writeQuery({
...this.projectQueryBody, ...this.projectQueryBody,
......
...@@ -36,10 +36,10 @@ export const extractCurrentDiscussion = (discussions, id) => ...@@ -36,10 +36,10 @@ export const extractCurrentDiscussion = (discussions, id) =>
const deleteDesignsFromStore = (store, query, selectedDesigns) => { const deleteDesignsFromStore = (store, query, selectedDesigns) => {
const data = store.readQuery(query); const data = store.readQuery(query);
const changedDesigns = data.project.issue.designs.designs.edges.filter( const changedDesigns = data.project.issue.designCollection.designs.edges.filter(
({ node }) => !selectedDesigns.includes(node.filename), ({ node }) => !selectedDesigns.includes(node.filename),
); );
data.project.issue.designs.designs.edges = [...changedDesigns]; data.project.issue.designCollection.designs.edges = [...changedDesigns];
store.writeQuery({ store.writeQuery({
...query, ...query,
...@@ -53,9 +53,9 @@ const addNewVersionToStore = (store, query, version) => { ...@@ -53,9 +53,9 @@ const addNewVersionToStore = (store, query, version) => {
const data = store.readQuery(query); const data = store.readQuery(query);
const newEdge = { node: version, __typename: 'DesignVersionEdge' }; const newEdge = { node: version, __typename: 'DesignVersionEdge' };
data.project.issue.designs.versions.edges = [ data.project.issue.designCollection.versions.edges = [
newEdge, newEdge,
...data.project.issue.designs.versions.edges, ...data.project.issue.designCollection.versions.edges,
]; ];
store.writeQuery({ store.writeQuery({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment