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-8783] - Migrate /volumes to Tanstack Router #11154

Merged
merged 45 commits into from
Dec 10, 2024

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Oct 24, 2024

Description 📝

This PR implements our new routing to /volumes 🎉

Beyond replicating functionalities, it also switches to using params for dialogs (modals & drawers) for the whole feature.
While being a tad more involved in terms of development, the benefits are quite great:

  • shareable URLs: routed state allows to encode the state of the UI in the URL, making it easy to share specific views or states via a link (ex: link to an detail drawer from another page without complicated state management)
  • browser History: changes in routed state are reflected in the browser's history, allowing users to use the back and forward buttons to navigate through different states.
  • deep Linking: users can bookmark or directly navigate to a specific state of the application, which is useful for returning to a specific view.
  • persistence: the state is preserved across page reloads, as it is stored in the URL.

An overview of how this works
Untitled-2024-10-31-1553

Changes 🔄

  • Implement new routing for any route under (and including) /volumes
  • deprecate state based drawer/modal display in favor of routes
  • make V2 versions of usePagination and userOrder to use the new router methods
  • Unit tests for all the above

How to test 🧪

Verification steps

note: you can use prod-test-029 to test with an account with many volumes

Try to break things!

  • test everything in /volumes
    • pagination: preferences, reload page on existing and new params etc
      • page size
      • page number
    • query volumes via search
    • navigate to all actions and confirm all is working
    • navigate back & forth with browser button
    • try loading a drawer or modal with an invalid ID

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@abailly-akamai abailly-akamai self-assigned this Oct 24, 2024
@abailly-akamai abailly-akamai force-pushed the M3-8783 branch 4 times, most recently from 870fa9c to b51f8da Compare October 29, 2024 18:04
@abailly-akamai abailly-akamai force-pushed the M3-8783 branch 2 times, most recently from 1ba4b04 to 071f12f Compare October 31, 2024 13:12
@@ -56,7 +56,7 @@ export const EditVolumeDrawer = (props: Props) => {
values,
} = useFormik({
enableReinitialize: true,
initialValues: { label: volume?.label, tags: volume?.tags },
initialValues: { label: volume?.label ?? '', tags: volume?.tags ?? [] },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

avoids console error (uncontrolled to controlled input)

// params: { linodeId: volume.linode_id },
// search: { upgrade: 'true' },
// to: '/linodes/$linodeId/storage',
// });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Important

We can't use Tanstack router's navigate() to route to a feature that has not been migrated to the new routing. This will result in a browser crash. In this case we will keep the react-router-dom history.push till /linodes/* routes are served by the new router

@@ -26,7 +26,8 @@ export const gettingStartedGuides: ResourcesLinkSection = {
},
{
text: 'Create and Manage Block Storage Volumes',
to: 'https://techdocs.akamai.com/cloud-computing/docs/block-storage',
to:
'https://techdocs.akamai.com/cloud-computing/docs/manage-block-storage-volumes',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated, doc link was just wrong

@@ -108,7 +108,7 @@ export const makePaginatedResponse = <T extends JsonBodyType>({
typeof item === 'object' &&
item !== null &&
key in item &&
String(item).toLowerCase().includes(searchValue)
String(item[key]).toLowerCase().includes(searchValue)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a fix to make the filtering work when using CRUD MSW (volumes are supported)

@@ -8,4 +9,12 @@ export type RouterContext = {
isACLPEnabled?: boolean;
isDatabasesEnabled?: boolean;
isPlacementGroupsEnabled?: boolean;
queryClient: QueryClient;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need this new react-query context to be able to inspect the cache to validate the entity the router is navigating to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: it is not used in this PR but will be used in features that can use prefetching at the route level

packages/manager/src/routes/volumes/index.ts Show resolved Hide resolved
@abailly-akamai abailly-akamai marked this pull request as ready for review October 31, 2024 21:10
@abailly-akamai abailly-akamai requested a review from a team as a code owner October 31, 2024 21:10
@abailly-akamai abailly-akamai requested review from hkhalil-akamai, coliu-akamai, bnussman-akamai and jaalah-akamai and removed request for a team October 31, 2024 21:10
Copy link

github-actions bot commented Nov 1, 2024

Coverage Report:
Base Coverage: 86.84%
Current Coverage: 86.9%

@jaalah-akamai
Copy link
Contributor

When a user requests a page number that exceeds our available pages (e.g., ?page=100), should we:

  • Automatically redirect them to the last available page, or
  • Maintain current UX where the table displays 'No volume found'?

Copy link
Contributor

@jaalah-akamai jaalah-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this, looking really good.

  • Nit: After clearing the search, the URL still includes an empty query parameter /volumes?query= We should look into cleaning this up since it gets appended for subsequent routes, IE: /volumes/1320163/details?query=

packages/manager/src/routes/volumes/index.ts Outdated Show resolved Hide resolved
packages/manager/src/hooks/usePaginationV2.ts Outdated Show resolved Hide resolved
@abailly-akamai abailly-akamai requested a review from a team as a code owner November 5, 2024 22:58
@abailly-akamai abailly-akamai requested review from cliu-akamai and removed request for a team November 5, 2024 22:58
Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Leaving a couple comments and minor suggestions. Will leave a true review once this PR is in its final state.

packages/api-v4/src/types.ts Outdated Show resolved Hide resolved
packages/manager/src/Router.tsx Outdated Show resolved Hide resolved
packages/manager/src/components/ActionMenu/ActionMenu.tsx Outdated Show resolved Hide resolved
packages/manager/src/hooks/useOrderV2.test.tsx Outdated Show resolved Hide resolved
packages/manager/src/routes/utils/buildXFilters.ts Outdated Show resolved Hide resolved
packages/manager/src/routes/volumes/index.ts Show resolved Hide resolved
@abailly-akamai abailly-akamai marked this pull request as draft November 6, 2024 23:55
@abailly-akamai
Copy link
Contributor Author

Converting this to draft in order to avoid too much feedback based on things being in flux because of reworking parts of the dialog routing from early comments

@hkhalil-akamai
Copy link
Contributor

Converting this to draft in order to avoid too much feedback based on things being in flux because of reworking parts of the dialog routing from early comments

@abailly-akamai for future reference, we should make it clear as early as possible when a PR is in an incomplete state. Reviewing 1000+ line PRs is a time-intensive effort and I didn't realize I was reviewing non-finalized changes until I was most of the way through my review.

@abailly-akamai
Copy link
Contributor Author

@hkhalil-akamai Apologies, you are right, should had done it earlier - addressing feedback and this PR is still in shape so it's tricky - It must be noted your feedback was very valuable

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 467 passing tests on test run #60 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing467 Passing2 Skipped96m 16s

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

✅ back and forth for order by working
✅ confirmed behavior of other items - pagination, search, actions, etc

thanks Alban!

@coliu-akamai coliu-akamai added the Approved Multiple approvals and ready to merge! label Dec 10, 2024
@abailly-akamai abailly-akamai merged commit ac15267 into linode:develop Dec 10, 2024
23 checks passed
Copy link

cypress bot commented Dec 10, 2024

Cloud Manager E2E    Run #6944

Run Properties:  status check failed Failed #6944  •  git commit ac15267b6e: refactor: [M3-8783] - Migrate /volumes to Tanstack Router (#11154)
Project Cloud Manager E2E
Branch Review develop
Run status status check failed Failed #6944
Run duration 32m 18s
Commit git commit ac15267b6e: refactor: [M3-8783] - Migrate /volumes to Tanstack Router (#11154)
Committer Alban Bailly
View all properties for this run ↗︎

Test results
Tests that failed  Failures 3
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 464
View all changes introduced in this branch ↗︎

Tests for review

Failed  linodes/rebuild-linode.spec.ts • 2 failed tests

View Output Video

Test Artifacts
rebuild linode > rebuilds a linode from Community StackScript Screenshots Video
rebuild linode > rebuilds a linode from Account StackScript Screenshots Video
Failed  images/search-images.spec.ts • 1 failed test

View Output Video

Test Artifacts
Search Images > creates two images and make sure they show up in the table and are searchable Screenshots Video
Flakiness  cypress/e2e/core/linodes/linode-config.spec.ts • 1 flaky test

View Output Video

Test Artifacts
Linode Config management > End-to-End > Clones a config Screenshots Video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Routing Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants