1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 14:59:41 +02:00

feat(helm): uninstall helm app from details view [r8s-285] (#648)

This commit is contained in:
Ali 2025-04-22 09:52:52 +12:00 committed by GitHub
parent 6fcf1893d3
commit bbe94f55b6
5 changed files with 133 additions and 18 deletions

View file

@ -0,0 +1,39 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { withGlobalError, withInvalidate } from '@/react-tools/react-query';
import { queryKeys as applicationsQueryKeys } from '@/react/kubernetes/applications/queries/query-keys';
import { EnvironmentId } from '@/react/portainer/environments/types';
export function useUninstallHelmAppMutation(environmentId: EnvironmentId) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({
releaseName,
namespace,
}: {
releaseName: string;
namespace?: string;
}) => uninstallHelmApplication(environmentId, releaseName, namespace),
...withInvalidate(queryClient, [
applicationsQueryKeys.applications(environmentId),
]),
...withGlobalError('Unable to uninstall helm application'),
});
}
export async function uninstallHelmApplication(
environmentId: EnvironmentId,
releaseName: string,
namespace?: string
) {
try {
await axios.delete(
`/endpoints/${environmentId}/kubernetes/helm/${releaseName}`,
{ params: { namespace } }
);
} catch (error) {
// parseAxiosError, because it's a regular portainer api error
throw parseAxiosError(error, 'Unable to remove application');
}
}