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

ref: Migrate isFreePlan to GQL Field and remove Helper #3584

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

ajay-sentry
Copy link
Contributor

Description

This PR aims to remove the isFreePlan helper function in Gazebo in favor of the new GraphQL field for the same.

Similar PR to #3576.

One piece of milestone 2: codecov/engineering-team#2989

Closes codecov/engineering-team#2997

Clearly I lied when I said the isEnterprisePlan PR was going to be the largest, each one looks to be similarly difficult though now with 2 under our belts I think we know what each of these will entail for the rest.

Notes

  • A couple bug fixes included that I found while doing this migration, I'll add comments for them on the review.
  • Most of the PR is just swapping over to the new GQL field and updating tests to reflect that new field
  • In the cases where useAccountDetails is no longer needed, we did a "hot swap" of usePlanData where applicable. I'll note those areas on the PR as well.

Screenshots

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

if (
accountDetails?.activatedUserCount >= accountDetails?.plan?.quantity &&
!planData?.plan?.hasSeatsLeft &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using hasSeatsLeft in favor of accountDetails business logic here -- cleaning up the code a bit imo :)

@@ -63,7 +62,7 @@ function MembersList() {
})

const { activate } = useActivateUser({ owner, provider })
const { data: accountDetails } = useAccountDetails({ owner, provider })
const { data: planData } = usePlanData({ owner, provider })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hot swap of useAccountDetails -> usePlanData

@@ -61,14 +60,14 @@ function ActivationStatus({
handleActivate,
}: ActivationStatusProps) {
const { provider, owner } = useParams<{ provider: string; owner: string }>()
const { data: accountDetails } = useAccountDetails({ owner, provider })
const { data: planData } = usePlanData({ owner, provider })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hot swap of useAccountDetails -> usePlanData


render(<FreePlanCard plan={freePlan} />, {
wrapper,
})

const link = await screen.findByRole('link', { name: /Manage plan/ })
const link = await screen.findByRole('link', { name: /Upgrade/ })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a bug fix test update

Copy link

codecov bot commented Dec 15, 2024

Bundle Report

Changes will increase total bundle size by 953 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 6.0MB 301 bytes (0.01%) ⬆️
gazebo-production-system-esm 6.05MB 652 bytes (0.01%) ⬆️

@codecov-staging
Copy link

codecov-staging bot commented Dec 15, 2024

Bundle Report

Changes will increase total bundle size by 953 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 6.05MB 652 bytes (0.01%) ⬆️
gazebo-staging-system 6.0MB 301 bytes (0.01%) ⬆️

@@ -17,10 +17,10 @@ const UpdateButton: React.FC<BillingControlsProps> = ({
seats,
}) => {
const { provider, owner } = useParams<{ provider: string; owner: string }>()
const { data: accountDetails } = useAccountDetails({ provider, owner })
const { data: planData } = usePlanData({ provider, owner })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hot swap of useAccountDetails -> usePlanData

@@ -281,7 +284,8 @@ export const useInfiniteTestResults = ({
data?.owner?.repository?.testAnalytics?.testResults?.totalCount ??
0,
private: data?.owner?.repository?.private ?? null,
plan: data?.owner?.plan?.value ?? null,
planName: data?.owner?.plan?.value ?? null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming this field to be more relevant to what it actually is

Copy link

codecov bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (c355537) to head (e132301).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3584      +/-   ##
==========================================
- Coverage   98.90%   98.90%   -0.01%     
==========================================
  Files         810      810              
  Lines       14563    14555       -8     
  Branches     4145     4150       +5     
==========================================
- Hits        14404    14395       -9     
- Misses        152      153       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
...rsPage/MembersActivation/Activation/Activation.jsx 100.00% <100.00%> (ø)
src/pages/MembersPage/MembersList/MembersList.jsx 100.00% <100.00%> (ø)
...bersPage/MembersList/MembersTable/MembersTable.tsx 100.00% <100.00%> (ø)
...ges/OwnerPage/Tabs/TrialReminder/TrialReminder.tsx 100.00% <100.00%> (ø)
...Routes/DowngradePlan/CancelButton/CancelButton.jsx 100.00% <100.00%> (ø)
...PlanPage/subRoutes/DowngradePlan/DowngradePlan.jsx 100.00% <100.00%> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <100.00%> (ø)
...Plan/CurrentPlanCard/FreePlanCard/FreePlanCard.jsx 100.00% <ø> (ø)
...d/FreePlanCard/PlanUpgradeTeam/PlanUpgradeTeam.jsx 100.00% <100.00%> (ø)
...eePlanCard/ProPlanSubheading/ProPlanSubheading.tsx 100.00% <100.00%> (ø)
... and 19 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.57% <100.00%> (-0.02%) ⬇️
Services 99.36% <ø> (ø)
Shared 99.32% <100.00%> (-0.01%) ⬇️
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 c355537...e132301. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (c355537) to head (e132301).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

@@            Coverage Diff             @@
##             main    #3584      +/-   ##
==========================================
- Coverage   98.90%   98.90%   -0.01%     
==========================================
  Files         810      810              
  Lines       14563    14555       -8     
  Branches     4145     4143       -2     
==========================================
- Hits        14404    14395       -9     
- Misses        152      153       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
...rsPage/MembersActivation/Activation/Activation.jsx 100.00% <100.00%> (ø)
src/pages/MembersPage/MembersList/MembersList.jsx 100.00% <100.00%> (ø)
...bersPage/MembersList/MembersTable/MembersTable.tsx 100.00% <100.00%> (ø)
...ges/OwnerPage/Tabs/TrialReminder/TrialReminder.tsx 100.00% <100.00%> (ø)
...Routes/DowngradePlan/CancelButton/CancelButton.jsx 100.00% <100.00%> (ø)
...PlanPage/subRoutes/DowngradePlan/DowngradePlan.jsx 100.00% <100.00%> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <100.00%> (ø)
...Plan/CurrentPlanCard/FreePlanCard/FreePlanCard.jsx 100.00% <ø> (ø)
...d/FreePlanCard/PlanUpgradeTeam/PlanUpgradeTeam.jsx 100.00% <100.00%> (ø)
...eePlanCard/ProPlanSubheading/ProPlanSubheading.tsx 100.00% <100.00%> (ø)
... and 19 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.57% <100.00%> (-0.02%) ⬇️
Services 99.36% <ø> (ø)
Shared 99.32% <100.00%> (-0.01%) ⬇️
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 c355537...e132301. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

@@            Coverage Diff             @@
##             main    #3584      +/-   ##
==========================================
- Coverage   98.90%   98.90%   -0.01%     
==========================================
  Files         810      810              
  Lines       14563    14555       -8     
  Branches     4152     4143       -9     
==========================================
- Hits        14404    14395       -9     
- Misses        152      153       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
...rsPage/MembersActivation/Activation/Activation.jsx 100.00% <100.00%> (ø)
src/pages/MembersPage/MembersList/MembersList.jsx 100.00% <100.00%> (ø)
...bersPage/MembersList/MembersTable/MembersTable.tsx 100.00% <100.00%> (ø)
...ges/OwnerPage/Tabs/TrialReminder/TrialReminder.tsx 100.00% <100.00%> (ø)
...Routes/DowngradePlan/CancelButton/CancelButton.jsx 100.00% <100.00%> (ø)
...PlanPage/subRoutes/DowngradePlan/DowngradePlan.jsx 100.00% <100.00%> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <100.00%> (ø)
...Plan/CurrentPlanCard/FreePlanCard/FreePlanCard.jsx 100.00% <ø> (ø)
...d/FreePlanCard/PlanUpgradeTeam/PlanUpgradeTeam.jsx 100.00% <100.00%> (ø)
...eePlanCard/ProPlanSubheading/ProPlanSubheading.tsx 100.00% <100.00%> (ø)
... and 19 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.57% <100.00%> (-0.02%) ⬇️
Services 99.36% <ø> (ø)
Shared 99.32% <100.00%> (-0.01%) ⬇️
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 c355537...e132301. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.90%. Comparing base (c05416a) to head (7027b35).
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3584      +/-   ##
==========================================
- Coverage   98.91%   98.90%   -0.02%     
==========================================
  Files         806      810       +4     
  Lines       14478    14555      +77     
  Branches     4105     4150      +45     
==========================================
+ Hits        14321    14395      +74     
- Misses        150      153       +3     
  Partials        7        7              
Files with missing lines Coverage Δ
...rsPage/MembersActivation/Activation/Activation.jsx 100.00% <100.00%> (ø)
src/pages/MembersPage/MembersList/MembersList.jsx 100.00% <100.00%> (ø)
...bersPage/MembersList/MembersTable/MembersTable.tsx 100.00% <100.00%> (ø)
...ges/OwnerPage/Tabs/TrialReminder/TrialReminder.tsx 100.00% <100.00%> (ø)
...Routes/DowngradePlan/CancelButton/CancelButton.jsx 100.00% <100.00%> (ø)
...PlanPage/subRoutes/DowngradePlan/DowngradePlan.jsx 100.00% <100.00%> (ø)
...CurrentOrgPlan/CurrentPlanCard/CurrentPlanCard.tsx 100.00% <100.00%> (ø)
...Plan/CurrentPlanCard/FreePlanCard/FreePlanCard.jsx 100.00% <ø> (ø)
...d/FreePlanCard/PlanUpgradeTeam/PlanUpgradeTeam.jsx 100.00% <100.00%> (ø)
...eePlanCard/ProPlanSubheading/ProPlanSubheading.tsx 100.00% <100.00%> (ø)
... and 19 more

... and 28 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.57% <100.00%> (-0.03%) ⬇️
Services 99.36% <ø> (+<0.01%) ⬆️
Shared 99.32% <100.00%> (-0.01%) ⬇️
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 c05416a...7027b35. Read the comment docs.

@@ -62,7 +60,7 @@ function PlansActionsBilling({ plan }) {
return (
<div className="flex self-start">
<Button to={{ pageName: 'upgradeOrgPlan' }} variant="primary">
{isSentryPlan(plan?.value) ? 'Manage plan' : 'Upgrade'}
Copy link
Contributor Author

@ajay-sentry ajay-sentry Dec 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUG FIX: this wasn't the plan object but rather the plan name so this was never working

@@ -71,22 +69,17 @@ function PlansActionsBilling({ plan }) {
return (
<div className="flex self-start">
<Button to={{ pageName: 'upgradeOrgPlan' }} variant="primary">
{isFreePlan(plan?.value) || isTrialPlan(plan?.value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar bugfix here

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Dec 15, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
bc6bf59 Sun, 15 Dec 2024 17:16:16 GMT Expired Expired
7027b35 Sun, 15 Dec 2024 17:22:48 GMT Expired Expired
e132301 Tue, 17 Dec 2024 21:50:29 GMT Cloud Enterprise

Copy link
Contributor

@RulaKhaled RulaKhaled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm in general just one question regarding nullable values

@@ -35,13 +35,6 @@ export interface Plan {
quantity?: number
}

export function isFreePlan(plan?: PlanName | null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beauty

@@ -65,6 +65,7 @@ const GetTestResultsSchema = z.object({
plan: z
.object({
value: z.nativeEnum(Plans),
isFreePlan: z.boolean(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this nullable?

@@ -181,7 +183,8 @@ interface UseTestResultsArgs {
testResults: TestResult[]
pageInfo: { endCursor: string | null; hasNextPage: boolean }
private: boolean | null
plan: PlanName | null
planName: PlanName | null
isFreePlan: boolean | null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it says | null here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guh good catch, I'll update. It shouldn't be nullable iirc

@ajay-sentry ajay-sentry added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit 9f5cd7c Dec 17, 2024
54 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/migrate-is-free-plan branch December 17, 2024 21:55
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.

Migrate isFreePlan in Gazebo to use GQL Property
3 participants