-
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
feat: [M3-6816] - Add AGLB Create Route Drawer #9806
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b2cae85
Work In Progress
jaalah 7510384
Update latest
jaalah 66af649
Add cypress tests
jaalah 1bcefbe
Rename desc
jaalah 4dee326
Remove it.only
jaalah 6e3750f
Added changeset: Add AGLB Create Route Drawer
jaalah 306c444
Update packages/manager/cypress/support/intercepts/load-balancers.ts
jaalah-akamai 42018f0
Merge branch 'develop' of github.com:linode/manager into M3-6816
jaalah be62eca
Merge branch 'M3-6816' of github.com:jaalah-akamai/manager into M3-6816
jaalah 336200e
Update formik error handling
jaalah a8a3032
Update changesets
jaalah 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
5 changes: 5 additions & 0 deletions
5
packages/api-v4/.changeset/pr-9806-upcoming-features-1697723638782.md
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,5 @@ | ||
--- | ||
"@linode/api-v4": Upcoming Features | ||
--- | ||
|
||
Updated AGLB createLoadbalancerRoute endpoint with payload/schema ([#9806](https://github.com/linode/manager/pull/9806)) |
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
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9806-upcoming-features-1697563902060.md
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,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add AGLB Create Route Drawer ([#9806](https://github.com/linode/manager/pull/9806)) |
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
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
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
113 changes: 113 additions & 0 deletions
113
packages/manager/src/features/LoadBalancers/LoadBalancerDetail/Routes/CreateRouteDrawer.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,113 @@ | ||
import { CreateRoutePayload } from '@linode/api-v4'; | ||
import { useFormik } from 'formik'; | ||
import React from 'react'; | ||
|
||
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||
import { Drawer } from 'src/components/Drawer'; | ||
import { FormControlLabel } from 'src/components/FormControlLabel'; | ||
import { FormHelperText } from 'src/components/FormHelperText'; | ||
import { FormLabel } from 'src/components/FormLabel'; | ||
import { Notice } from 'src/components/Notice/Notice'; | ||
import { Radio } from 'src/components/Radio/Radio'; | ||
import { RadioGroup } from 'src/components/RadioGroup'; | ||
import { TextField } from 'src/components/TextField'; | ||
import { useLoadBalancerRouteCreateMutation } from 'src/queries/aglb/routes'; | ||
import { capitalize } from 'src/utilities/capitalize'; | ||
import { getFormikErrorsFromAPIErrors } from 'src/utilities/formikErrorUtils'; | ||
import { scrollErrorIntoView } from 'src/utilities/scrollErrorIntoView'; | ||
|
||
interface Props { | ||
loadbalancerId: number; | ||
onClose: () => void; | ||
open: boolean; | ||
} | ||
|
||
const initialValues: CreateRoutePayload = { | ||
label: '', | ||
protocol: 'http', | ||
rules: [], | ||
}; | ||
|
||
export const CreateRouteDrawer = (props: Props) => { | ||
const { loadbalancerId, onClose: _onClose, open } = props; | ||
|
||
const { | ||
error, | ||
mutateAsync: createRoute, | ||
reset, | ||
} = useLoadBalancerRouteCreateMutation(loadbalancerId); | ||
|
||
const formik = useFormik<CreateRoutePayload>({ | ||
initialValues, | ||
async onSubmit(values) { | ||
try { | ||
await createRoute(values); | ||
onClose(); | ||
} catch (errors) { | ||
scrollErrorIntoView(); | ||
formik.setErrors(getFormikErrorsFromAPIErrors(errors)); | ||
} | ||
}, | ||
}); | ||
|
||
const onClose = () => { | ||
formik.resetForm(); | ||
reset(); | ||
_onClose(); | ||
}; | ||
|
||
const generalError = error?.find((e) => !e.field)?.reason; | ||
|
||
return ( | ||
<Drawer onClose={onClose} open={open} title="Create Route"> | ||
<form onSubmit={formik.handleSubmit}> | ||
{generalError && <Notice text={generalError} variant="error" />} | ||
<TextField | ||
errorText={formik.touched.label ? formik.errors.label : undefined} | ||
label="Route Label" | ||
name="label" | ||
onChange={formik.handleChange} | ||
value={formik.values.label} | ||
/> | ||
<RadioGroup | ||
onChange={(_, value) => formik.setFieldValue('protocol', value)} | ||
value={formik.values.protocol} | ||
> | ||
<FormLabel sx={(theme) => ({ marginTop: theme.spacing(1) })}> | ||
Protocol | ||
</FormLabel> | ||
<FormControlLabel | ||
control={<Radio />} | ||
data-qa-radio={'HTTP'} | ||
label="HTTP" | ||
value="http" | ||
/> | ||
<FormControlLabel | ||
control={<Radio />} | ||
data-qa-radio={'TCP'} | ||
label="TCP" | ||
value="tcp" | ||
/> | ||
<FormHelperText error> | ||
{formik.touched.protocol | ||
? typeof formik.errors.protocol === 'string' | ||
? capitalize(formik.errors.protocol) | ||
: undefined | ||
: undefined} | ||
</FormHelperText> | ||
</RadioGroup> | ||
<ActionsPanel | ||
primaryButtonProps={{ | ||
label: 'Create Route', | ||
loading: formik.isSubmitting, | ||
type: 'submit', | ||
}} | ||
secondaryButtonProps={{ | ||
label: 'Cancel', | ||
onClick: onClose, | ||
}} | ||
/> | ||
</form> | ||
</Drawer> | ||
); | ||
}; |
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
5 changes: 5 additions & 0 deletions
5
packages/validation/.changeset/pr-9806-upcoming-features-1697723572839.md
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,5 @@ | ||
--- | ||
"@linode/validation": Upcoming Features | ||
--- | ||
|
||
Added AGLB CreateRouteSchema ([#9806](https://github.com/linode/manager/pull/9806)) |
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
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.
Had to narrow this type because it returned
string | undefined
andcapitalize
doesn't like that.