Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 15:08:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 15:08:18 +0300
commitd00cd98a2b1b3f0899677f61257821c94cde8e31 (patch)
tree602dc6d5ca71906ff282d87808c0c1d04b853aeb /app/assets/javascripts/boards
parentedf0e5b64384499283b406f9087e890ac4fad13f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/boards')
-rw-r--r--app/assets/javascripts/boards/graphql/cache_updates.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/app/assets/javascripts/boards/graphql/cache_updates.js b/app/assets/javascripts/boards/graphql/cache_updates.js
index 084809e4e60..1bd3ffea3df 100644
--- a/app/assets/javascripts/boards/graphql/cache_updates.js
+++ b/app/assets/javascripts/boards/graphql/cache_updates.js
@@ -2,10 +2,21 @@ import produce from 'immer';
import listQuery from 'ee_else_ce/boards/graphql/board_lists_deferred.query.graphql';
import { listsDeferredQuery } from 'ee_else_ce/boards/constants';
-export function removeItemFromList({ query, variables, boardType, id, issuableType, cache }) {
+export function removeItemFromList({
+ query,
+ variables,
+ boardType,
+ id,
+ issuableType,
+ listId = undefined,
+ cache,
+}) {
cache.updateQuery({ query, variables }, (sourceData) =>
produce(sourceData, (draftData) => {
- const { nodes: items } = draftData[boardType].board.lists.nodes[0][`${issuableType}s`];
+ const list = listId
+ ? draftData[boardType]?.board.lists.nodes.find((l) => l.id === listId)
+ : draftData[boardType].board.lists.nodes[0];
+ const { nodes: items } = list[`${issuableType}s`];
items.splice(
items.findIndex((item) => item.id === id),
1,
@@ -21,11 +32,15 @@ export function addItemToList({
issuable,
newIndex,
issuableType,
+ listId = undefined,
cache,
}) {
cache.updateQuery({ query, variables }, (sourceData) =>
produce(sourceData, (draftData) => {
- const { nodes: items } = draftData[boardType].board.lists.nodes[0][`${issuableType}s`];
+ const list = listId
+ ? draftData[boardType]?.board.lists.nodes.find((l) => l.id === listId)
+ : draftData[boardType].board.lists.nodes[0];
+ const { nodes: items } = list[`${issuableType}s`];
items.splice(newIndex, 0, issuable);
}),
);