diff options
Diffstat (limited to 'app/assets/javascripts/clusters_list/graphql')
-rw-r--r-- | app/assets/javascripts/clusters_list/graphql/cache_update.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/clusters_list/graphql/mutations/delete_agent.mutation.graphql | 5 |
2 files changed, 27 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, + }); + } +} diff --git a/app/assets/javascripts/clusters_list/graphql/mutations/delete_agent.mutation.graphql b/app/assets/javascripts/clusters_list/graphql/mutations/delete_agent.mutation.graphql new file mode 100644 index 00000000000..28387b2a36c --- /dev/null +++ b/app/assets/javascripts/clusters_list/graphql/mutations/delete_agent.mutation.graphql @@ -0,0 +1,5 @@ +mutation deleteClusterAgent($input: ClusterAgentDeleteInput!) { + clusterAgentDelete(input: $input) { + errors + } +} |