feat: Publish breadcrumbs through widget API - #5005
georgylobko merged 9 commits into
Conversation
b239758 to
be8c825
Compare
georgylobko
left a comment
There was a problem hiding this comment.
Overall, the PR involves solving a few separate problems:
Accessing the currently rendered breadcrumb group
- Establish communication between
breadcrumb-group/implementationanduse-app-layoutso thatuse-app-layoutcan access the breadcrumb props. - We already have access to
discoveredProps. - We know that the component’s own breadcrumb props should take precedence.
Once we determine which breadcrumb instance is being rendered external or internal, we will have access to its props.
External communication
We need to declare an event in plugins/widget, subscribe to it in useWidgetMessages, listen for it, and trigger it with the reconciled props.
Deciding whether to render breadcrumbs in the AppLayout toolbar
After completing the previous steps, we will know whether there is an external consumer. At that point, we can decide whether to hide the breadcrumbs in the toolbar.
Let’s keep these steps separate and avoid mixing them together
81d8477 to
4c41152
Compare
4c41152 to
8470032
Compare
dc9dcef to
9646836
Compare
georgylobko
left a comment
There was a problem hiding this comment.
Approving the PR with few optional comments, you can address them in a follow-up
2f8ef41 to
f25e8af
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5005 +/- ##
==========================================
- Coverage 97.68% 93.80% -3.89%
==========================================
Files 965 965
Lines 31484 27306 -4178
Branches 11641 9824 -1817
==========================================
- Hits 30755 25614 -5141
+ Misses 683 611 -72
- Partials 46 1081 +1035 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3465efd to
f25e8af
Compare
Description
Adds a widget API for rendering App Layout breadcrumbs in Global Navigation or another external container, without requiring console teams to adopt App Layout bundle changes before the consumer can register.
registerBreadcrumbsConsumerhandles external ownership only. App Layout stores the registered consumer callback in a ref and uses a boolean as the single source of truth for whether breadcrumbs are externally owned. Registration sets ownership, and the returnedunregisterclosure clears that registration and restores toolbar rendering. Only one external consumer can be registered at a time.Own-breadcrumb extraction is kept separate from external consumer registration. The internal
extractOwnBreadcrumbscallback captures the completeBreadcrumbGroupPropsfrom the widgetized BreadcrumbGroup rendered in the App Layout slot, including through console wrapper components. App Layout then reconciles own and discovered breadcrumbs in one place using the existing source priority.A layout effect publishes the resolved breadcrumb props, or
null, to the active external consumer whenever they change. Publishing is visibility-aware: a mounted App Layout that becomes hidden publishesnull, preventing it from leaving stale breadcrumbs or overriding a visible App Layout.While breadcrumbs are externally owned, App Layout keeps its BreadcrumbGroup and funnel analytics markers in the DOM but hides the toolbar breadcrumb section with
display: none. Unregistering the consumer makes the toolbar breadcrumbs visible again.There is no startup global flag or pre-registration reservation. Ownership begins when the external consumer registers. The demos exercise the late-mount order where App Layout renders first and the Global Navigation consumer registers afterward.
Related links, issue #, if available: #4984
How has this been tested?
app-layout/global-nav-breadcrumbsapp-layout/global-nav-breadcrumbs-multi-layoutapp-layout/global-nav-breadcrumbs-multi-instanceapp-layout/global-nav-breadcrumbs-hidden-instances-iframenpm run quick-buildpassed.npm run buildpassed.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.