Add PlatformContext to replace build-time hook switching#4508
Draft
kingsleyzissou wants to merge 4 commits into
Draft
Add PlatformContext to replace build-time hook switching#4508kingsleyzissou wants to merge 4 commits into
kingsleyzissou wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #4508 +/- ##
==========================================
+ Coverage 75.36% 76.07% +0.71%
==========================================
Files 230 226 -4
Lines 7453 7203 -250
Branches 2770 2661 -109
==========================================
- Hits 5617 5480 -137
+ Misses 1578 1482 -96
+ Partials 258 241 -17
... and 13 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Provide the React context plumbing that entry points use to inject the correct platform hooks at runtime instead of relying on build-time environment variable switching.
d0eb769 to
11b08cd
Compare
Define the PlatformHooks type contract with queries, mutations, env, and api sections, then wire up hostedPlatform and onPremPlatform as static objects satisfying the contract. Uses per-field type casts where on-prem base query types diverge from hosted.
11b08cd to
6791896
Compare
AppEntry and AppCockpit now inject their respective platform objects into the React tree so all descendants can access the correct hooks via usePlatform() instead of build-time switching.
6791896 to
5f055b0
Compare
Move 35 component and hook files from importing platform-switched hooks directly from barrel files to destructuring them from usePlatform(), preparing for barrel file cleanup.
5f055b0 to
5dfc2a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce a
PlatformContext/usePlatform()abstraction so components access RTK Query hooks, feature flags, and API references through aruntime context rather than build-time barrel file switching. This is the foundation for eliminating the
IS_ON_PREMISEenvironment variable andternary-based import logic.
Changes
PlatformContext,usePlatform()hook, andPlatformProviderwith a fail-fast null guard that throws if the provider is missingPlatformHookstype contract withqueries,mutations,env, andapinamespaces, and implementhostedPlatformandonPremPlatformstatic objects satisfying the contractAppEntry(hosted) andAppCockpit(on-prem) withPlatformProviderat the application boundaryusePlatform().queries/.mutations/.apidestructuringrenderWithRedux,renderLandingPage, wizard helpers) withPlatformProviderwrapping, selecting the correctplatform from
preloadedState.env.isOnPremise