Skip to content

Commit

Permalink
fix(endpoints): show toaster on delete [EE-7170] (#11888)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiptus committed Jun 13, 2024
1 parent 69f9a50 commit 9d7173f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/react/portainer/environments/ListView/ListView.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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?'
);
Expand All @@ -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(', ')
);
},
}
);
}
}

0 comments on commit 9d7173f

Please sign in to comment.