mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: Move files in file manager #1826 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -28,6 +28,23 @@ export interface IListResult {
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export const useFetchPureFileList = () => {
|
||||
const { mutateAsync, isPending: loading } = useMutation({
|
||||
mutationKey: ['fetchPureFileList'],
|
||||
gcTime: 0,
|
||||
|
||||
mutationFn: async (parentId: string) => {
|
||||
const { data } = await fileManagerService.listFile({
|
||||
parent_id: parentId,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
|
||||
return { loading, fetchList: mutateAsync };
|
||||
};
|
||||
|
||||
export const useFetchFileList = (): ResponseType<any> & IListResult => {
|
||||
const { searchString, handleInputChange } = useHandleSearchChange();
|
||||
const { pagination, setPagination } = useGetPaginationWithRouter();
|
||||
@ -225,3 +242,31 @@ export const useConnectToKnowledge = () => {
|
||||
|
||||
return { data, loading, connectFileToKnowledge: mutateAsync };
|
||||
};
|
||||
|
||||
export interface IMoveFileBody {
|
||||
src_file_ids: string[];
|
||||
dest_file_id: string; // target folder id
|
||||
}
|
||||
|
||||
export const useMoveFile = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: ['moveFile'],
|
||||
mutationFn: async (params: IMoveFileBody) => {
|
||||
const { data } = await fileManagerService.moveFile(params);
|
||||
if (data.retcode === 0) {
|
||||
message.success(t('message.operated'));
|
||||
queryClient.invalidateQueries({ queryKey: ['fetchFileList'] });
|
||||
}
|
||||
return data.retcode;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, moveFile: mutateAsync };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user