-
Notifications
You must be signed in to change notification settings - Fork 364
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
fix: [M3-7741] - Hide error notices for $0 regions in Resize Pool and Add a Node Pool drawers #10157
fix: [M3-7741] - Hide error notices for $0 regions in Resize Pool and Add a Node Pool drawers #10157
Conversation
<Typography className={classes.summary}> | ||
{`Resized pool: $${renderMonthlyPriceToCorrectDecimalPlace( | ||
updatedCount * pricePerNode | ||
!isInvalidPricePerNode ? updatedCount * pricePerNode : undefined |
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.
Because the pricePerNode
could be null
or undefined
, we can't multiply a non-number. renderMonthlyPriceToCorrectDecimalPlace()
has logic to render a non-numeric price as $--.--
.
variant="error" | ||
|
||
{nodePool.count && | ||
(isInvalidPricePerNode || isInvalidTotalMonthlyPrice) && ( |
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.
Only real change in this section is the updated bools to determine whether to display the pricing error notice or not - the rest of the diff is due to indentation.
{isLoadingTypes ? ( | ||
<CircleProgress /> | ||
) : ( | ||
<form | ||
onSubmit={(e: React.ChangeEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
handleSubmit(); | ||
}} | ||
> | ||
<div className={classes.section}> |
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.
Most of this diff is an indentation change caused by fixing an issue where the loading spinner was displaying above the form, instead of in its place, while isLoadingTypes
is true. This was visible when I blocked network requests as described in the testing steps.
Before | After |
---|---|
Screen.Recording.2024-02-07.at.9.01.57.AM.mov |
Screen.Recording.2024-02-07.at.9.01.12.AM.mov |
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.
Changes in the file are to account for the loading state that is now present before form data is rendered.
const isInvalidPricePerNode = !pricePerNode && pricePerNode !== 0; | ||
const isInvalidTotalMonthlyPrice = | ||
!totalMonthlyPrice && totalMonthlyPrice !== 0; | ||
|
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.
undefined
and null
prices are invalid, but 0
is allowed.
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.
Might be good to have this clarification as a comment in the code
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 second this. Am also thinking you could consolidate this logic with the addNodePool drawer logic in a util with your comments.
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.
Done in 6b86e9a.
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.
Observed the behavior described in the Changes
section for each circumstance (opted to manually modify the values of pricePerNode
and totalMonthlyPrice
) ✅
lke-update.spec.ts
passed ✅
const isInvalidPricePerNode = !pricePerNode && pricePerNode !== 0; | ||
const isInvalidTotalMonthlyPrice = | ||
!totalMonthlyPrice && totalMonthlyPrice !== 0; | ||
|
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.
Might be good to have this clarification as a comment in the code
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.
Looks good and confirmed the fixes shown in the description ✅
Thanks for the improved coverage as well!
Bonus point if you wanna do that minor refactor
const isInvalidPricePerNode = !pricePerNode && pricePerNode !== 0; | ||
const isInvalidTotalMonthlyPrice = | ||
!totalMonthlyPrice && totalMonthlyPrice !== 0; | ||
|
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 second this. Am also thinking you could consolidate this logic with the addNodePool drawer logic in a util with your comments.
… Add a Node Pool drawers (linode#10157) * Allow -zsh LKE prices without error notices in Resize Pool and Add Pool drawers * Fix loading spinner displaying above what was supposed to be loading * Fix conditional to render notice if either price is invalid * Add test coverage * Added changeset: Hide error notices for /bin/sh regions for LKE Resize and Add Node Pools * Fix changeset wording * Address feedback: use invalid price util
…xes for release (#10177) * fix: [M3-7741] - Hide error notices for $0 regions in Resize Pool and Add a Node Pool drawers (#10157) * Allow -zsh LKE prices without error notices in Resize Pool and Add Pool drawers * Fix loading spinner displaying above what was supposed to be loading * Fix conditional to render notice if either price is invalid * Add test coverage * Added changeset: Hide error notices for /bin/sh regions for LKE Resize and Add Node Pools * Fix changeset wording * Address feedback: use invalid price util * fix: [M3-7746] - Fix $0 region price error in "Enable All Backups" drawer (#10161) * Remove error indicator for Linodes in $0 regions * Fix $0 total price display issue * Cover $0 pricing cases in Cypress backup tests * Add BackupLinodeRow tests to account for error states and $0 regions * Add unit tests for BackupDrawer component * fix: [M3-7747] - Fix Linode Migration dialog hidden $0 price (#10166) * Add unit tests for MigrationPricing component * Accounting for $0 prices in MigrationPricing component * fix: [M3-7739] - Fix error when enabling backups for Linodes in regions with $0 price (#10153) * Fix error when enabling backups for Linodes in regions with $0 price * Add unit tests for EnableBackupsDialog --------- Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com> * Replace "toBeDisabled" with "toHaveAttribute" assertion --------- Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Description 📝
This PR supports $0 region pricing by correctly showing pricing without errors on the LKE Details page. It also fixes the UI for invalid (
null
orundefined
) prices in the Resize Pool drawer.Currently, once a user creates a LKE cluster in a region where pricing is $0 (currently: Madrid, which is in LA):
When trying to resize pool, the UI displays a confusing
0
in place of the "Current pool" and "Resized pool" calculations, the pricing error is displayed, but a user is actually still able to complete the resize because the enhanced number input is still clickable and can be incremented, at which point the user can save changes.When trying to add a node pool, after adding at lease one node, the UI displays a pricing error and pricing display text with $--.-- placeholder pricing in it. The user can still save changes.
Changes 🔄
Resize Pool:
N
node(s) at $--.--/month)N
node(s) at $--.--/month)and the pricing error rather than just
0
.Add a Node Pool:
N
node(s) at $--.--/month) to this cluster.Preview 📷
Madrid
)undefined
ornull
pricingMadrid
)How to test 🧪
Prerequisites
(How to setup test environment)
yarn dev
.es-madrid
as its region.Reproduction steps
(How to reproduce the issue, if applicable)
Resize Pool:
Add a Node Pool:
Verification steps
(How to verify changes)
undefined
(same behavior asnull
), block network requests to the linode type (example:v4/linode/types/g6-standard-1
) or manually edit the values ofpricePerNode
andtotalMonthlyPrice
(here, here).As an Author I have considered 🤔
Check all that apply