mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
task(endpoints): change the definition of /endpoints/remove EE-7126 (#11872)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
11404aaecb
commit
3b95c333fc
3 changed files with 83 additions and 79 deletions
|
@ -18,30 +18,32 @@ export function useDeleteEnvironmentsMutation() {
|
|||
deleteCluster?: boolean;
|
||||
}[]
|
||||
) => {
|
||||
const resps = await deleteEnvironments(environments);
|
||||
const successfulDeletions = resps.filter((r) => r.err === null);
|
||||
const failedDeletions = resps.filter((r) => r.err !== null);
|
||||
return { successfulDeletions, failedDeletions };
|
||||
const resp = await deleteEnvironments(environments);
|
||||
|
||||
if (resp === null) {
|
||||
return { deleted: environments, errors: [] };
|
||||
}
|
||||
|
||||
return {
|
||||
deleted: environments.filter((e) =>
|
||||
(resp.deleted || []).includes(e.id)
|
||||
),
|
||||
errors: environments.filter((e) => (resp.errors || []).includes(e.id)),
|
||||
};
|
||||
},
|
||||
{
|
||||
...withError('Unable to delete environment(s)'),
|
||||
onSuccess: ({ successfulDeletions, failedDeletions }) => {
|
||||
onSuccess: ({ deleted, errors }) => {
|
||||
queryClient.invalidateQueries(['environments']);
|
||||
// show an error message for each env that failed to delete
|
||||
failedDeletions.forEach((deletion) => {
|
||||
notifyError(
|
||||
`Failed to remove environment`,
|
||||
new Error(deletion.err ? deletion.err.Message : '') as Error
|
||||
);
|
||||
errors.forEach((e) => {
|
||||
notifyError(`Failed to remove environment ${e.name}`, undefined);
|
||||
});
|
||||
// show one summary message for all successful deletes
|
||||
if (successfulDeletions.length) {
|
||||
if (deleted.length) {
|
||||
notifySuccess(
|
||||
`${pluralize(
|
||||
successfulDeletions.length,
|
||||
'Environment'
|
||||
)} successfully removed`,
|
||||
successfulDeletions.map((deletion) => deletion.name).join(', ')
|
||||
`${pluralize(deleted.length, 'Environment')} successfully removed`,
|
||||
deleted.map((d) => d.name).join(', ')
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -53,10 +55,11 @@ async function deleteEnvironments(
|
|||
environments: { id: EnvironmentId; deleteCluster?: boolean }[]
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.post<
|
||||
{ name: string; err: { Message: string } | null }[]
|
||||
>(buildUrl(undefined, 'remove'), {
|
||||
environments,
|
||||
const { data } = await axios.delete<{
|
||||
deleted: EnvironmentId[];
|
||||
errors: EnvironmentId[];
|
||||
} | null>(buildUrl(), {
|
||||
data: { endpoints: environments },
|
||||
});
|
||||
return data;
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue