-
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
feat: [M3-6743] - Create Subnet Drawer #9652
feat: [M3-6743] - Create Subnet Drawer #9652
Conversation
@@ -1,6 +1,6 @@ | |||
import { determineIPType, vpcsValidateIP } from '@linode/validation'; | |||
|
|||
export const DEFAULT_SUBNET_IPV4_VALUE = '10.0.0.0/24'; | |||
export const DEFAULT_SUBNET_IPV4_VALUE = '10.0.4.0/24'; |
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.
UI mocks updated to use 10.0.4.0/24 as default subnet ip value, so changed it here (+ had to update a lot of related tests)
@@ -1,7 +1,7 @@ | |||
import ipaddr from 'ipaddr.js'; | |||
import { array, lazy, object, string } from 'yup'; | |||
|
|||
const LABEL_MESSAGE = 'VPC label must be between 1 and 64 characters.'; | |||
const LABEL_MESSAGE = 'Label must be between 1 and 64 characters.'; |
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.
If a subnet label was 0 or > 64 characters, this message showed up, so removed VPC from the error message
const newErrors = getErrorMap(['label', 'ipv4'], errors); | ||
setErrorMap(newErrors); | ||
setValues({ | ||
label: values.label, | ||
labelError: newErrors.label, | ||
ip: { | ||
...values.ip, | ||
ipv4Error: newErrors.ipv4, | ||
}, | ||
}); | ||
} | ||
}; | ||
|
||
const { dirty, handleSubmit, resetForm, setValues, values } = useFormik({ | ||
enableReinitialize: true, | ||
initialValues: { | ||
// TODO VPC - add IPv6 when that is supported | ||
label: '', | ||
ip: { | ||
ipv4: DEFAULT_SUBNET_IPV4_VALUE, | ||
availIPv4s: 256, | ||
}, | ||
} as SubnetFieldState, | ||
onSubmit: onCreateSubnet, | ||
validateOnBlur: false, | ||
validateOnChange: false, | ||
validationSchema: createSubnetSchema, | ||
}); |
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 have a version where I don't use the SubnetNode on one of my branches -- the code for error handling is a bit cleaner (+ we can keep the formik in the same shape as the CreateSubnetPayload) in that case in exchange for a more cluttered form (but both versions should have the same functionality, if SubnetNode is as flexible as I'd originally intended it to be way back during VPCCreate).
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 like the inputs are still enabled for restricted users
Screen.Recording.2023-09-11.at.3.50.16.PM.mov
packages/manager/src/features/VPCs/VPCDetail/VPCSubnetsTable.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>
@hana-linode thanks for catching, should be fixed now :D |
ip: { | ||
...values.ip, | ||
ipv4Error: newErrors.ipv4, | ||
}, |
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.
When we get a general error (would end up being stored on errorMap.none
since it doesn't belong to a particular field -- you can try blocking network requests to *subnet*
to replicate this), it's persisting between drawer openings and closings currently.
Might have to do something like setErrorMap({})
in the useEffect()
, although I'm not sure why resetForm()
isn't taking care of this aspect
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.
thanks for catching, just pushed! Maybe it could be because I've a separate useState hook for the error map due to the SubnetNode, and Formik can't reset that with resetForm? Not too sure though, just a guess 💭
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.
🎉
packages/manager/src/features/VPCs/VPCCreate/SubnetNode.test.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/VPCs/VPCCreate/SubnetNode.test.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/VPCs/VPCCreate/SubnetNode.test.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/VPCs/VPCCreate/SubnetNode.test.tsx
Outdated
Show resolved
Hide resolved
@@ -27,10 +27,7 @@ export const ListeningServices = (props: TableProps) => { | |||
const { services, servicesError, servicesLoading } = props; |
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.
how did this sneak in? 🤣
maybe an eslint thing after merging
Description 📝
Preview 📷
Screen.Recording.2023-09-08.at.10.37.49.AM.mov
How to test 🧪
yarn test CreateSubnetDrawer
yarn test SubnetNode
yarn cy:run -s "cypress/e2e/core/vpc/vpc-details-page.spec.ts"