mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import {
|
|
addErrorMessage,
|
|
addLoadingMessage,
|
|
addSuccessMessage,
|
|
} from 'sentry/actionCreators/indicator';
|
|
import {t} from 'sentry/locale';
|
|
import type {UseMutationOptions} from 'sentry/utils/queryClient';
|
|
import {useMutation} from 'sentry/utils/queryClient';
|
|
import type RequestError from 'sentry/utils/requestError/requestError';
|
|
import useApi from 'sentry/utils/useApi';
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
|
interface DeleteDebugIdArtifactsVariables {
|
|
bundleId: string;
|
|
projectSlug: string;
|
|
}
|
|
|
|
export function useDeleteDebugIdBundle(
|
|
options: Omit<
|
|
UseMutationOptions<unknown, RequestError, DeleteDebugIdArtifactsVariables>,
|
|
'mutationFn'
|
|
> = {}
|
|
) {
|
|
const api = useApi();
|
|
const organization = useOrganization();
|
|
|
|
return useMutation<unknown, RequestError, DeleteDebugIdArtifactsVariables>({
|
|
...options,
|
|
mutationFn: ({projectSlug, bundleId}: DeleteDebugIdArtifactsVariables) => {
|
|
const debugIdBundlesEndpoint = `/projects/${organization.slug}/${projectSlug}/files/artifact-bundles/`;
|
|
return api.requestPromise(debugIdBundlesEndpoint, {
|
|
method: 'DELETE',
|
|
query: {bundleId},
|
|
});
|
|
},
|
|
onMutate: (...args) => {
|
|
addLoadingMessage(t('Deleting bundle\u2026'));
|
|
options.onMutate?.(...args);
|
|
},
|
|
onSuccess: (...args) => {
|
|
addSuccessMessage(t('Bundle deleted.'));
|
|
options.onSuccess?.(...args);
|
|
},
|
|
onError: (...args) => {
|
|
addErrorMessage(t('Unable to delete bundle. Please try again.'));
|
|
options.onError?.(...args);
|
|
},
|
|
});
|
|
}
|