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:
Wang Qi
2026-04-22 20:42:41 +08:00
committed by GitHub
parent c08cd8e090
commit 01753b8f31
9 changed files with 66 additions and 44 deletions

View File

@@ -144,7 +144,7 @@ const SourceDetailPage = () => {
];
}, [detail, runSchedule]);
const { addLoading, handleAddOk } = useAddDataSource();
const { addLoading, handleAddOk } = useAddDataSource({isEdit:true});
const onSubmit = useCallback(() => {
formRef?.current?.submit();

View File

@@ -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'] });

View File

@@ -79,7 +79,7 @@ const DataSource = () => {
handleAddOk,
hideAddingModal,
showAddingModal,
} = useAddDataSource();
} = useAddDataSource({});
return (
<ProfileSettingWrapperCard