feat(settings): implement Environment tab with edit + drift detection
Add drift-badge, env-var-editor, env-var-row components and replace the environment-tab stub; install shadcn Switch which was missing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
76
web-ui/src/app/settings/_components/env-var-editor.tsx
Normal file
76
web-ui/src/app/settings/_components/env-var-editor.tsx
Normal file
@@ -0,0 +1,76 @@
|
||||
"use client";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import type { McpEnvVar } from "@/lib/api/settings";
|
||||
|
||||
type Props = {
|
||||
spec: McpEnvVar;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export function EnvVarEditor({ spec, value, onChange, disabled }: Props) {
|
||||
if (spec.type === "bool") {
|
||||
const checked = value === "true";
|
||||
return (
|
||||
<Switch
|
||||
checked={checked}
|
||||
onCheckedChange={(c) => onChange(c ? "true" : "false")}
|
||||
disabled={disabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (spec.enum_values && spec.enum_values.length > 0) {
|
||||
return (
|
||||
<Select value={value} onValueChange={onChange} disabled={disabled}>
|
||||
<SelectTrigger className="w-[220px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{spec.enum_values.map((v) => (
|
||||
<SelectItem key={v} value={v}>
|
||||
{v}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
if (spec.type === "int" || spec.type === "float") {
|
||||
return (
|
||||
<Input
|
||||
type="number"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
min={spec.min ?? undefined}
|
||||
max={spec.max ?? undefined}
|
||||
step={spec.type === "float" ? "0.01" : "1"}
|
||||
disabled={disabled}
|
||||
className="w-[160px] text-start"
|
||||
dir="ltr"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Input
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
disabled={disabled}
|
||||
className="w-[260px] text-start"
|
||||
dir="ltr"
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user