mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-03 01:01:56 +08:00
Fix: pass mcp to useExportMcp for correct JSON export filename (#16564)
This commit is contained in:
@@ -16,7 +16,7 @@ export function McpOperation({
|
||||
}: { mcp: IMcpServer } & Pick<UseEditMcpReturnType, 'showEditModal'>) {
|
||||
const { t } = useTranslation();
|
||||
const { deleteMcpServer } = useDeleteMcpServer();
|
||||
const { handleExportMcpJson } = useExportMcp();
|
||||
const { handleExportMcpJson } = useExportMcp(mcp);
|
||||
|
||||
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
|
||||
deleteMcpServer([mcp.id]);
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { useExportMcpServer } from '@/hooks/use-mcp-request';
|
||||
import { IMcpServer } from '@/interfaces/database/mcp';
|
||||
import { downloadJsonFile } from '@/utils/file-util';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export function useExportMcp() {
|
||||
export function useExportMcp(mcp: IMcpServer) {
|
||||
const { exportMcpServer } = useExportMcpServer();
|
||||
|
||||
const handleExportMcpJson = useCallback(
|
||||
(ids: string[]) => async () => {
|
||||
const data = await exportMcpServer(ids);
|
||||
if (data.code === 0) {
|
||||
downloadJsonFile(data.data, `mcp.json`);
|
||||
if (data.code === 0 && mcp) {
|
||||
downloadJsonFile(data.data, `${mcp.name || 'mcp'}.json`);
|
||||
}
|
||||
},
|
||||
[exportMcpServer],
|
||||
[exportMcpServer, mcp],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user