refactor: migrate LayoutsContext to query module pattern#18069
refactor: migrate LayoutsContext to query module pattern#18069adamhaeger wants to merge 3 commits intorefactor/entrypoint-to-loaderfrom
Conversation
Extract layout data fetching from context/provider pattern into a dedicated query module at core/queries/layouts/. - Create LayoutApi static class in core/api-client/ - Create layout query module with queryOptions, query keys, and hooks - Migrate ~80 consumer files to import from new module - Reduce LayoutsContext.tsx to a thin loading gate (no context) - Processing logic (cleanLayout, dedup, likert) moved to query module Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔍 Lighthouse Report
|
Description
Migrates layout data fetching from the legacy
LayoutsContext(context + provider pattern) to the nextsrc query module pattern atcore/queries/layouts/.What changed:
LayoutApistatic class incore/api-client/layout.api.ts— replacesfetchLayouts/fetchLayoutsForInstancefromuseAppQueriescore/queries/layouts/withlayoutQueryDef(), typed query keys, and public hooks (useLayouts,useLayoutLookups,useLayoutLookupsLax,useHiddenLayoutsExpressions,useExpandedWidthLayouts)LayoutsContextLayoutsContext.tsxreduced from 190 lines to ~50 lines — now a thin loading gate (blocks rendering until layout query resolves, no context)processLayouts,removeDuplicateComponentIds,addLikertItemToLayout) moved into the query module'squeryFnmakeLayoutLookupscalls across consumersBackward compatibility:
LayoutsProviderremains inFormContextprovider tree as a loading gate (validation layer requires layout data before rendering)layoutQueryDefaccepts optional fetch functions parameter — hooks passuseAppQueries()functions preserving test mock infrastructureLayoutContextValuetype alias preserved for e2e tests and devtoolsVerification