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

refactor: [M3-9080] - Tanstack routing for VPCs #11906

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Mar 21, 2025

Note

I see some VPC related work coming in, so hopefully I'm putting this up early enough to not interrupt VPC stuff. If not, I can def close this and come back to it at a later time

I also have a few questions/stuff I'm unsure of for this refactor, def would appreciate some thoughts! 🙏
(I can also move the bug fixes to a separate PR if needed)

Description 📝

  • Refactors VPC routing to use tanstack routing

Changes 🔄

  • Implement tanstack routing
  • route drawers and modals
  • Fixed a couple of bugs unrelated to tanstack routing:
    • Subnet pagination
    • Subnet create drawer IP incrementation (whoops)

Preview 📷

  • No visual changes besides loading states

How to test 🧪

Navigate to /vpcs and confirm routing behavior for

VPC Landing:

  • edit/delete VPCS
  • pagination/order

VPC Create
VPCDetails ******

  • edit/delete VPCs
  • subnet actions
  • subnet pagination/search/order
  • linode actions

Bug fixes:

  • confirm pagination for subnets table works
  • Confirm IP increments in Subnet Create drawer whenever you create a new Subnet
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@@ -318,47 +385,54 @@ export const VPCSubnetsTable = (props: Props) => {
TableRowHead={SubnetTableRowHead}
/>
<PaginationFooter
count={subnets.data?.length || 0}
count={subnets.results || 0}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixes bug for subnet pagination

@@ -61,7 +61,7 @@ export const SubnetCreateDrawer = (props: Props) => {
setError,
watch,
} = useForm<CreateSubnetPayload>({
defaultValues: {
values: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixes bug for IP incrementation

Comment on lines 52 to 64
const handleEditVPC = (vpc: VPC) => {
navigate({
params: { action: 'edit', vpcId: vpc.id },
to: '/vpcs/$vpcId/details/$action',
});
};

const handleDeleteVPC = (vpc: VPC) => {
navigate({
params: { action: 'delete', vpcId: vpc.id },
to: '/vpcs/$vpcId/details/$action',
});
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

VPC Details was interesting to refactor, and I'm not sure about all the decisions I made

Here:

  • we have edit/delete dialogs on the detail page itself + we fetch the VPC, so I currently went with not using dialog data for VPC in details. In terms of error handling, if we're unable to get the VPC, we remain on the VPC's detail page and display the following error below. Should we reroute to the /vpcs landing page instead?
  if (!vpc || error) {
    return (
      <ErrorState errorText="There was a problem retrieving your VPC. Please try again." />
    );
  }
  • I have different routes for the edit/delete dialogs on the landing vs details page. Otherwise clicking Edit/Delete on the details page would take us to the landing page
    • landing edit/delete routes for comparison:
      • /vpcs/$vpcId/edit
      • /vpcs/$vpcId/delete

Comment on lines 215 to 222
// If the user initiates a history -/+ to complete a linode action and the linode
// is no longer assigned to a subnet, push navigation to the vpc's detail page
React.useEffect(() => {
if (subnets && selectedSubnet) {
const updatedSubnet = subnets.data.find(
(subnet) => subnet.id === selectedSubnet.id
);
setSelectedSubnet(updatedSubnet);
if (params.linodeAction && !selectedLinode) {
navigate({
params: { vpcId },
to: VPC_DETAILS_ROUTE,
});
Copy link
Contributor Author

@coliu-akamai coliu-akamai Mar 21, 2025

Choose a reason for hiding this comment

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

(see selected subnet comment above)
I've currently kept the selected Linode in a useState, so it has the same issue as mentioned above ^. Thinking about switching to useDialogData, but may still have to keep the useEffect - the Linode actions here don't delete the Linode, so useDialogData won't time out

update: using useDialogData for this as well now + a useEffect that determines if the selected Linode no longer exists in the selectedSubnet

@coliu-akamai coliu-akamai added the Help Wanted Teamwork makes the dream work! label Mar 21, 2025
@coliu-akamai
Copy link
Contributor Author

putting this up for initial review, but likely will be returning it to a draft state based on feedback on ^ items (and other stuff as found)

@abailly-akamai would appreciate your thoughts on this!

@coliu-akamai coliu-akamai marked this pull request as ready for review March 21, 2025 15:17
@coliu-akamai coliu-akamai requested review from a team as code owners March 21, 2025 15:17
@coliu-akamai coliu-akamai requested review from jdamore-linode, mjac0bs and abailly-akamai and removed request for a team March 21, 2025 15:17
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Alight, fixed the useDialogData hook to handle a secondary argument. Hopefully this will work as we want!

Will do a deeper review once some changes and cleanup discussed during pair programming are addressed.

Great work so far tho, this is looking solid as a 🪨

@coliu-akamai coliu-akamai marked this pull request as draft March 24, 2025 16:26
@coliu-akamai
Copy link
Contributor Author

thanks Alban! will get to the changes we discussed sooner rather than later, and then re-request you

@coliu-akamai coliu-akamai removed the Help Wanted Teamwork makes the dream work! label Mar 27, 2025
@coliu-akamai
Copy link
Contributor Author

alrighty should be in a better state now!

@coliu-akamai coliu-akamai marked this pull request as ready for review March 27, 2025 20:40
@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 534 passing tests on test run #10 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing534 Passing4 Skipped106m 48s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants