Make env vars UI toggleable

This commit is contained in:
Justin Spahr-Summers
2024-11-07 15:28:10 +00:00
parent 76e2cf6fdc
commit afefcb3fa5

View File

@@ -43,6 +43,8 @@ import {
Send, Send,
Terminal, Terminal,
FolderTree, FolderTree,
ChevronDown,
ChevronRight,
} from "lucide-react"; } from "lucide-react";
import { ZodType } from "zod"; import { ZodType } from "zod";
@@ -94,6 +96,7 @@ const App = () => {
const [notifications, setNotifications] = useState<ServerNotification[]>([]); const [notifications, setNotifications] = useState<ServerNotification[]>([]);
const [roots, setRoots] = useState<Root[]>([]); const [roots, setRoots] = useState<Root[]>([]);
const [env, setEnv] = useState<Record<string, string>>({}); const [env, setEnv] = useState<Record<string, string>>({});
const [showEnvVars, setShowEnvVars] = useState(false);
const [pendingSampleRequests, setPendingSampleRequests] = useState< const [pendingSampleRequests, setPendingSampleRequests] = useState<
Array< Array<
@@ -384,9 +387,20 @@ const App = () => {
</div> </div>
{transportType === "stdio" && ( {transportType === "stdio" && (
<div className="mt-4"> <div className="mt-4">
<h3 className="text-md font-semibold mb-2"> <Button
variant="outline"
onClick={() => setShowEnvVars(!showEnvVars)}
className="flex items-center"
>
{showEnvVars ? (
<ChevronDown className="w-4 h-4 mr-2" />
) : (
<ChevronRight className="w-4 h-4 mr-2" />
)}
Environment Variables Environment Variables
</h3> </Button>
{showEnvVars && (
<div className="mt-2">
{Object.entries(env).map(([key, value]) => ( {Object.entries(env).map(([key, value]) => (
<div key={key} className="flex space-x-2 mb-2"> <div key={key} className="flex space-x-2 mb-2">
<Input <Input
@@ -403,7 +417,10 @@ const App = () => {
placeholder="Value" placeholder="Value"
value={value} value={value}
onChange={(e) => onChange={(e) =>
setEnv((prev) => ({ ...prev, [key]: e.target.value })) setEnv((prev) => ({
...prev,
[key]: e.target.value,
}))
} }
/> />
<Button <Button
@@ -427,6 +444,8 @@ const App = () => {
</div> </div>
)} )}
</div> </div>
)}
</div>
{mcpClient ? ( {mcpClient ? (
<Tabs defaultValue="resources" className="w-full p-4"> <Tabs defaultValue="resources" className="w-full p-4">
<TabsList className="mb-4 p-0"> <TabsList className="mb-4 p-0">