FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add OUIA support to all sub-components · patternfly-java/patternfly-java@24146d1 · GitHub

feat: Add OUIA support to all sub-components · patternfly-java/patternfly-java@24146d1 · GitHub
Skip to content

Navigation Menu

Commit 24146d1

Browse files
committed
feat: Add OUIA support to all sub-components
Every sub-component now renders data-ouia-component-type (e.g., PF6/Component/Card/CardHeader) and data-ouia-safe="true", with an ouiaId(String) method for setting data-ouia-component-id. This brings sub-components to parity with BaseComponent's existing OUIA support.
1 parent db7058e commit 24146d1

202 files changed

Lines changed: 609 additions & 440 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Add OUIA support to all sub-components: every sub-component now renders `data-ouia-component-type` (e.g., `PF6/Component/Card/CardHeader`) and `data-ouia-safe="true"`, with an `ouiaId(String)` method for setting `data-ouia-component-id`
12+
913
## [0.7.7] - 2026-05-19
1014

1115
### Changed

‎components/src/main/java/org/patternfly/component/ComponentStore.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ static <E extends HTMLElement, B extends TypedBuilder<E, B>> void storeComponent
7676
static <E extends HTMLElement, B extends TypedBuilder<E, B>> void storeSubComponent(SubComponent<E, B> subComponent) {
7777
String uuid = uuid();
7878
subComponents.put(uuid, subComponent);
79-
subComponent.element().dataset.set(key(subComponent.componentType, subComponent.name), uuid);
79+
subComponent.element().dataset.set(key(subComponent.componentType, subComponent.subComponentId), uuid);
8080
onDetach(subComponent.element(), mr -> remove(uuid, "sub component", subComponents::remove));
8181
if (logger.isEnabled(DEBUG)) {
82-
logger.debug("Store subcomponent %s/%s as %s on %o%s", subComponent.componentType.componentName, subComponent.name,
82+
logger.debug("Store subcomponent %s/%s as %s on %o%s", subComponent.componentType.componentName, subComponent.subComponentId,
8383
uuid, subComponent.element(), count());
8484
}
8585
}

‎components/src/main/java/org/patternfly/component/SubComponent.java‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import static java.util.Objects.requireNonNull;
3535
import static org.patternfly.component.ComponentRegistry.componentRegistry;
36+
import static org.patternfly.core.Ouia.ouia;
3637

3738
public abstract class SubComponent<E extends HTMLElement, B extends TypedBuilder<E, B>> implements
3839
ElementAttributeMethods<E, B>,
@@ -48,17 +49,25 @@ public abstract class SubComponent<E extends HTMLElement, B extends TypedBuilder
4849
HTMLElementVisibilityMethods<E, B> {
4950

5051
final ComponentType componentType;
51-
final String name;
52+
final String subComponentId;
53+
final String subComponentName;
5254
private final E element;
5355

54-
protected SubComponent(ComponentType componentType, String name, E element) {
56+
protected SubComponent(ComponentType componentType, String subComponentId, String subComponentName, E element) {
5557
this.componentType = requireNonNull(componentType, "component type required");
56-
this.name = requireNonNull(name, "name required");
58+
this.subComponentId = requireNonNull(subComponentId, "sub-component ID required");
59+
this.subComponentName = requireNonNull(subComponentName, "sub-component name required");
5760
this.element = requireNonNull(element, "element required");
61+
ouia(element, componentType.componentName + "/" + subComponentName);
62+
}
63+
64+
public B ouiaId(String id) {
65+
ouia(element(), id, componentType.componentName + "/" + subComponentName);
66+
return that();
5867
}
5968

6069
protected String subComponentId() {
61-
return Id.build(componentType.id, name);
70+
return Id.build(componentType.id, subComponentId);
6271
}
6372

6473
@Override
@@ -67,7 +76,7 @@ public E element() {
6776
}
6877

6978
public B registerSubComponent() {
70-
componentRegistry().registerSubComponent(componentType, name, this);
79+
componentRegistry().registerSubComponent(componentType, subComponentId, this);
7180
return that();
7281
}
7382

‎components/src/main/java/org/patternfly/component/accordion/AccordionItem.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public static AccordionItem accordionItem(String identifier, String text) {
8181

8282
// ------------------------------------------------------ instance
8383

84-
public static final String SUB_COMPONENT_NAME = "aci";
84+
public static final String SUB_COMPONENT_ID = "aci";
85+
public static final String SUB_COMPONENT_NAME = "AccordionItem";
8586
private final String identifier;
8687
private final Map<String, Object> data;
8788
private final HTMLElement textElement;
@@ -92,7 +93,7 @@ public static AccordionItem accordionItem(String identifier, String text) {
9293
private HTMLElement contentElement;
9394

9495
AccordionItem(String identifier) {
95-
super(SUB_COMPONENT_NAME, div().css(component(accordion, item)).element());
96+
super(SUB_COMPONENT_ID, SUB_COMPONENT_NAME, div().css(component(accordion, item)).element());
9697
this.identifier = identifier;
9798
this.data = new HashMap<>();
9899
this.expanded = false;

‎components/src/main/java/org/patternfly/component/accordion/AccordionItemBody.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ public static AccordionItemBody accordionItemBody() {
3636

3737
// ------------------------------------------------------ instance
3838

39-
public static final String SUB_COMPONENT_NAME = "acicb";
39+
public static final String SUB_COMPONENT_ID = "acicb";
40+
public static final String SUB_COMPONENT_NAME = "AccordionItemBody";
4041

4142
AccordionItemBody() {
42-
super(SUB_COMPONENT_NAME, div().css(component(accordion, expandableContent, body)).element());
43+
super(SUB_COMPONENT_ID, SUB_COMPONENT_NAME, div().css(component(accordion, expandableContent, body)).element());
4344
}
4445

4546
// ------------------------------------------------------ builder

‎components/src/main/java/org/patternfly/component/accordion/AccordionSubComponent.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
abstract class AccordionSubComponent<E extends HTMLElement, B extends TypedBuilder<E, B>> extends SubComponent<E, B> {
2525

26-
AccordionSubComponent(String name, E element) {
27-
super(ComponentType.Accordion, name, element);
26+
AccordionSubComponent(String subComponentId, String subComponentName, E element) {
27+
super(ComponentType.Accordion, subComponentId, subComponentName, element);
2828
}
2929
}

‎components/src/main/java/org/patternfly/component/alert/AlertActionGroup.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ public static AlertActionGroup alertActionGroup() {
3737

3838
// ------------------------------------------------------ instance
3939

40-
public static final String SUB_COMPONENT_NAME = "aag";
40+
public static final String SUB_COMPONENT_ID = "aag";
41+
public static final String SUB_COMPONENT_NAME = "AlertActionGroup";
4142

4243
AlertActionGroup() {
43-
super(SUB_COMPONENT_NAME, div().css(component(Classes.alert, actionGroup)).element());
44+
super(SUB_COMPONENT_ID, SUB_COMPONENT_NAME, div().css(component(Classes.alert, actionGroup)).element());
4445
}
4546

4647
// ------------------------------------------------------ add

‎components/src/main/java/org/patternfly/component/alert/AlertDescription.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public static AlertDescription alertDescription(String text) {
3939

4040
// ------------------------------------------------------ instance
4141

42-
public static final String SUB_COMPONENT_NAME = "ad";
42+
public static final String SUB_COMPONENT_ID = "ad";
43+
public static final String SUB_COMPONENT_NAME = "AlertDescription";
4344

4445
AlertDescription() {
45-
super(SUB_COMPONENT_NAME, div().css(component(alert, description)).element());
46+
super(SUB_COMPONENT_ID, SUB_COMPONENT_NAME, div().css(component(alert, description)).element());
4647
}
4748

4849
// ------------------------------------------------------ builder

‎components/src/main/java/org/patternfly/component/alert/AlertSubComponent.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
abstract class AlertSubComponent<E extends HTMLElement, B extends TypedBuilder<E, B>> extends SubComponent<E, B> {
2525

26-
AlertSubComponent(String name, E element) {
27-
super(ComponentType.Alert, name, element);
26+
AlertSubComponent(String subComponentId, String subComponentName, E element) {
27+
super(ComponentType.Alert, subComponentId, subComponentName, element);
2828
}
2929
}

‎components/src/main/java/org/patternfly/component/breadcrumb/BreadcrumbItem.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ public static BreadcrumbItem breadcrumbItem(String identifier, String text, Stri
6464

6565
// ------------------------------------------------------ instance
6666

67-
public static final String SUB_COMPONENT_NAME = "bci";
67+
public static final String SUB_COMPONENT_ID = "bci";
68+
public static final String SUB_COMPONENT_NAME = "BreadcrumbItem";
6869
private final String identifier;
6970
private final Map<String, Object> data;
7071
private final HTMLElement textElement;
7172
private HTMLAnchorElement anchorElement;
7273

7374
<E extends HTMLElement> BreadcrumbItem(String identifier) {
74-
super(SUB_COMPONENT_NAME, li().css(component(breadcrumb, item))
75+
super(SUB_COMPONENT_ID, SUB_COMPONENT_NAME, li().css(component(breadcrumb, item))
7576
.data(Dataset.identifier, identifier)
7677
.element());
7778
this.identifier = identifier;

0 commit comments

Comments
 (0)

Footer

© 2026 GitHub, Inc.

Back | FazBrowse Home | New Git URL