mirror of
https://github.com/khairul169/garage-webui.git
synced 2026-09-15 00:43:21 +07:00
feat: add recursive remove directory option
This commit is contained in:
@@ -40,10 +40,13 @@ export const usePutObject = (
|
||||
|
||||
export const useDeleteObject = (
|
||||
bucket: string,
|
||||
options?: UseMutationOptions<any, Error, string>
|
||||
options?: UseMutationOptions<any, Error, { key: string; recursive?: boolean }>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (key) => api.delete(`/browse/${bucket}/${key}`),
|
||||
mutationFn: (data) =>
|
||||
api.delete(`/browse/${bucket}/${data.key}`, {
|
||||
params: { recursive: data.recursive },
|
||||
}),
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -34,8 +34,17 @@ const ObjectActions = ({ prefix = "", object, end }: Props) => {
|
||||
};
|
||||
|
||||
const onDelete = () => {
|
||||
if (window.confirm("Are you sure you want to delete this object?")) {
|
||||
deleteObject.mutate(prefix + object.objectKey);
|
||||
if (
|
||||
window.confirm(
|
||||
`Are you sure you want to delete this ${
|
||||
isDirectory ? "directory and its content" : "object"
|
||||
}?`
|
||||
)
|
||||
) {
|
||||
deleteObject.mutate({
|
||||
key: prefix + object.objectKey,
|
||||
recursive: isDirectory,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user