Skip to content

Commit

Permalink
feat: add lazy loading to all routes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroPP committed Jan 24, 2025
1 parent d448d5d commit 51ca090
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { createBrowserRouter } from 'react-router-dom';
import { AppRoot } from '../AppRoot/AppRoot';
import { GithubRedirect, githubRedirectLoader } from '../components/GithubRedirect';
import { ModalProvider } from '../components/modal/ModalProvider';
import {
ReleaseDetailsLayout,
releaseDetailsViewLoader,
ReleaseListViewTab,
releaseListViewTabLoader,
ReleaseOverviewTab,
} from '../components/Releases';
import { workspaceLoader, WorkspaceProvider } from '../components/Workspace';
import { HttpError } from '../k8s/error';
import ErrorEmptyState from '../shared/components/empty-state/ErrorEmptyState';
Expand Down Expand Up @@ -105,9 +97,13 @@ export const router = createBrowserRouter([
},
{
path: 'releases',
loader: releaseListViewTabLoader,
errorElement: <RouteErrorBoundry />,
element: <ReleaseListViewTab />,
async lazy() {
const { ReleaseListViewTab, releaseListViewTabLoader } = await import(
'../components/Releases'
);
return { Component: ReleaseListViewTab, loader: releaseListViewTabLoader };

Check warning on line 105 in src/routes/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/routes/index.tsx#L103-L105

Added lines #L103 - L105 were not covered by tests
},
},
],
},
Expand Down Expand Up @@ -211,13 +207,20 @@ export const router = createBrowserRouter([
{
// details page
path: `/workspaces/:${RouterParams.workspaceName}/applications/:${RouterParams.applicationName}/releases/:${RouterParams.releaseName}`,
loader: releaseDetailsViewLoader,
errorElement: <RouteErrorBoundry />,
element: <ReleaseDetailsLayout />,
async lazy() {
const { ReleaseDetailsLayout, releaseDetailsViewLoader } = await import(
'../components/Releases'

Check warning on line 213 in src/routes/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/routes/index.tsx#L211-L213

Added lines #L211 - L213 were not covered by tests
);
return { Component: ReleaseDetailsLayout, loader: releaseDetailsViewLoader };
},
children: [
{
index: true,
element: <ReleaseOverviewTab />,
async lazy() {
const { ReleaseOverviewTab } = await import('../components/Releases');
return { Component: ReleaseOverviewTab };
},
},
],
},
Expand Down Expand Up @@ -494,9 +497,13 @@ export const router = createBrowserRouter([
/* Github Redirects */
{
path: `/ns/:${GithubRedirectRouteParams.ns}/pipelinerun?/:${GithubRedirectRouteParams.pipelineRunName}?/logs?/:${GithubRedirectRouteParams.taskName}?`,
element: <GithubRedirect />,
loader: githubRedirectLoader,
errorElement: <RouteErrorBoundry />,
async lazy() {
const { GithubRedirect, githubRedirectLoader } = await import(

Check warning on line 502 in src/routes/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/routes/index.tsx#L501-L502

Added lines #L501 - L502 were not covered by tests
'../components/GithubRedirect'
);
return { Component: GithubRedirect, loader: githubRedirectLoader };
},
},
],
},
Expand Down

0 comments on commit 51ca090

Please sign in to comment.