-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Migrate useSelfHostedSeatsAndLicense to TS Query V5 #3577
base: main
Are you sure you want to change the base?
chore: Migrate useSelfHostedSeatsAndLicense to TS Query V5 #3577
Conversation
Bundle ReportChanges will decrease total bundle size by 2.77kB (-0.02%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
Bundle ReportChanges will decrease total bundle size by 2.77kB (-0.02%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #3577 +/- ##
==========================================
- Coverage 99.00% 98.99% -0.01%
==========================================
Files 810 810
Lines 14563 14559 -4
Branches 4151 4144 -7
==========================================
- Hits 14418 14413 -5
- Misses 138 139 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. @@ Coverage Diff @@
## main #3577 +/- ##
==========================================
- Coverage 99.00% 98.99% -0.01%
==========================================
Files 810 810
Lines 14563 14559 -4
Branches 4158 4144 -14
==========================================
- Hits 14418 14413 -5
- Misses 138 139 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. @@ Coverage Diff @@
## main #3577 +/- ##
==========================================
- Coverage 99.00% 98.99% -0.01%
==========================================
Files 810 810
Lines 14563 14559 -4
Branches 4158 4144 -14
==========================================
- Hits 14418 14413 -5
- Misses 138 139 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. @@ Coverage Diff @@
## main #3577 +/- ##
==========================================
- Coverage 99.00% 98.99% -0.01%
==========================================
Files 810 810
Lines 14563 14559 -4
Branches 4151 4144 -7
==========================================
- Hits 14418 14413 -5
- Misses 138 139 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved! Had a Q about suspense
return <SelfHostedLicenseExpiration /> | ||
} | ||
|
||
export default SelfHostedLicenseExpirationWrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am probably missing it - where is this wrapper component meant to be used?
Was just wondering in case perhaps there's a way to create a generic "conditionalSuspense" or similar wrapper to handle if we have this scenario in other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i played around a bit with this idea and came up with something like:
// ConditionalRenderer.tsx
export const ConditionalRenderer = ({ condition, children }) => {
if (condition) {
return <>{children}</>
}
return null
}
// SelfHostedLicenseExpiration.tsx
function SelfHostedLicenseExpirationWrapper() {
const isSelfHosted = !!config.IS_SELF_HOSTED
const isDedicatedNamespace = !!config.IS_DEDICATED_NAMESPACE
return (
<ConditionalRenderer condition={isSelfHosted && isDedicatedNamespace}>
<SelfHostedLicenseExpiration />
</ConditionalRenderer>
)
}
export default SelfHostedLicenseExpirationWrapper
Because of the way TanStack suspense queries work, we're still required to creating this wrapping component to conditionally render the hook call, so the resulting abstraction becomes fairly simple. Because of this I'd rather avoid trying to abstract it, and just handle the conditions directly in the same file.
The main motivating factor behind keeping the conditional rendering in the same file, is that everything is defined up front right in front of the engineer, and if there are more complex condition cases we're not stuck trying to create a "one size fits all" conditional rendering component that is a pain to maintain and makes the app overall more fragile.
b5e0433
to
1168494
Compare
Description
This PR migrates the
useSelfHostedSeatsAndLicense
to the TSQ V5 query options versionSelfHostedSeatsAndLicenseQueryOpts
, as well as a TS migrationTicket: codecov/engineering-team#2961
Notable Changes
useSelfHostedSeatsAndLicense
toSelfHostedSeatsAndLicenseQueryOpts
SelfHostedLicenseExpiration
enabled
property