-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [M3-8783] - Migrate /volumes to Tanstack Router (#11154)
* initial commit: wire new router * Migrate test to use new helper * volumes landing routing * doin the filtering * wire actions * cleanup * cleanup * moar cleanup * more work on params * usePaginationV2 * cleanup * oops fix types * fix e2e * useOrderV2 * and... dont forget the util 🤦 * revert unwarranted change * useOrderV2 test * console error * A bit more cleanup * usePaginationV2 test * usePaginationV2 test * route level error handling * xFilter util * xFilter util improvements * post rebase fix * testing xQuery builder * moar testing and cleanup * Added changeset: Migrate `/volumes` to Tanstack router * Save progress * fix one test * fix remaining test * feedback @jaalah-akamai * more work on preloading * save progress * Walking back and using a more progressive approach * cleanup * entity not found logic * post rebase fix * post rebase fix * update loading state * fix the smoke tests * Feedback @bnussman-akamai * JsDocs for Tanstack link components * Improve new useOrder hook * feedback @coliu-akamai @hkhalil-akamai
- Loading branch information
1 parent
652b2aa
commit ac15267
Showing
49 changed files
with
1,284 additions
and
206 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11154-tech-stories-1730404184309.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tech Stories | ||
--- | ||
|
||
Migrate `/volumes` to Tanstack router ([#11154](https://github.com/linode/manager/pull/11154)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
|
||
import { TanstackLink } from './TanstackLinks'; | ||
|
||
import type { TanstackLinkComponentProps } from './TanstackLinks'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export const AsButtonPrimary: StoryObj<TanstackLinkComponentProps> = { | ||
render: () => ( | ||
<TanstackLink linkType="primary" to="/"> | ||
Home | ||
</TanstackLink> | ||
), | ||
}; | ||
|
||
export const AsButtonSecondary: StoryObj<TanstackLinkComponentProps> = { | ||
render: () => ( | ||
<TanstackLink linkType="secondary" to="/"> | ||
Home | ||
</TanstackLink> | ||
), | ||
}; | ||
|
||
export const AsLink: StoryObj<TanstackLinkComponentProps> = { | ||
render: () => ( | ||
<TanstackLink linkType="link" to="/"> | ||
Home | ||
</TanstackLink> | ||
), | ||
}; | ||
|
||
const meta: Meta<TanstackLinkComponentProps> = { | ||
parameters: { | ||
tanStackRouter: true, | ||
}, | ||
title: 'Foundations/Link/Tanstack Link', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Button } from '@linode/ui'; | ||
import { omitProps } from '@linode/ui'; | ||
import { LinkComponent } from '@tanstack/react-router'; | ||
import { createLink } from '@tanstack/react-router'; | ||
import * as React from 'react'; | ||
|
||
import { MenuItem } from 'src/components/MenuItem'; | ||
|
||
import type { ButtonProps, ButtonType } from '@linode/ui'; | ||
import type { LinkProps as TanStackLinkProps } from '@tanstack/react-router'; | ||
|
||
export interface TanstackLinkComponentProps | ||
extends Omit<ButtonProps, 'buttonType' | 'href'> { | ||
linkType: 'link' | ButtonType; | ||
tooltipAnalyticsEvent?: (() => void) | undefined; | ||
tooltipText?: string; | ||
} | ||
|
||
export interface TanStackLinkRoutingProps { | ||
linkType: TanstackLinkComponentProps['linkType']; | ||
params?: TanStackLinkProps['params']; | ||
preload?: TanStackLinkProps['preload']; | ||
search?: TanStackLinkProps['search']; | ||
to: TanStackLinkProps['to']; | ||
} | ||
|
||
const LinkComponent = React.forwardRef< | ||
HTMLButtonElement, | ||
TanstackLinkComponentProps | ||
>((props, ref) => { | ||
const _props = omitProps(props, ['linkType']); | ||
|
||
return <Button component="a" ref={ref} {..._props} />; | ||
}); | ||
|
||
const MenuItemLinkComponent = React.forwardRef< | ||
HTMLButtonElement, | ||
TanstackLinkComponentProps | ||
>((props, ref) => { | ||
const _props = omitProps(props, ['linkType']); | ||
|
||
return <MenuItem component="a" ref={ref} {..._props} />; | ||
}); | ||
|
||
const CreatedLinkComponent = createLink(LinkComponent); | ||
const CreatedMenuItemLinkComponent = createLink(MenuItemLinkComponent); | ||
|
||
/** | ||
* @deprecated | ||
* This is marked as deprecated to discourage usage until the migration is complete. | ||
* While not technically deprecated, these components should not be used anywhere in the app. | ||
* They will be replacing our Links eventually, but have only been introduced early to test their functionality. | ||
*/ | ||
export const TanstackLink: LinkComponent<typeof LinkComponent> = (props) => { | ||
return ( | ||
<CreatedLinkComponent | ||
{...props} | ||
sx={(theme) => ({ | ||
...(props.linkType === 'link' && { | ||
'&:hover': { | ||
textDecoration: 'underline', | ||
}, | ||
fontFamily: theme.font.normal, | ||
fontSize: '0.875rem', | ||
minWidth: 'initial', | ||
padding: 0, | ||
}), | ||
})} | ||
/> | ||
); | ||
}; | ||
|
||
/** | ||
* @deprecated | ||
* This is marked as deprecated to discourage usage until the migration is complete. | ||
* While not technically deprecated, these components should not be used anywhere in the app. | ||
* They will be replacing our Links eventually, but have only been introduced early to test their functionality. | ||
*/ | ||
export const TanstackMenuItemLink: LinkComponent< | ||
typeof MenuItemLinkComponent | ||
> = (props) => { | ||
return <CreatedMenuItemLinkComponent {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.