refactor(frontend): remove redundant 'Sync All' button from MCP panel

All MCP operations already auto-sync to live configs:
- upsert_server() → sync_server_to_apps()
- toggle_app() → sync_server_to_app() or remove_server_from_app()
- delete_server() → remove_server_from_all_apps()

The manual 'Sync All' button was redundant and could confuse users
into thinking they need to manually sync after each change.

Changes:
- Remove 'Sync All' button from UnifiedMcpPanel header
- Remove useSyncAllMcpServers hook
- Remove handleSyncAll function and syncAllMutation state
- Remove RefreshCw icon import
- Remove sync-related i18n translations (en/zh)

Note: Backend sync_all_mcp_servers command remains for potential
future use (e.g., recovery tool), but is no longer exposed in UI.
This commit is contained in:
Jason
2025-11-14 15:52:01 +08:00
parent f4b8aed29a
commit fafca841cb
4 changed files with 6 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { Plus, Server, Check, RefreshCw } from "lucide-react";
import { Plus, Server, Check } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -10,7 +10,7 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { Checkbox } from "@/components/ui/checkbox";
import { useAllMcpServers, useToggleMcpApp, useSyncAllMcpServers } from "@/hooks/useMcp";
import { useAllMcpServers, useToggleMcpApp } from "@/hooks/useMcp";
import type { McpServer } from "@/types";
import type { AppId } from "@/lib/api/types";
import McpFormModal from "./McpFormModal";
@@ -48,7 +48,6 @@ const UnifiedMcpPanel: React.FC<UnifiedMcpPanelProps> = ({
const { data: serversMap, isLoading } = useAllMcpServers();
const toggleAppMutation = useToggleMcpApp();
const deleteServerMutation = useDeleteMcpServer();
const syncAllMutation = useSyncAllMcpServers();
// Convert serversMap to array for easier rendering
const serverEntries = useMemo((): Array<[string, McpServer]> => {
@@ -110,17 +109,6 @@ const UnifiedMcpPanel: React.FC<UnifiedMcpPanelProps> = ({
});
};
const handleSyncAll = async () => {
try {
await syncAllMutation.mutateAsync();
toast.success(t("mcp.unifiedPanel.syncAllSuccess"));
} catch (error) {
toast.error(t("common.error"), {
description: String(error),
});
}
};
const handleCloseForm = () => {
setIsFormOpen(false);
setEditingId(null);
@@ -133,26 +121,11 @@ const UnifiedMcpPanel: React.FC<UnifiedMcpPanelProps> = ({
<DialogHeader>
<div className="flex items-center justify-between pr-8">
<DialogTitle>{t("mcp.unifiedPanel.title")}</DialogTitle>
<div className="flex gap-2">
<Button
type="button"
variant="outline"
size="sm"
onClick={handleSyncAll}
disabled={syncAllMutation.isPending}
>
<RefreshCw
size={16}
className={syncAllMutation.isPending ? "animate-spin" : ""}
/>
{t("mcp.unifiedPanel.syncAll")}
</Button>
<Button type="button" variant="mcp" onClick={handleAdd}>
<Plus size={16} />
{t("mcp.unifiedPanel.addServer")}
</Button>
</div>
</div>
</DialogHeader>
{/* Info Section */}

View File

@@ -59,12 +59,3 @@ export function useDeleteMcpServer() {
},
});
}
/**
* 同步所有启用的 MCP 服务器到各应用的 live 配置
*/
export function useSyncAllMcpServers() {
return useMutation({
mutationFn: () => mcpApi.syncAllServers(),
});
}

View File

@@ -447,8 +447,6 @@
"editServer": "Edit Server",
"deleteServer": "Delete Server",
"deleteConfirm": "Are you sure you want to delete server \"{{id}}\"? This action cannot be undone.",
"syncAll": "Sync All",
"syncAllSuccess": "All enabled servers have been synced to application configs",
"noServers": "No servers yet",
"enabledApps": "Enabled Apps",
"apps": {

View File

@@ -447,8 +447,6 @@
"editServer": "编辑服务器",
"deleteServer": "删除服务器",
"deleteConfirm": "确定要删除服务器 \"{{id}}\" 吗?此操作无法撤销。",
"syncAll": "同步全部",
"syncAllSuccess": "已同步所有启用的服务器到各应用配置",
"noServers": "暂无服务器",
"enabledApps": "启用的应用",
"apps": {