Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nicholas-codecov
Copy link
Contributor

Description

This PR migrates the useSelfHostedSeatsAndLicense to the TSQ V5 query options version SelfHostedSeatsAndLicenseQueryOpts, as well as a TS migration

Ticket: codecov/engineering-team#2961

Notable Changes

  • Migrate useSelfHostedSeatsAndLicense to SelfHostedSeatsAndLicenseQueryOpts
  • Update SelfHostedLicenseExpiration
    • Refactor to TS
    • Add in tiny wrapper component so that we can short circuit rendering the actual banner and triggering the data fetching, as suspense queries cannot be controlled via an enabled property

Copy link

codecov bot commented Dec 12, 2024

Bundle Report

Changes will decrease total bundle size by 2.77kB (-0.02%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 6.0MB 1.48kB (-0.02%) ⬇️
gazebo-production-system-esm 6.05MB 1.29kB (-0.02%) ⬇️

@codecov-staging
Copy link

codecov-staging bot commented Dec 12, 2024

Bundle Report

Changes will decrease total bundle size by 2.77kB (-0.02%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 6.05MB 1.29kB (-0.02%) ⬇️
gazebo-staging-system 6.0MB 1.48kB (-0.02%) ⬇️

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (7200eea) to head (1168494).

✅ 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              
Files with missing lines Coverage Δ
...s/selfHosted/SelfHostedSeatsAndLicenseQueryOpts.ts 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.tsx 97.05% <100.00%> (-2.95%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (ø)
Services 99.36% <100.00%> (-0.01%) ⬇️
Shared 99.25% <100.00%> (-0.07%) ⬇️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7200eea...1168494. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Dec 12, 2024

Codecov Report

All 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              
Files with missing lines Coverage Δ
...s/selfHosted/SelfHostedSeatsAndLicenseQueryOpts.ts 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.tsx 97.05% <100.00%> (-2.95%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (ø)
Services 99.36% <100.00%> (-0.01%) ⬇️
Shared 99.25% <100.00%> (-0.07%) ⬇️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7200eea...1168494. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (7200eea) to head (1168494).

✅ 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              
Files with missing lines Coverage Δ
...s/selfHosted/SelfHostedSeatsAndLicenseQueryOpts.ts 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.tsx 97.05% <100.00%> (-2.95%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (ø)
Services 99.36% <100.00%> (-0.01%) ⬇️
Shared 99.25% <100.00%> (-0.07%) ⬇️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7200eea...1168494. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (7200eea) to head (1168494).

✅ 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              
Files with missing lines Coverage Δ
...s/selfHosted/SelfHostedSeatsAndLicenseQueryOpts.ts 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.tsx 97.05% <100.00%> (-2.95%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.75% <ø> (ø)
Services 99.36% <100.00%> (-0.01%) ⬇️
Shared 99.25% <100.00%> (-0.07%) ⬇️
UI 99.14% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7200eea...1168494. Read the comment docs.

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Dec 12, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
b5e0433 Thu, 12 Dec 2024 19:16:37 GMT Expired Expired
b5e0433 Thu, 12 Dec 2024 19:20:34 GMT Expired Expired
1168494 Mon, 23 Dec 2024 17:22:32 GMT Cloud Enterprise

Copy link
Contributor

@suejung-sentry suejung-sentry left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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.

@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2961-migrate-useSelfHostedSeatsAndLicense-to-tsqv5 branch from b5e0433 to 1168494 Compare December 23, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants