refactor(web): load channel configs without exposing secret values (#2277)

* refactor(web): load channel configs without exposing secret values

- add a dedicated channel config API that returns sanitized config plus
  configured secret metadata
- update channel config pages and forms to use secret presence for
  placeholders, validation, reset, and save behavior
- refresh the channel settings layout and clean up related i18n copy
- add backend tests for the new channel config endpoint

* fix(config): restore missing strings import
This commit is contained in:
wenjie authored and GitHub committed 2026-04-02 19:09:33 +08:00
1 parent e075be6b10
commit dad5dcc30f
16 files changed
+1232 -809

No files matched your search

+32 -15
View File
@@ -34,23 +34,28 @@ export function Field({
}: FieldProps) {
if (layout === "setting-row") {
return (
<div className="flex flex-col gap-4 py-4 md:grid md:grid-cols-[minmax(0,1fr)_minmax(240px,320px)] md:items-center md:gap-6">
<div className="max-w-full space-y-1 md:max-w-[clamp(18rem,42vw,28rem)]">
<FieldLabel>
<div className="flex flex-col gap-4 py-4 md:grid md:grid-cols-[280px_minmax(0,1fr)] md:items-center md:gap-8">
<div className="w-full min-w-0">
<FieldLabel className="leading-relaxed break-words whitespace-normal">
{label}
{required && <span className="text-destructive ml-1">*</span>}
</FieldLabel>
{hint && (
<FieldDescription className="text-xs leading-normal break-words">
<FieldDescription className="mt-1 text-xs leading-relaxed break-words whitespace-normal">
{hint}
</FieldDescription>
)}
</div>
<div className={cn("w-full md:justify-self-center", controlClassName)}>
<div
className={cn(
"w-full md:max-w-[28rem] md:justify-self-end",
controlClassName,
)}
>
{children}
</div>
{error && (
<FieldDescription className="text-destructive text-xs leading-normal md:col-start-2">
<FieldDescription className="text-destructive text-xs leading-normal md:col-start-2 md:justify-self-end">
{error}
</FieldDescription>
)}
@@ -125,6 +130,7 @@ interface SwitchCardFieldProps {
disabled?: boolean
children?: ReactNode
layout?: FieldLayout
transparent?: boolean
}
export function SwitchCardField({
@@ -137,19 +143,22 @@ export function SwitchCardField({
disabled,
children,
layout = "default",
transparent,
}: SwitchCardFieldProps) {
if (layout === "setting-row") {
return (
<div className="flex flex-col gap-4 py-4 md:grid md:grid-cols-[minmax(0,1fr)_auto] md:items-center md:gap-6">
<div className="max-w-full min-w-0 md:max-w-[clamp(18rem,42vw,28rem)]">
<p className="text-sm font-medium">{label}</p>
<div className="flex flex-col gap-4 py-4 md:grid md:grid-cols-[280px_minmax(0,1fr)] md:items-center md:gap-8">
<div className="w-full min-w-0">
<p className="text-sm leading-relaxed font-medium break-words whitespace-normal">
{label}
</p>
{hint && (
<p className="text-muted-foreground mt-0.5 text-xs leading-normal break-words">
<p className="text-muted-foreground mt-1 text-xs leading-relaxed break-words whitespace-normal">
{hint}
</p>
)}
</div>
<div className="flex items-center md:justify-self-center">
<div className="flex items-center md:justify-self-end">
<Switch
checked={checked}
onCheckedChange={onCheckedChange}
@@ -157,9 +166,13 @@ export function SwitchCardField({
aria-label={ariaLabel ?? label}
/>
</div>
{children && <div className="md:col-start-2">{children}</div>}
{children && (
<div className="mt-1 flex w-full justify-end md:col-start-2">
<div className="w-full md:max-w-[28rem]">{children}</div>
</div>
)}
{error && (
<p className="text-destructive text-xs leading-normal md:col-start-2">
<p className="text-destructive text-xs leading-normal md:col-start-2 md:justify-self-end">
{error}
</p>
)}
@@ -168,7 +181,11 @@ export function SwitchCardField({
}
return (
<div className="border-border/60 bg-background rounded-lg border px-4 py-3">
<div
className={cn(
transparent ? "py-1" : "border-border/60 rounded-lg border px-4 py-3",
)}
>
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<p className="text-sm font-medium">{label}</p>
@@ -185,7 +202,7 @@ export function SwitchCardField({
aria-label={ariaLabel ?? label}
/>
</div>
{children && <div className="mt-3">{children}</div>}
{children && <div className="mt-4">{children}</div>}
{error && (
<p className="text-destructive mt-2 text-xs leading-normal">{error}</p>
)}