diff --git a/ui/src/ui/views/config-form.render.ts b/ui/src/ui/views/config-form.render.ts index dc6cebe3e36..d8c41b39904 100644 --- a/ui/src/ui/views/config-form.render.ts +++ b/ui/src/ui/views/config-form.render.ts @@ -435,6 +435,46 @@ export function renderConfigForm(props: ConfigFormProps) { `; } + const renderSectionCard = (params: { + id: string; + sectionKey: string; + label: string; + description: string; + node: JsonSchema; + nodeValue: unknown; + path: Array; + }) => html` +
+
+ ${getSectionIcon(params.sectionKey)} +
+

${params.label}

+ ${ + params.description + ? html`

${params.description}

` + : nothing + } +
+
+
+ ${renderNode({ + schema: params.node, + value: params.nodeValue, + path: params.path, + hints: props.uiHints, + unsupported, + disabled: props.disabled ?? false, + showLabel: false, + searchCriteria, + revealSensitive: props.revealSensitive ?? false, + isSensitivePathRevealed: props.isSensitivePathRevealed, + onToggleSensitivePath: props.onToggleSensitivePath, + onPatch: props.onPatch, + })} +
+
+ `; + return html`
${ @@ -449,38 +489,15 @@ export function renderConfigForm(props: ConfigFormProps) { sectionValue && typeof sectionValue === "object" ? (sectionValue as Record)[subsectionKey] : undefined; - const id = `config-section-${sectionKey}-${subsectionKey}`; - return html` -
-
- ${getSectionIcon(sectionKey)} -
-

${label}

- ${ - description - ? html`

${description}

` - : nothing - } -
-
-
- ${renderNode({ - schema: node, - value: scopedValue, - path: [sectionKey, subsectionKey], - hints: props.uiHints, - unsupported, - disabled: props.disabled ?? false, - showLabel: false, - searchCriteria, - revealSensitive: props.revealSensitive ?? false, - isSensitivePathRevealed: props.isSensitivePathRevealed, - onToggleSensitivePath: props.onToggleSensitivePath, - onPatch: props.onPatch, - })} -
-
- `; + return renderSectionCard({ + id: `config-section-${sectionKey}-${subsectionKey}`, + sectionKey, + label, + description, + node, + nodeValue: scopedValue, + path: [sectionKey, subsectionKey], + }); })() : filteredEntries.map(([key, node]) => { const meta = SECTION_META[key] ?? { @@ -488,37 +505,15 @@ export function renderConfigForm(props: ConfigFormProps) { description: node.description ?? "", }; - return html` -
-
- ${getSectionIcon(key)} -
-

${meta.label}

- ${ - meta.description - ? html`

${meta.description}

` - : nothing - } -
-
-
- ${renderNode({ - schema: node, - value: value[key], - path: [key], - hints: props.uiHints, - unsupported, - disabled: props.disabled ?? false, - showLabel: false, - searchCriteria, - revealSensitive: props.revealSensitive ?? false, - isSensitivePathRevealed: props.isSensitivePathRevealed, - onToggleSensitivePath: props.onToggleSensitivePath, - onPatch: props.onPatch, - })} -
-
- `; + return renderSectionCard({ + id: `config-section-${key}`, + sectionKey: key, + label: meta.label, + description: meta.description, + node, + nodeValue: value[key], + path: [key], + }); }) }