From 51f99778850167392db4c175850286a073c7bbe5 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Fri, 14 Jun 2024 00:32:17 +0300 Subject: [PATCH] fix(endpoints): show toaster on delete [EE-7170] (#11889) --- .../edge/edge-stacks/CreateView/useCreate.tsx | 2 ++ .../environments/ListView/ListView.tsx | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/react/edge/edge-stacks/CreateView/useCreate.tsx b/app/react/edge/edge-stacks/CreateView/useCreate.tsx index 92c7e4a4f..cb9ef6e14 100644 --- a/app/react/edge/edge-stacks/CreateView/useCreate.tsx +++ b/app/react/edge/edge-stacks/CreateView/useCreate.tsx @@ -4,6 +4,7 @@ import { useCurrentUser } from '@/react/hooks/useUser'; import { useAnalytics } from '@/react/hooks/useAnalytics'; import { TemplateViewModel } from '@/react/portainer/templates/app-templates/view-model'; import { CustomTemplate } from '@/react/portainer/templates/custom-templates/types'; +import { notifySuccess } from '@/portainer/services/notifications'; import { BasePayload, @@ -49,6 +50,7 @@ export function useCreate({ mutation.mutate(getPayload(method, values), { onSuccess: () => { + notifySuccess('Success', 'Edge stack created'); router.stateService.go('^'); }, }); diff --git a/app/react/portainer/environments/ListView/ListView.tsx b/app/react/portainer/environments/ListView/ListView.tsx index f3801d083..633ff1556 100644 --- a/app/react/portainer/environments/ListView/ListView.tsx +++ b/app/react/portainer/environments/ListView/ListView.tsx @@ -1,5 +1,6 @@ import { useStore } from 'zustand'; +import { notifySuccess } from '@/portainer/services/notifications'; import { environmentStore } from '@/react/hooks/current-environment-store'; import { PageHeader } from '@@/PageHeader'; @@ -26,7 +27,7 @@ export function ListView() { ); - async function handleRemove(environments: Array) { + async function handleRemove(environmentsToDelete: Array) { const confirmed = await confirmDelete( 'This action will remove all configurations associated to your environment(s). Continue?' ); @@ -37,16 +38,24 @@ export function ListView() { const id = constCurrentEnvironmentStore.environmentId; // If the current endpoint was deleted, then clean endpoint store - if (environments.some((e) => e.Id === id)) { + if (environmentsToDelete.some((e) => e.Id === id)) { constCurrentEnvironmentStore.clear(); } deletionMutation.mutate( - environments.map((e) => ({ + environmentsToDelete.map((e) => ({ id: e.Id, deleteCluster: false, name: e.Name, - })) + })), + { + onSuccess() { + notifySuccess( + 'Environments successfully removed', + environmentsToDelete.map((e) => e.Name).join(', ') + ); + }, + } ); } }