diff options
Diffstat (limited to 'app/assets/javascripts/clusters_list/graphql/cache_update.js')
-rw-r--r-- | app/assets/javascripts/clusters_list/graphql/cache_update.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/assets/javascripts/clusters_list/graphql/cache_update.js b/app/assets/javascripts/clusters_list/graphql/cache_update.js index 4d12bc8151c..6476b7a6c2f 100644 --- a/app/assets/javascripts/clusters_list/graphql/cache_update.js +++ b/app/assets/javascripts/clusters_list/graphql/cache_update.js @@ -63,3 +63,25 @@ export function addAgentConfigToStore( }); } } + +export function removeAgentFromStore(store, deleteClusterAgent, query, variables) { + if (!hasErrors(deleteClusterAgent)) { + const sourceData = store.readQuery({ + query, + variables, + }); + + const data = produce(sourceData, (draftData) => { + draftData.project.clusterAgents.nodes = draftData.project.clusterAgents.nodes.filter( + ({ id }) => id !== deleteClusterAgent.id, + ); + draftData.project.clusterAgents.count -= 1; + }); + + store.writeQuery({ + query, + variables, + data, + }); + } +} |