-
Notifications
You must be signed in to change notification settings - Fork 367
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
Changes from 2 commits
21916de
2dd11af
0af12a7
314e3f9
7a1c274
e17a427
6b86e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||
import { KubeNodePoolResponse, Region } from '@linode/api-v4'; | ||||||
import { Theme } from '@mui/material/styles'; | ||||||
import { makeStyles } from 'tss-react/mui'; | ||||||
import * as React from 'react'; | ||||||
import { makeStyles } from 'tss-react/mui'; | ||||||
|
||||||
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||||||
import { CircleProgress } from 'src/components/CircleProgress'; | ||||||
|
@@ -107,85 +107,92 @@ export const ResizeNodePoolDrawer = (props: Props) => { | |||||
types: planType ? [planType] : [], | ||||||
}); | ||||||
|
||||||
const isInvalidPricePerNode = !pricePerNode && pricePerNode !== 0; | ||||||
const isInvalidTotalMonthlyPrice = | ||||||
!totalMonthlyPrice && totalMonthlyPrice !== 0; | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done in 6b86e9a. |
||||||
return ( | ||||||
<Drawer | ||||||
onClose={onClose} | ||||||
open={open} | ||||||
title={`Resize Pool: ${planType?.formattedLabel ?? 'Unknown'} Plan`} | ||||||
> | ||||||
{isLoadingTypes && <CircleProgress />} | ||||||
<form | ||||||
onSubmit={(e: React.ChangeEvent<HTMLFormElement>) => { | ||||||
e.preventDefault(); | ||||||
handleSubmit(); | ||||||
}} | ||||||
> | ||||||
<div className={classes.section}> | ||||||
{totalMonthlyPrice && ( | ||||||
{isLoadingTypes ? ( | ||||||
<CircleProgress /> | ||||||
) : ( | ||||||
<form | ||||||
onSubmit={(e: React.ChangeEvent<HTMLFormElement>) => { | ||||||
e.preventDefault(); | ||||||
handleSubmit(); | ||||||
}} | ||||||
> | ||||||
<div className={classes.section}> | ||||||
Comment on lines
+123
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
<Typography className={classes.summary}> | ||||||
Current pool: $ | ||||||
{renderMonthlyPriceToCorrectDecimalPlace(totalMonthlyPrice)}/month{' '} | ||||||
({pluralize('node', 'nodes', nodePool.count)} at $ | ||||||
{renderMonthlyPriceToCorrectDecimalPlace(totalMonthlyPrice)} | ||||||
/month ({pluralize('node', 'nodes', nodePool.count)} at $ | ||||||
{renderMonthlyPriceToCorrectDecimalPlace(pricePerNode)} | ||||||
/month) | ||||||
</Typography> | ||||||
)} | ||||||
</div> | ||||||
|
||||||
{error && <Notice text={error?.[0].reason} variant="error" />} | ||||||
|
||||||
<div className={classes.section}> | ||||||
<Typography className={classes.helperText}> | ||||||
Enter the number of nodes you'd like in this pool: | ||||||
</Typography> | ||||||
<EnhancedNumberInput | ||||||
min={1} | ||||||
setValue={handleChange} | ||||||
value={updatedCount} | ||||||
/> | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
{error && <Notice text={error?.[0].reason} variant="error" />} | ||||||
|
||||||
<div className={classes.section}> | ||||||
{/* Renders total pool price/month for N nodes at price per node/month. */} | ||||||
{pricePerNode && ( | ||||||
<div className={classes.section}> | ||||||
<Typography className={classes.helperText}> | ||||||
Enter the number of nodes you'd like in this pool: | ||||||
</Typography> | ||||||
<EnhancedNumberInput | ||||||
min={1} | ||||||
setValue={handleChange} | ||||||
value={updatedCount} | ||||||
/> | ||||||
</div> | ||||||
|
||||||
<div className={classes.section}> | ||||||
{/* Renders total pool price/month for N nodes at price per node/month. */} | ||||||
<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 commentThe reason will be displayed to describe this comment to others. Learn more. Because the |
||||||
)}/month`}{' '} | ||||||
({pluralize('node', 'nodes', updatedCount)} at $ | ||||||
{renderMonthlyPriceToCorrectDecimalPlace(pricePerNode)} | ||||||
/month) | ||||||
</Typography> | ||||||
</div> | ||||||
|
||||||
{updatedCount < nodePool.count && ( | ||||||
<Notice important text={resizeWarning} variant="warning" /> | ||||||
)} | ||||||
|
||||||
{updatedCount < 3 && ( | ||||||
<Notice important text={nodeWarning} variant="warning" /> | ||||||
)} | ||||||
</div> | ||||||
|
||||||
{updatedCount < nodePool.count && ( | ||||||
<Notice important text={resizeWarning} variant="warning" /> | ||||||
)} | ||||||
|
||||||
{updatedCount < 3 && ( | ||||||
<Notice important text={nodeWarning} variant="warning" /> | ||||||
)} | ||||||
|
||||||
{nodePool.count && (!pricePerNode || !totalMonthlyPrice) && ( | ||||||
<Notice | ||||||
spacingBottom={16} | ||||||
spacingTop={8} | ||||||
text={PRICES_RELOAD_ERROR_NOTICE_TEXT} | ||||||
variant="error" | ||||||
|
||||||
{nodePool.count && | ||||||
(isInvalidPricePerNode || isInvalidTotalMonthlyPrice) && ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
<Notice | ||||||
spacingBottom={16} | ||||||
spacingTop={8} | ||||||
text={PRICES_RELOAD_ERROR_NOTICE_TEXT} | ||||||
variant="error" | ||||||
/> | ||||||
)} | ||||||
|
||||||
<ActionsPanel | ||||||
primaryButtonProps={{ | ||||||
'data-testid': 'submit', | ||||||
disabled: | ||||||
updatedCount === nodePool.count || | ||||||
isInvalidPricePerNode || | ||||||
isInvalidTotalMonthlyPrice, | ||||||
label: 'Save Changes', | ||||||
loading: isLoading, | ||||||
onClick: handleSubmit, | ||||||
}} | ||||||
/> | ||||||
)} | ||||||
|
||||||
<ActionsPanel | ||||||
primaryButtonProps={{ | ||||||
'data-testid': 'submit', | ||||||
disabled: updatedCount === nodePool.count, | ||||||
label: 'Save Changes', | ||||||
loading: isLoading, | ||||||
onClick: handleSubmit, | ||||||
}} | ||||||
/> | ||||||
</form> | ||||||
</form> | ||||||
)} | ||||||
</Drawer> | ||||||
); | ||||||
}; |
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.