mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: List MCP servers #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
49
web/src/pages/profile-setting/mcp/use-edit-mcp.ts
Normal file
49
web/src/pages/profile-setting/mcp/use-edit-mcp.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useCreateMcpServer,
|
||||
useGetMcpServer,
|
||||
useUpdateMcpServer,
|
||||
} from '@/hooks/use-mcp-request';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useEditMcp = () => {
|
||||
const {
|
||||
visible: editVisible,
|
||||
hideModal: hideEditModal,
|
||||
showModal: showEditModal,
|
||||
} = useSetModalState();
|
||||
const { createMcpServer, loading } = useCreateMcpServer();
|
||||
const { data, setId, id } = useGetMcpServer();
|
||||
const { updateMcpServer } = useUpdateMcpServer();
|
||||
|
||||
const handleShowModal = useCallback(
|
||||
(id?: string) => () => {
|
||||
if (id) {
|
||||
setId(id);
|
||||
}
|
||||
showEditModal();
|
||||
},
|
||||
[setId, showEditModal],
|
||||
);
|
||||
|
||||
const handleOk = useCallback(
|
||||
async (values: any) => {
|
||||
if (id) {
|
||||
updateMcpServer(values);
|
||||
} else {
|
||||
createMcpServer(values);
|
||||
}
|
||||
},
|
||||
[createMcpServer, id, updateMcpServer],
|
||||
);
|
||||
|
||||
return {
|
||||
editVisible,
|
||||
hideEditModal,
|
||||
showEditModal: handleShowModal,
|
||||
loading,
|
||||
createMcpServer,
|
||||
detail: data,
|
||||
handleOk,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user