-
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
Tech Story [M3-6276]: Nodebalancers MUI Migration #9139
Merged
abailly-akamai
merged 10 commits into
linode:develop
from
abailly-akamai:tech-story-M3-6276
May 23, 2023
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1fff7fd
Refactor: [M3-6276]: ConfigNodeIPSelect
abailly-akamai 17e4895
Refactor: [M3-6276]: NodeBalancerConfigNode
abailly-akamai bbcee82
Refactor: [M3-6276]: NodeBalancerConfigPanel
abailly-akamai 8877bd3
Refactor: [M3-6276]: NodeBalancerSummary
abailly-akamai 8bfac4b
Refactor: [M3-6276]: NodeBalancerLandingEmpty
abailly-akamai 50e3d68
Refactor: [M3-6276]: NodeBalancerConfigurations
abailly-akamai 03ee358
Refactor: [M3-6276]: SummaryPanel
abailly-akamai cb57282
Refactor: [M3-6276]: TablesPanel
abailly-akamai 007d7da
Added changeset: Nodebalancers (feature) MUI Migration
abailly-akamai 31e5458
Refactor: [M3-6276]: Address feedback
abailly-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 217 additions & 0 deletions
217
packages/manager/src/features/NodeBalancers/NodeBalancerActiveCheck.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
import * as React from 'react'; | ||
import FormHelperText from 'src/components/core/FormHelperText'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import InputAdornment from 'src/components/core/InputAdornment'; | ||
import Select from 'src/components/EnhancedSelect/Select'; | ||
import TextField from 'src/components/TextField'; | ||
import Typography from 'src/components/core/Typography'; | ||
import { setErrorMap } from './utils'; | ||
import type { Item } from 'src/components/EnhancedSelect'; | ||
import type { NodeBalancerConfigPanelProps } from './types'; | ||
|
||
interface ActiveCheckProps extends NodeBalancerConfigPanelProps { | ||
errorMap: Record<string, string | undefined>; | ||
} | ||
|
||
const displayProtocolText = (p: string) => { | ||
if (p === 'tcp') { | ||
return `'TCP Connection' requires a successful TCP handshake.`; | ||
} | ||
if (p === 'http' || p === 'https') { | ||
return `'HTTP Valid Status' requires a 2xx or 3xx response from the backend node. 'HTTP Body Regex' uses a regex to match against an expected result body.`; | ||
} | ||
return undefined; | ||
}; | ||
|
||
export const ActiveCheck = (props: ActiveCheckProps) => { | ||
const { | ||
checkBody, | ||
checkPath, | ||
configIdx, | ||
disabled, | ||
errors, | ||
forEdit, | ||
healthCheckAttempts, | ||
healthCheckInterval, | ||
healthCheckTimeout, | ||
healthCheckType, | ||
protocol, | ||
} = props; | ||
|
||
const errorMap = setErrorMap(errors || []); | ||
|
||
const onCheckBodyChange = (e: React.ChangeEvent<HTMLInputElement>) => | ||
props.onCheckBodyChange(e.target.value); | ||
|
||
const onCheckPathChange = (e: React.ChangeEvent<HTMLInputElement>) => | ||
props.onCheckPathChange(e.target.value); | ||
|
||
const onHealthCheckAttemptsChange = ( | ||
e: React.ChangeEvent<HTMLInputElement> | ||
) => props.onHealthCheckAttemptsChange(e.target.value); | ||
|
||
const onHealthCheckIntervalChange = ( | ||
e: React.ChangeEvent<HTMLInputElement> | ||
) => props.onHealthCheckIntervalChange(e.target.value); | ||
|
||
const onHealthCheckTimeoutChange = (e: React.ChangeEvent<HTMLInputElement>) => | ||
props.onHealthCheckTimeoutChange(e.target.value); | ||
|
||
const onHealthCheckTypeChange = (e: Item<string>) => | ||
props.onHealthCheckTypeChange(e.value); | ||
|
||
const conditionalText = displayProtocolText(protocol); | ||
|
||
const typeOptions = [ | ||
{ | ||
label: 'None', | ||
value: 'none', | ||
}, | ||
{ | ||
label: 'TCP Connection', | ||
value: 'connection', | ||
}, | ||
{ | ||
label: 'HTTP Status', | ||
value: 'http', | ||
disabled: protocol === 'tcp', | ||
}, | ||
{ | ||
label: 'HTTP Body', | ||
value: 'http_body', | ||
disabled: protocol === 'tcp', | ||
}, | ||
]; | ||
|
||
const defaultType = typeOptions.find((eachType) => { | ||
return eachType.value === healthCheckType; | ||
}); | ||
|
||
return ( | ||
<Grid xs={12} md={6} sx={{ padding: 0 }}> | ||
<Grid container spacing={2}> | ||
<Grid xs={12}> | ||
<Typography variant="h2" data-qa-active-checks-header> | ||
Active Health Checks | ||
</Typography> | ||
</Grid> | ||
<Grid xs={12}> | ||
<Select | ||
options={typeOptions} | ||
label="Type" | ||
inputId={`type-${configIdx}`} | ||
value={defaultType || typeOptions[0]} | ||
onChange={onHealthCheckTypeChange} | ||
errorText={errorMap.check} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
textFieldProps={{ | ||
dataAttrs: { | ||
'data-qa-active-check-select': true, | ||
}, | ||
}} | ||
small | ||
disabled={disabled} | ||
isClearable={false} | ||
noMarginTop | ||
/> | ||
<FormHelperText> | ||
Active health checks proactively check the health of back-end nodes.{' '} | ||
{conditionalText} | ||
</FormHelperText> | ||
</Grid> | ||
{healthCheckType !== 'none' && ( | ||
<React.Fragment> | ||
<Grid xs={12}> | ||
<TextField | ||
type="number" | ||
label="Interval" | ||
InputProps={{ | ||
'aria-label': 'Active Health Check Interval', | ||
endAdornment: ( | ||
<InputAdornment position="end">seconds</InputAdornment> | ||
), | ||
}} | ||
value={healthCheckInterval} | ||
onChange={onHealthCheckIntervalChange} | ||
errorText={errorMap.check_interval} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
data-qa-active-check-interval | ||
disabled={disabled} | ||
/> | ||
<FormHelperText> | ||
Seconds between health check probes | ||
</FormHelperText> | ||
</Grid> | ||
<Grid xs={12}> | ||
<TextField | ||
type="number" | ||
label="Timeout" | ||
InputProps={{ | ||
'aria-label': 'Active Health Check Timeout', | ||
endAdornment: ( | ||
<InputAdornment position="end">seconds</InputAdornment> | ||
), | ||
}} | ||
value={healthCheckTimeout} | ||
onChange={onHealthCheckTimeoutChange} | ||
errorText={errorMap.check_timeout} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
data-qa-active-check-timeout | ||
disabled={disabled} | ||
/> | ||
<FormHelperText> | ||
Seconds to wait before considering the probe a failure. 1-30. | ||
Must be less than check_interval. | ||
</FormHelperText> | ||
</Grid> | ||
<Grid xs={12} lg={6}> | ||
<TextField | ||
type="number" | ||
label="Attempts" | ||
value={healthCheckAttempts} | ||
onChange={onHealthCheckAttemptsChange} | ||
errorText={errorMap.check_attempts} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
InputProps={{ | ||
'aria-label': 'Active Health Check Attempts', | ||
}} | ||
data-qa-active-check-attempts | ||
disabled={disabled} | ||
/> | ||
<FormHelperText> | ||
Number of failed probes before taking a node out of rotation. | ||
1-30 | ||
</FormHelperText> | ||
</Grid> | ||
{['http', 'http_body'].includes(healthCheckType) && ( | ||
<Grid xs={12} lg={6}> | ||
<TextField | ||
label="Check HTTP Path" | ||
value={checkPath || ''} | ||
onChange={onCheckPathChange} | ||
required={['http', 'http_body'].includes(healthCheckType)} | ||
errorText={errorMap.check_path} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
disabled={disabled} | ||
/> | ||
</Grid> | ||
)} | ||
{healthCheckType === 'http_body' && ( | ||
<Grid xs={12} md={4}> | ||
<TextField | ||
label="Expected HTTP Body" | ||
value={checkBody} | ||
onChange={onCheckBodyChange} | ||
required={healthCheckType === 'http_body'} | ||
errorText={errorMap.check_body} | ||
errorGroup={forEdit ? `${configIdx}` : undefined} | ||
disabled={disabled} | ||
/> | ||
</Grid> | ||
)} | ||
</React.Fragment> | ||
)} | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
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. Extracting to a new component cause |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
not replacing this, display: block is a default for a div and it was not overridden anywhere else