fix(endpoints): show toaster on delete [EE-7170] (#11889)

pull/11944/head
Chaim Lev-Ari 2024-06-14 00:32:17 +03:00 committed by GitHub
parent 27865981df
commit 51f9977885
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import { useCurrentUser } from '@/react/hooks/useUser';
import { useAnalytics } from '@/react/hooks/useAnalytics'; import { useAnalytics } from '@/react/hooks/useAnalytics';
import { TemplateViewModel } from '@/react/portainer/templates/app-templates/view-model'; import { TemplateViewModel } from '@/react/portainer/templates/app-templates/view-model';
import { CustomTemplate } from '@/react/portainer/templates/custom-templates/types'; import { CustomTemplate } from '@/react/portainer/templates/custom-templates/types';
import { notifySuccess } from '@/portainer/services/notifications';
import { import {
BasePayload, BasePayload,
@ -49,6 +50,7 @@ export function useCreate({
mutation.mutate(getPayload(method, values), { mutation.mutate(getPayload(method, values), {
onSuccess: () => { onSuccess: () => {
notifySuccess('Success', 'Edge stack created');
router.stateService.go('^'); router.stateService.go('^');
}, },
}); });

View File

@ -1,5 +1,6 @@
import { useStore } from 'zustand'; import { useStore } from 'zustand';
import { notifySuccess } from '@/portainer/services/notifications';
import { environmentStore } from '@/react/hooks/current-environment-store'; import { environmentStore } from '@/react/hooks/current-environment-store';
import { PageHeader } from '@@/PageHeader'; 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( const confirmed = await confirmDelete(
'This action will remove all configurations associated to your environment(s). Continue?' 'This action will remove all configurations associated to your environment(s). Continue?'
); );
@ -37,16 +38,24 @@ export function ListView() {
const id = constCurrentEnvironmentStore.environmentId; const id = constCurrentEnvironmentStore.environmentId;
// If the current endpoint was deleted, then clean endpoint store // 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(); constCurrentEnvironmentStore.clear();
} }
deletionMutation.mutate( deletionMutation.mutate(
environments.map((e) => ({ environmentsToDelete.map((e) => ({
id: e.Id, id: e.Id,
deleteCluster: false, deleteCluster: false,
name: e.Name, name: e.Name,
})) })),
{
onSuccess() {
notifySuccess(
'Environments successfully removed',
environmentsToDelete.map((e) => e.Name).join(', ')
);
},
}
); );
} }
} }