Skip to content

Commit

Permalink
only-export-components fro routes
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly-akamai committed Oct 22, 2024
1 parent 8b9d956 commit 92a3aa7
Show file tree
Hide file tree
Showing 49 changed files with 456 additions and 367 deletions.
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
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';

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 { createRoute } from '@tanstack/react-router';

import { rootRoute } from '../root';
import { AccountRoutes } from './index';

const accountRoute = createRoute({
component: AccountRoutes,
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/routes/account/index.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 AccountRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Account" />
<Outlet />
</React.Suspense>
);
};
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 BetaRoutes = () => {
const flags = useFlags();
const { selfServeBetas } = flags;
return (
<React.Suspense fallback={<SuspenseLoader />}>
{selfServeBetas ? <Outlet /> : <NotFound />}
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import { Outlet, createRoute } from '@tanstack/react-router';
import React from 'react';
import { createRoute } from '@tanstack/react-router';

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

import { rootRoute } from './root';

export const BetaRoutes = () => {
const flags = useFlags();
const { selfServeBetas } = flags;
return (
<React.Suspense fallback={<SuspenseLoader />}>
{selfServeBetas ? <Outlet /> : <NotFound />}
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { BetaRoutes } from './BetasRoute';

const betaRoute = createRoute({
component: BetaRoutes,
Expand Down
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 CloudPulseRoutes = () => {
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 { CloudPulseRoutes } from './CloudPulseRoute';

const cloudPulseRoute = createRoute({
component: CloudPulseRoutes,
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 DatabasesRoutes = () => {
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,21 +1,7 @@
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 { DatabasesRoutes } from './DatabasesRoute';

const databasesRoute = createRoute({
component: DatabasesRoutes,
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 DomainsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Domains" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
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 { DomainsRoutes } from './DomainsRoute';

const domainsRoute = createRoute({
component: DomainsRoutes,
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 EventsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
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 { EventsRoutes } from './EventsRoute';

const eventsRoute = createRoute({
component: EventsRoutes,
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 FirewallsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Firewalls" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
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 FirewallsRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Firewalls" />
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { FirewallsRoutes } from './FirewallsRoute';

const firewallsRoute = createRoute({
component: FirewallsRoutes,
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/routes/images/ImagesRoute.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 ImagesRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Images" />
<Outlet />
</React.Suspense>
);
};
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
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 ImagesRoutes = () => {
return (
<React.Suspense fallback={<SuspenseLoader />}>
<ProductInformationBanner bannerLocation="Images" />
<Outlet />
</React.Suspense>
);
};
import { rootRoute } from '../root';
import { ImagesRoutes } from './ImagesRoute';

const imagesRoute = createRoute({
component: ImagesRoutes,
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

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

import { accountRouteTree } from './account';
import { accountRouteTree } from './account/AccountRoute';
import { betaRouteTree } from './betas';
import { cloudPulseRouteTree } from './cloudPulse';
import { databasesRouteTree } from './databases';
Expand All @@ -16,7 +16,7 @@ import { linodesRouteTree } from './linodes';
import { longviewRouteTree } from './longview';
import { managedRouteTree } from './managed';
import { nodeBalancersRouteTree } from './nodeBalancers';
import { objectStorageRouteTree } from './object-storage';
import { objectStorageRouteTree } from './objectStorage';
import { placementGroupsRouteTree } from './placementGroups';
import { profileRouteTree } from './profile';
import { migrationRootRoute, rootRoute } from './root';
Expand Down
Loading

0 comments on commit 92a3aa7

Please sign in to comment.