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-8762] - only-export-components for Tanstack routes #11142

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

`only-export-components` for Tanstack routes ([#11142](https://github.com/linode/manager/pull/11142))
2 changes: 2 additions & 0 deletions packages/manager/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ module.exports = {
'xss',
'perfectionist',
'@linode/eslint-plugin-cloud-manager',
'react-refresh',
],
rules: {
'@linode/cloud-manager/deprecate-formik': 'warn',
Expand Down Expand Up @@ -275,6 +276,7 @@ module.exports = {
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-refresh/only-export-components': 'warn',
'scanjs-rules/assign_to_hostname': 'warn',
'scanjs-rules/assign_to_href': 'warn',
'scanjs-rules/assign_to_location': 'warn',
Expand Down
1 change: 1 addition & 0 deletions packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"eslint-plugin-ramda": "^2.5.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^3.0.0",
"eslint-plugin-react-refresh": "^0.4.13",
"eslint-plugin-scanjs-rules": "^0.2.1",
"eslint-plugin-sonarjs": "^0.5.0",
"eslint-plugin-testing-library": "^3.1.2",
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/routes/account/AccountRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const AccountRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Account" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';
import { createRoute } from '@tanstack/react-router';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

import { rootRoute } from './root';

export const AccountRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Account" />
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { AccountRoute } from './AccountRoute';

const accountRoute = createRoute({
component: AccountRoutes,
component: AccountRoute,
getParentRoute: () => rootRoute,
path: 'account',
});
Expand Down
43 changes: 0 additions & 43 deletions packages/manager/src/routes/betas.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions packages/manager/src/routes/betas/BetasRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { NotFound } from 'src/components/NotFound';
import { SuspenseLoader } from 'src/components/SuspenseLoader';
import { useFlags } from 'src/hooks/useFlags';

export const BetasRoute = () => {
const flags = useFlags();
const { selfServeBetas } = flags;
return (
<React.Suspense fallback={<SuspenseLoader />}>
{selfServeBetas ? <Outlet /> : <NotFound />}
</React.Suspense>
);
};
29 changes: 29 additions & 0 deletions packages/manager/src/routes/betas/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createRoute } from '@tanstack/react-router';

import { rootRoute } from '../root';
import { BetasRoute } from './BetasRoute';

const betasRoute = createRoute({
component: BetasRoute,
getParentRoute: () => rootRoute,
path: 'betas',
});

const betaLandingRoute = createRoute({
getParentRoute: () => betasRoute,
path: '/',
}).lazy(() =>
import('src/features/Betas/BetasLanding').then((m) => m.betasLandingLazyRoute)
);

const betaSignupRoute = createRoute({
getParentRoute: () => betasRoute,
path: 'signup/$betaId',
}).lazy(() =>
import('src/features/Betas/BetaSignup').then((m) => m.betaSignupLazyRoute)
);

export const betaRouteTree = betasRoute.addChildren([
betaLandingRoute,
betaSignupRoute,
]);
35 changes: 0 additions & 35 deletions packages/manager/src/routes/cloudPulse.tsx

This file was deleted.

14 changes: 14 additions & 0 deletions packages/manager/src/routes/cloudPulse/CloudPulseRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const CloudPulseRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<DocumentTitleSegment segment="Cloud Pulse" />
<Outlet />
</React.Suspense>
);
};
23 changes: 23 additions & 0 deletions packages/manager/src/routes/cloudPulse/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createRoute } from '@tanstack/react-router';

import { rootRoute } from '../root';
import { CloudPulseRoute } from './CloudPulseRoute';

const cloudPulseRoute = createRoute({
component: CloudPulseRoute,
getParentRoute: () => rootRoute,
path: 'monitor/cloudpulse',
});

const cloudPulseLandingRoute = createRoute({
getParentRoute: () => cloudPulseRoute,
path: '/',
}).lazy(() =>
import('src/features/CloudPulse/CloudPulseLanding').then(
(m) => m.cloudPulseLandingLazyRoute
)
);

export const cloudPulseRouteTree = cloudPulseRoute.addChildren([
cloudPulseLandingRoute,
]);
16 changes: 16 additions & 0 deletions packages/manager/src/routes/databases/DatabasesRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const DatabasesRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<DocumentTitleSegment segment="Databases" />
<ProductInformationBanner bannerLocation="Databases" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';
import { createRoute } from '@tanstack/react-router';

import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

import { rootRoute } from './root';

export const DatabasesRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<DocumentTitleSegment segment="Databases" />
<ProductInformationBanner bannerLocation="Databases" />
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { DatabasesRoute } from './DatabasesRoute';

const databasesRoute = createRoute({
component: DatabasesRoutes,
component: DatabasesRoute,
getParentRoute: () => rootRoute,
path: 'databases',
});
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/routes/domains/DomainsRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const DomainsRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Domains" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';
import { createRoute } from '@tanstack/react-router';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

import { rootRoute } from './root';

export const DomainsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Domains" />
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { DomainsRoute } from './DomainsRoute';

const domainsRoute = createRoute({
component: DomainsRoutes,
component: DomainsRoute,
getParentRoute: () => rootRoute,
path: 'domains',
});
Expand Down
12 changes: 12 additions & 0 deletions packages/manager/src/routes/events/EventsRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const EventsRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';
import { createRoute } from '@tanstack/react-router';

import { SuspenseLoader } from 'src/components/SuspenseLoader';

import { rootRoute } from './root';

export const EventsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { EventsRoute } from './EventsRoute';

const eventsRoute = createRoute({
component: EventsRoutes,
component: EventsRoute,
getParentRoute: () => rootRoute,
path: 'events',
});
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/routes/firewalls/FirewallsRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';

export const FirewallsRoute = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Firewalls" />
<Outlet />
</React.Suspense>
);
};
Loading