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

tech-story: [M3-9052] - Migrate PlacementGroups to Tanstack router #11474

Merged
merged 20 commits into from
Jan 23, 2025

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Jan 3, 2025

Description 📝

  • Adds tanstack routing to placement groups + associated cleanup

Changes 🔄

  • routing consolidations in routes/PlacementGroups
  • use existing patterns for orderby, pagination, and getting dialog data
  • fix tests
  • removed route for /placement-groups/$id/linodes, as this was an extra route that only showed up after closing a drawer while on a PG's details page
  • for the Linodes table in placement groups, had to remove ordering by status as this is not supported by the API (now using API for order by)

Preview 📷

  • Behavior should be relatively unchanged

How to test 🧪

  • Confirm navigation & routed drawers at /placement-groups
    • Confirm pagination
    • Confirm sorting
    • confirm searching
  • Confirm navigation & drawers at /placement-groups/{id}
    • confirm sorting
    • confirm searching

Pagination testing:

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

@coliu-akamai coliu-akamai self-assigned this Jan 3, 2025
@coliu-akamai coliu-akamai changed the title tech-story: [M3-9052] - DRAFT! Migrate PlacementGroups to Tanstack router tech-story: [M3-9052] - DRAFT Migrate PlacementGroups to Tanstack router Jan 3, 2025
@coliu-akamai coliu-akamai force-pushed the m3-9052 branch 4 times, most recently from d4590c6 to 18984b0 Compare January 7, 2025 15:10
@linode linode deleted a comment from linode-gh-bot Jan 7, 2025
@coliu-akamai coliu-akamai force-pushed the m3-9052 branch 3 times, most recently from 0797511 to 610ed4b Compare January 10, 2025 15:18
@coliu-akamai coliu-akamai changed the title tech-story: [M3-9052] - DRAFT Migrate PlacementGroups to Tanstack router tech-story: [M3-9052] - Migrate PlacementGroups to Tanstack router Jan 10, 2025
packages/manager/.eslintrc.cjs Outdated Show resolved Hide resolved
@@ -155,7 +155,7 @@ describe('resize linode', () => {
});
});

it.only('resizes a linode by decreasing size', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops didn't catch this earlier in its respective pr 😅

label: 'PG-1',
placement_group_type: 'anti_affinity:local',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this and a bunch of other test files may just be eslint fixes. Otherwise, they'll have changes to use renderWithThemeAndRouter/other tanstack changes

@@ -11,6 +11,7 @@ import { createPlacementGroupSchema } from '@linode/validation';
import { useFormik } from 'formik';
import { useSnackbar } from 'notistack';
import * as React from 'react';
// eslint-disable-next-line no-restricted-imports
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since PlacementGroupsCreatedDrawer is used in LinodesCreate, we need to keep react-router-dom here (for now)

@@ -105,28 +99,6 @@ export const PlacementGroupsDeleteModal = (props: Props) => {
return null;
}

if (!assignedLinodes) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for here and PlacementGroupsUnassignModal, now that we fetch the values in the parent component via useDialogData, and pass isFetching here, we can remove this existing check - a loading state will get rendered if the data is fetching

Copy link
Contributor

Choose a reason for hiding this comment

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

yup!


const {
data: placementGroup,
error: placementGroupError,
isLoading,
} = usePlacementGroupQuery(placementGroupId);
const { data: linodes, isFetching: isFetchingLinodes } = useAllLinodesQuery(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this and related logic was moved down to a child component, PlacementGroupsLinodes, to avoid excessive prop drilling

Comment on lines -43 to -46
<OrderBy data={linodes} order="asc" orderBy={orderLinodeKey}>
{({ data: orderedData, handleOrderChange, order, orderBy }) => (
<Paginate data={orderedData}>
{({
Copy link
Contributor Author

@coliu-akamai coliu-akamai Jan 13, 2025

Choose a reason for hiding this comment

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

rather than OrderBy, we're now using useOrderV2 - see PlacementGroupsLinodes

paginate - tbd, running into some issues

const orderLinodeKey = 'label';
const orderStatusKey = 'status';
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 Changes section in PR main comment - removed status option bc it's not supported by the API

action,
}),
},
path: 'linodes/$action',
Copy link
Contributor Author

@coliu-akamai coliu-akamai Jan 13, 2025

Choose a reason for hiding this comment

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

since assigning a Linode and unassigning it use slightly different routes, updating to use params.action === action pattern wasn't as straightforward as placementGroupAction - I ended up making placementGroupsUnassignRoute be a child of this placementGroupLinodesActionBaseRoute route

...(query && { label: { '+contains': query } }),
};

const { data: linodes, isFetching: isFetchingLinodes } = useAllLinodesQuery(
Copy link
Contributor Author

@coliu-akamai coliu-akamai Jan 13, 2025

Choose a reason for hiding this comment

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

pagination for the linodes table: having trouble testing with mock testing - it looks like filtering isn't applied, so all linodes are being returned, not just the ones that match lines 72-73 above. (also, repeat linodes are being returned/the same query is firing several times?, so I need to do more investigation with this)

I do think that pagination with actual data should work, (if it gets to that point - for actual data, most PGs I see can only have up to 5, maybe 10 linodes, so I haven't yet seen the footer) bc the actual queries are returning filtered and paginated data. However, bc I'm having trouble confirming, I don't want to say this with 100% confidence...

If it's better, I can switch this back to the original code which uses the Paginate hoc, but would need to do more work to get routing working for pagination then

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is ok. Seems like an edge for mock data only so i am not worried about this.

@coliu-akamai coliu-akamai marked this pull request as ready for review January 13, 2025 20:02
@coliu-akamai coliu-akamai requested review from a team as code owners January 13, 2025 20:02
@coliu-akamai coliu-akamai requested review from AzureLatte, bnussman-akamai and carrillo-erik and removed request for a team January 13, 2025 20:02
>();
const { isLinodeReadOnly, placementGroup, region } = props;
const navigate = useNavigate();
const params = useParams({ strict: false });
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, is there any realistic way we can avoid using strict: false so often? It feels wrong, but does the job

Copy link
Contributor

@abailly-akamai abailly-akamai Jan 13, 2025

Choose a reason for hiding this comment

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

We can only avoid strict: false for routes that don't have mounted routed content. So for pages containing modals/drawers/tabs we need to have it - it is by design (and also because of the way our application was composed)

@coliu-akamai
Copy link
Contributor Author

coliu-akamai commented Jan 22, 2025

@abailly-akamai for the notice issue, this is what I'm seeing - I just rebased with develop which has this pr that fixed a lot of notices 🚀

Looking into the extra reload thing - wondering if isFetching is suddenly changing

update - changing deleteModal to use isLoading instead + each unassign Linode button has its own loading state

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🔺 1 failing test on test run #36 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
1 Failing476 Passing2 Skipped108m 0s

Details

Failing Tests
SpecTest
resize-linode.spec.tsresize linode » resizes a linode by increasing size: warm migration

Troubleshooting

Use this command to re-run the failing tests:

yarn cy:run -s "cypress/e2e/core/linodes/resize-linode.spec.ts"

@coliu-akamai coliu-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Jan 22, 2025
@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jan 23, 2025
@coliu-akamai coliu-akamai merged commit 20b4b73 into linode:develop Jan 23, 2025
22 of 23 checks passed
@coliu-akamai coliu-akamai deleted the m3-9052 branch January 23, 2025 13:28
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.

4 participants