Skip to content

Commit 5724612

Browse files
committed
feat(ui): add collapsible sections to configuration layout
1 parent 6a544e7 commit 5724612

2 files changed

Lines changed: 52 additions & 9 deletions

File tree

patterns/unified/template.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Resources:
221221
ocr:
222222
order: 3
223223
type: object
224+
collapsible: true
225+
defaultExpanded: false
224226
sectionLabel: OCR Configuration
225227
description: "Not used when BDA is enabled - BDA handles OCR internally"
226228
dependsOn: { field: "use_bda", value: false }
@@ -581,7 +583,9 @@ Resources:
581583
classification:
582584
order: 4
583585
type: object
584-
sectionLabel: Classification Inference
586+
collapsible: true
587+
defaultExpanded: false
588+
sectionLabel: Classification Configuration
585589
description: "Not used when BDA is enabled - BDA handles classification internally"
586590
dependsOn: { field: "use_bda", value: false }
587591
required:
@@ -730,7 +734,9 @@ Resources:
730734
order: 5
731735
type: object
732736
format: section
733-
sectionLabel: Extraction Inference
737+
collapsible: true
738+
defaultExpanded: false
739+
sectionLabel: Extraction Configuration
734740
description: "Not used when BDA is enabled - BDA handles extraction internally"
735741
dependsOn: { field: "use_bda", value: false }
736742
required:
@@ -880,6 +886,8 @@ Resources:
880886
assessment:
881887
order: 6
882888
type: object
889+
collapsible: true
890+
defaultExpanded: false
883891
sectionLabel: Assessment & HITL Configuration
884892
properties:
885893
hitl_enabled:
@@ -1048,7 +1056,9 @@ Resources:
10481056
summarization:
10491057
order: 7
10501058
type: object
1051-
sectionLabel: Summarization Inference
1059+
collapsible: true
1060+
defaultExpanded: false
1061+
sectionLabel: Summarization Configuration
10521062
properties:
10531063
enabled:
10541064
type: boolean
@@ -1133,9 +1143,11 @@ Resources:
11331143
description: Task prompt - supports parameters {DOCUMENT_TEXT} and {EXTRACTION_RESULTS}. Optionally use <<CACHEPOINT>> to separate static and dynamic elements of prompt for Bedrock prompt caching.
11341144
order: 8
11351145
evaluation:
1136-
order: 8
1146+
order: 9
11371147
type: object
1138-
sectionLabel: Evaluation Inference
1148+
collapsible: true
1149+
defaultExpanded: false
1150+
sectionLabel: Evaluation Configuration
11391151
properties:
11401152
enabled:
11411153
type: boolean
@@ -1218,8 +1230,10 @@ Resources:
12181230
description: Task prompt for LLM evaluation - supports placeholders {DOCUMENT_CLASS}, {ATTRIBUTE_NAME}, {ATTRIBUTE_DESCRIPTION}, {EXPECTED_VALUE} and {ACTUAL_VALUE}
12191231
order: 7
12201232
discovery:
1221-
order: 9
1233+
order: 10
12221234
type: object
1235+
collapsible: true
1236+
defaultExpanded: false
12231237
sectionLabel: Discovery Configuration
12241238
description: Configuration for document class discovery functionality
12251239
properties:
@@ -1562,8 +1576,10 @@ Resources:
15621576
minimum: 1
15631577
order: 9
15641578
agents:
1565-
order: 10
1579+
order: 11
15661580
type: object
1581+
collapsible: true
1582+
defaultExpanded: false
15671583
sectionLabel: Agent Configuration
15681584
description: Configuration for AI agents used in the system
15691585
properties:
@@ -1647,9 +1663,11 @@ Resources:
16471663
default: 24
16481664
order: 2
16491665
rule_validation:
1650-
order: 11
1666+
order: 8
16511667
type: object
1652-
sectionLabel: Rule Validation Inference
1668+
collapsible: true
1669+
defaultExpanded: false
1670+
sectionLabel: Rule Validation Configuration
16531671
properties:
16541672
enabled:
16551673
type: boolean

src/ui/src/components/configuration-layout/ConfigBuilder.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Button,
1616
Header,
1717
Container,
18+
ExpandableSection,
1819
Modal,
1920
Tabs,
2021
} from '@cloudscape-design/components';
@@ -454,6 +455,9 @@ const ConfigBuilder = ({
454455
// Track expanded state for all list items across the form - default to collapsed
455456
const [expandedItems, setExpandedItems] = useState<Record<string, boolean>>({});
456457

458+
// Track expanded state for collapsible top-level sections
459+
const [expandedSections, setExpandedSections] = useState<Record<string, boolean>>({});
460+
457461
// State for add item modals
458462
const [activeAddModal, setActiveAddModal] = useState<string | null>(null); // Path of the list currently showing add modal
459463
const [newItemName, setNewItemName] = useState('');
@@ -1620,6 +1624,27 @@ const ConfigBuilder = ({
16201624
const sectionTitle = property.sectionLabel as string;
16211625
console.log(`Creating section container for ${key} with title: ${sectionTitle}`); // nosemgrep: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring - Debug logging with controlled internal data
16221626

1627+
// Support collapsible top-level sections via schema property `collapsible: true`
1628+
// defaultExpanded controls whether section starts expanded (defaults to true for backward compat)
1629+
if (property.collapsible === true || property.collapsible === 'true') {
1630+
const defaultExpanded = property.defaultExpanded === true || property.defaultExpanded === 'true'; // default to collapsed
1631+
const isExpanded = expandedSections[key] !== undefined ? expandedSections[key] : defaultExpanded;
1632+
1633+
return (
1634+
<ExpandableSection
1635+
key={key}
1636+
variant="container"
1637+
headerText={sectionTitle}
1638+
expanded={isExpanded}
1639+
onChange={({ detail }) => {
1640+
setExpandedSections((prev) => ({ ...prev, [key]: detail.expanded }));
1641+
}}
1642+
>
1643+
<ExtBox padding="s">{renderField(key, property)}</ExtBox>
1644+
</ExpandableSection>
1645+
);
1646+
}
1647+
16231648
return (
16241649
<Container key={key} header={<Header variant="h3">{sectionTitle}</Header>}>
16251650
<ExtBox padding="s">{renderField(key, property)}</ExtBox>

0 commit comments

Comments
 (0)