mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-21 15:11:08 +08:00
Refactor: API connectors (#14228)
### What problem does this PR solve? Refactor /api/v1/connectors to be more RESTful. ### Type of change - [x] Refactoring
This commit is contained in:
@@ -144,7 +144,7 @@ const SourceDetailPage = () => {
|
||||
];
|
||||
}, [detail, runSchedule]);
|
||||
|
||||
const { addLoading, handleAddOk } = useAddDataSource();
|
||||
const { addLoading, handleAddOk } = useAddDataSource({isEdit:true});
|
||||
|
||||
const onSubmit = useCallback(() => {
|
||||
formRef?.current?.submit();
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
||||
import dataSourceService, {
|
||||
dataSourceRebuild,
|
||||
dataSourceResume,
|
||||
dataSourceResume, dataSourceUpdate,
|
||||
deleteDataSource,
|
||||
featchDataSourceDetail,
|
||||
getDataSourceLogs,
|
||||
@@ -68,7 +68,7 @@ export const useListDataSource = () => {
|
||||
return { list, categorizedList: updatedDataSourceTemplates, isFetching };
|
||||
};
|
||||
|
||||
export const useAddDataSource = () => {
|
||||
export const useAddDataSource = ({isEdit=false}:{isEdit?:boolean} ) => {
|
||||
const [addSource, setAddSource] = useState<IDataSorceInfo | undefined>(
|
||||
undefined,
|
||||
);
|
||||
@@ -90,7 +90,9 @@ export const useAddDataSource = () => {
|
||||
const handleAddOk = useCallback(
|
||||
async (data: any) => {
|
||||
setAddLoading(true);
|
||||
const { data: res } = await dataSourceService.dataSourceSet(data);
|
||||
const { data: res } = isEdit
|
||||
? await dataSourceUpdate(data.id, data)
|
||||
: await dataSourceService.dataSourceSet(data);
|
||||
console.log('🚀 ~ handleAddOk ~ code:', res.code);
|
||||
if (res.code === 0) {
|
||||
queryClient.invalidateQueries({ queryKey: ['data-source'] });
|
||||
|
||||
@@ -79,7 +79,7 @@ const DataSource = () => {
|
||||
handleAddOk,
|
||||
hideAddingModal,
|
||||
showAddingModal,
|
||||
} = useAddDataSource();
|
||||
} = useAddDataSource({});
|
||||
|
||||
return (
|
||||
<ProfileSettingWrapperCard
|
||||
|
||||
Reference in New Issue
Block a user