mirror of https://github.com/portainer/portainer
fix(endpoints): show toaster on delete [EE-7170] (#11888)
parent
69f9a509c8
commit
9d7173fb5f
|
@ -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<Environment>) {
|
||||
async function handleRemove(environmentsToDelete: Array<Environment>) {
|
||||
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(', ')
|
||||
);
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue