Skip to content
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-6757] - Create VPC page #9537

Merged
merged 28 commits into from
Aug 23, 2023

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Aug 11, 2023

Description 📝

Preview 📷

image
image
image

How to test 🧪

yarn test VPCCreate
yarn test subnets.test.ts

  • turn on mocks and navigate to /vpc/create to create a vpc OR use your dev account 9must have vpc abilities enabled)

@coliu-akamai coliu-akamai added the VPC Relating to VPC project label Aug 11, 2023
@coliu-akamai coliu-akamai self-assigned this Aug 11, 2023
Comment on lines 60 to 85
const validateVPCSubnets = () => {
const validatedSubnets = validateSubnets(values.subnets, {
labelError:
'Label is required. Must only be ASCII letters, numbers, and dashes',
ipv4Error: 'The IPv4 range must be in CIDR format',
});

if (
validatedSubnets.some(
(subnet) => subnet.labelError || subnet.ip.ipv4Error
)
) {
setFieldValue('subnets', validatedSubnets);
return false;
} else {
setFieldValue(
'subnets',
validatedSubnets.map((subnet) => {
delete subnet.labelError;
delete subnet.ip.ipv4Error;
return { ...subnet };
})
);
return true;
}
};
Copy link
Contributor Author

@coliu-akamai coliu-akamai Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is pretty similar to the validateIP method in DatabaseCreate -- I'm not the biggest fan of this validation outside of using the createVPCSchema, but was having trouble trying to parse through the errors returned from the schema. Playing around with this on my branch create-vpc-offshoot1, but it's messy rn

update: see coliu-akamai#1!

Comment on lines +17 to +32
export const determineIPType = (ip: string) => {
try {
let addr;
const [, mask] = ip.split('/');
if (mask) {
const parsed = ipaddr.parseCIDR(ip);
addr = parsed[0];
} else {
addr = ipaddr.parse(ip);
}
return addr.kind();
} catch (e) {
return undefined;
}
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this functionality outside of vpcsValidateIP and into its own function in order to be able to determine ip type for calculating the number of available ipv4s of a subnet mask

Comment on lines 16 to 23
// janky solution to enable SubnetNode to be an independent component or be part of MultipleSubnetInput
// (not the biggest fan tbh)
onChange: (
subnet: SubnetFieldState,
subnetIdx?: number,
remove?: boolean
) => void;
removable?: boolean;
Copy link
Contributor Author

@coliu-akamai coliu-akamai Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to make SubnetNode its own component in order for it to have future use cases (like the edit/create Subnet drawers), but that led to packing the onChange method with some parameters that wouldn't be necessary (and some props, like removable) if this file was combined with MultiplleSubnetInput.tsx. The MultipleSubnetInput.tsx functionality is otherwise along the same idea as the MultipleIpInput component

Comment on lines +51 to +53
onChange={(subnet, subnetIdx, removable) =>
handleSubnetChange(subnet, subnetIdx ?? 0, !!removable)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment at SubnetNode.tsx

@coliu-akamai coliu-akamai marked this pull request as ready for review August 16, 2023 16:39
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI is looking solid so far and I was able to create a VPC successfully 🎉

I still have a lot of code to comb through but I left some initial comments. Will be sure to dedicate some time tomorrow to looking at this more thoroughly.

@coliu-akamai
Copy link
Contributor Author

Second version of validation here: coliu-akamai#1

Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we display general API errors and scroll errors into view as well? You can see this error by trying to create a VPC on the prod env

Screen.Recording.2023-08-17.at.4.17.25.PM.mov

@coliu-akamai
Copy link
Contributor Author

@dwiley-akamai not sure why I'm not seeing the sort-imports and related suggestions, but I ran eslint on all the VPC related files which reorganized them all

Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I'm in favor of rolling with the validation in this PR as opposed to the one on the other branch given the drawbacks of that other approach.

@bnussman-akamai bnussman-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Aug 22, 2023
Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real API errors don't seem to be mapping to the inputs 🤔

image

@coliu-akamai
Copy link
Contributor Author

coliu-akamai commented Aug 23, 2023

@hana-linode nice catch, thanks! It's probably gonna be a change to line 114 on VPCCreate

--> fixed! ty :D

Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! 🚀 🚀

@coliu-akamai coliu-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Aug 23, 2023
@bnussman-akamai bnussman-akamai removed the Approved Multiple approvals and ready to merge! label Aug 23, 2023
@coliu-akamai
Copy link
Contributor Author

Unsure why the Banks-bot is saying this is not approved, but will be merging now since two approvals

@coliu-akamai coliu-akamai added the Approved Multiple approvals and ready to merge! label Aug 23, 2023
@bnussman-akamai bnussman-akamai removed the Approved Multiple approvals and ready to merge! label Aug 23, 2023
@coliu-akamai coliu-akamai merged commit 0dcc5ee into linode:develop Aug 23, 2023
coliu-akamai added a commit to coliu-akamai/manager that referenced this pull request Aug 23, 2023
* add landing header for vpc create

* initial page layout, still need all the logic + more styling

* the form persists :o

* tiny bit of styling (honestly should wait til the end to do this)

* form logic

* mock service worker

* some unit tests, calculating subnet

* test updates

* add multipleSubnetInput wrapper (may potentially undo)

* unnecessary divider in v2 of subnet inputs

* there's a lot of issues with validation

* updated validation

* update diabled factors

* Added changeset: VPC Create page

* fix failing vpc create tests

* address feedback

* address feedback (+ dev account working now :D)

* fix failing tests after scrollErrorIntoView

* address feedback, update tests

* subnet ip default value

* default subnet ip value when adding new subnets too

* eslint and move constant to utility file

* Update packages/manager/src/features/VPC/VPCCreate/VPCCreate.tsx

Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>

* Update packages/validation/.changeset/pr-9537-changed-1692640036055.md

Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>

* feedback + starting some tests

* finish tests + update availIPv4 state location due to react key entry

* make subnet errors show up @hana-linode

---------

Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>
Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>
@coliu-akamai coliu-akamai added @linode/api-v4 Changes are made to the @linode/api-v4 package @linode/validation Changes are made to the @linode/validation package labels Aug 24, 2023
corya-akamai pushed a commit to corya-akamai/manager that referenced this pull request Sep 6, 2023
* add landing header for vpc create

* initial page layout, still need all the logic + more styling

* the form persists :o

* tiny bit of styling (honestly should wait til the end to do this)

* form logic

* mock service worker

* some unit tests, calculating subnet

* test updates

* add multipleSubnetInput wrapper (may potentially undo)

* unnecessary divider in v2 of subnet inputs

* there's a lot of issues with validation

* updated validation

* update diabled factors

* Added changeset: VPC Create page

* fix failing vpc create tests

* address feedback

* address feedback (+ dev account working now :D)

* fix failing tests after scrollErrorIntoView

* address feedback, update tests

* subnet ip default value

* default subnet ip value when adding new subnets too

* eslint and move constant to utility file

* Update packages/manager/src/features/VPC/VPCCreate/VPCCreate.tsx

Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>

* Update packages/validation/.changeset/pr-9537-changed-1692640036055.md

Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>

* feedback + starting some tests

* finish tests + update availIPv4 state location due to react key entry

* make subnet errors show up @hana-linode

---------

Co-authored-by: Hana Xu <115299789+hana-linode@users.noreply.github.com>
Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>
@coliu-akamai coliu-akamai deleted the feat-m3-6757 branch September 26, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@linode/api-v4 Changes are made to the @linode/api-v4 package @linode/validation Changes are made to the @linode/validation package VPC Relating to VPC project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants