mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-10-08 19:26:31 +08:00
feat: support enabled
This commit is contained in:
parent
cd6e118868
commit
a2a7867b0e
@ -7,6 +7,7 @@ import { useCallback, useState } from "react";
|
|||||||
|
|
||||||
import { Tooltip } from "~/app/_components/tooltip";
|
import { Tooltip } from "~/app/_components/tooltip";
|
||||||
import { Button } from "~/components/ui/button";
|
import { Button } from "~/components/ui/button";
|
||||||
|
import { Switch } from "~/components/ui/switch";
|
||||||
import type { MCPServerMetadata } from "~/core/mcp";
|
import type { MCPServerMetadata } from "~/core/mcp";
|
||||||
|
|
||||||
import { AddMCPServerDialog } from "../dialogs/add-mcp-server-dialog";
|
import { AddMCPServerDialog } from "../dialogs/add-mcp-server-dialog";
|
||||||
@ -46,6 +47,16 @@ export const MCPTab: Tab = ({ settings, onChange }) => {
|
|||||||
},
|
},
|
||||||
[onChange, settings],
|
[onChange, settings],
|
||||||
);
|
);
|
||||||
|
const handleToggleServer = useCallback(
|
||||||
|
(name: string, enabled: boolean) => {
|
||||||
|
const merged = settings.mcp.servers.map((server) =>
|
||||||
|
server.name === name ? { ...server, enabled } : server,
|
||||||
|
);
|
||||||
|
setServers(merged);
|
||||||
|
onChange({ ...settings, mcp: { ...settings.mcp, servers: merged } });
|
||||||
|
},
|
||||||
|
[onChange, settings],
|
||||||
|
);
|
||||||
const animationProps = {
|
const animationProps = {
|
||||||
initial: { backgroundColor: "gray" },
|
initial: { backgroundColor: "gray" },
|
||||||
animate: { backgroundColor: "transparent" },
|
animate: { backgroundColor: "transparent" },
|
||||||
@ -86,7 +97,20 @@ export const MCPTab: Tab = ({ settings, onChange }) => {
|
|||||||
key={server.name}
|
key={server.name}
|
||||||
{...(isNew && newlyAdded && animationProps)}
|
{...(isNew && newlyAdded && animationProps)}
|
||||||
>
|
>
|
||||||
<div className="absolute top-1 right-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
<div className="absolute top-3 right-2">
|
||||||
|
<Tooltip title="Enable/disable server">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Switch
|
||||||
|
id="airplane-mode"
|
||||||
|
checked={server.enabled}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
handleToggleServer(server.name, checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div className="absolute top-1 right-12 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
||||||
<Tooltip title="Delete server">
|
<Tooltip title="Delete server">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user