-
Notifications
You must be signed in to change notification settings - Fork 365
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
refactor: [M3-7831] - Use nodebalancers/types
endpoint for pricing data
#10265
refactor: [M3-7831] - Use nodebalancers/types
endpoint for pricing data
#10265
Conversation
8eee1fa
to
18393a4
Compare
export const typesQueries = createQueryKeys('types', { | ||
nodebalancers: { | ||
queryFn: getAllNodeBalancerTypes, | ||
queryKey: null, | ||
}, | ||
}); | ||
|
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 started transitioning this file to the query key factory with new types queries to keep the scope small, with the goal of adding additional keys with each /types PR. And I wasn't sure how to transition the linodes specific types query (queryClient
➡️ contextQueries
?).
Query key changes don't have to be in this PR, and I could revert the query key factory change for now, to be refactored all at once in its own PR later.
@@ -15,6 +20,18 @@ export interface DataCenterPricingOptions { | |||
regionId: Region['id'] | undefined; | |||
} | |||
|
|||
export interface DataCenterPricingByTypeOptions { |
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.
Eventually, we'll be able to remove the getDCSpecificPrice
function and DataCenterPricingOptions
interface and replace them with getDCSpecificPricingByType
and DataCenterPricingByTypeOptions
. We'll have both until all prices are being calculated using /types
data, rather than constants we maintain.
@@ -115,3 +117,11 @@ export interface RequestHeaders { | |||
'User-Agent'?: string; | |||
'Content-Type'?: RequestContentType; | |||
} | |||
|
|||
export interface PriceType { |
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.
Placed this new interface in this file because it's not specific to any one product... nodebalancers, volumes, obj, etc. /types
endpoints will all use this.
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.
Do you know if those will be consistent with future price types for other entities? Otherwise they may just belong to NodeBalancersPriceTypes in
packages/api-v4/src/nodebalancers/nodebalancers.ts
?
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.
They will be consistent.
disabled={ | ||
(showGDPRCheckbox && !hasSignedAgreement) || isRestricted || !price | ||
} | ||
sx={{ | ||
flexShrink: 0, | ||
mx: matchesSmDown ? theme.spacing(1) : null, | ||
}} | ||
buttonType="primary" | ||
data-qa-deploy-nodebalancer | ||
disabled={(showGDPRCheckbox && !hasSignedAgreement) || isRestricted} | ||
loading={isLoading} | ||
onClick={onCreate} | ||
tooltipText={!price ? PRICE_ERROR_TOOLTIP_TEXT : ''} |
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.
The only UI changes in this PR are to disable the Create button with a tooltip for context if, for any reason, the price is not available. (It will display as $--.-- in the summary.)
disabled={ | ||
(showGDPRCheckbox && !hasSignedAgreement) || | ||
isRestricted || | ||
isInvalidPrice |
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 kind of feel like we shouldn't disable the button if price isn't invalid, but because this will be a rare case, I don't think it's a huge deal either way.
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.
feel like we shouldn't disable the button if price isn't invalid
I'm guessing you mean we shouldn't disable the button if the price is invalid, since that's the change here.
Going to add this as a topic at cafe today to get some UX feedback.
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.
Yes, my fault!
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.
@@ -115,3 +117,11 @@ export interface RequestHeaders { | |||
'User-Agent'?: string; | |||
'Content-Type'?: RequestContentType; | |||
} | |||
|
|||
export interface PriceType { |
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.
Do you know if those will be consistent with future price types for other entities? Otherwise they may just belong to NodeBalancersPriceTypes in
packages/api-v4/src/nodebalancers/nodebalancers.ts
?
Coverage Report: ✅ |
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.
Tested different options for the Region and observed the correct impacts on pricing -- base pricing ($10/month), Jakarta ($12/month), and Sao Paulo ($14/month) ✅
Observed no regressions in decimal point value or calculations displayed in the UI ✅
NodeBalancer flow functionality ✅
Merging this as is. Product is aware of this UX for the disabled create button and didn't request any changes to the behavior. |
…data (linode#10265) * Replace nodebalancer constant pricing with /types endpoint pricing * Add factory and MSW endpoint * Remove price constant * Clean up * Disable Create button if pricing is unavailable * Use query key factory for new types query * Only disable Create button if region is valid but price is not * Add changesets * Fix typo * Address feedback: types, unit test, move query * Update the import statements I missed * Gotta catch 'em all
Description 📝
API is now returning pricing data through the
/nodebalancers/types
endpoint.As developers, we want to update our code to rely on prices returned by the API so that we do not need to manually maintain our pricing maps as more DC-specific pricing regions are added.
Changes 🔄
getDCSpecificPriceByType
, to use data from the type object instead of from a constant pricing map.NODEBALANCER_PRICE
in utils/pricing/constants.ts for hardcoded prices is removed.Preview 📷
The only visual change should be the disabled Create NodeBalancer button if a region is selected and the price is invalid (e.g. undefined).
How to test 🧪
Prerequisites
(How to setup test environment)
yarn up
.types
endpoints are all in prod, so use the prod environment.Verification steps
(How to verify changes)
Confirm:
As an Author I have considered 🤔
Check all that apply