Skip to content

Commit 59ae223

Browse files
committed
feat(FR-2521): add Suspense skeleton fallback to all lazy-loaded pages
1 parent 2ab8e80 commit 59ae223

1 file changed

Lines changed: 90 additions & 20 deletions

File tree

react/src/routes.tsx

Lines changed: 90 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ export const mainLayoutChildRoutes: RouteObject[] = [
146146
},
147147
{
148148
path: '/start',
149-
element: <StartPage />,
149+
element: (
150+
<Suspense fallback={<Skeleton active />}>
151+
<StartPage />
152+
</Suspense>
153+
),
150154
handle: { labelKey: 'webui.menu.Start' },
151155
},
152156
{
@@ -348,12 +352,20 @@ export const mainLayoutChildRoutes: RouteObject[] = [
348352
},
349353
{
350354
path: '/my-environment',
351-
element: <MyEnvironmentPage />,
355+
element: (
356+
<Suspense fallback={<Skeleton active />}>
357+
<MyEnvironmentPage />
358+
</Suspense>
359+
),
352360
handle: { labelKey: 'webui.menu.MyEnvironments' },
353361
},
354362
{
355363
path: '/agent-summary',
356-
element: <AgentSummaryPage />,
364+
element: (
365+
<Suspense fallback={<Skeleton active />}>
366+
<AgentSummaryPage />
367+
</Suspense>
368+
),
357369
handle: { labelKey: 'webui.menu.AgentSummary' },
358370
},
359371
{
@@ -377,7 +389,11 @@ export const mainLayoutChildRoutes: RouteObject[] = [
377389
{
378390
path: '/admin-session',
379391
handle: { labelKey: 'webui.menu.Sessions' },
380-
Component: AdminSessionPage,
392+
element: (
393+
<Suspense fallback={<Skeleton active />}>
394+
<AdminSessionPage />
395+
</Suspense>
396+
),
381397
},
382398
{
383399
path: '/admin-serving',
@@ -424,7 +440,11 @@ export const mainLayoutChildRoutes: RouteObject[] = [
424440
{
425441
path: '/environment',
426442
handle: { labelKey: 'webui.menu.Environments' },
427-
Component: EnvironmentPage,
443+
element: (
444+
<Suspense fallback={<Skeleton active />}>
445+
<EnvironmentPage />
446+
</Suspense>
447+
),
428448
},
429449
{
430450
path: '/scheduler',
@@ -444,12 +464,20 @@ export const mainLayoutChildRoutes: RouteObject[] = [
444464
{
445465
path: '/agent',
446466
handle: { labelKey: 'webui.menu.Resources' },
447-
Component: ResourcesPage,
467+
element: (
468+
<Suspense fallback={<Skeleton active />}>
469+
<ResourcesPage />
470+
</Suspense>
471+
),
448472
},
449473
{
450474
path: '/resource-policy',
451475
handle: { labelKey: 'webui.menu.ResourcePolicies' },
452-
Component: ResourcePolicyPage,
476+
element: (
477+
<Suspense fallback={<Skeleton active />}>
478+
<ResourcePolicyPage />
479+
</Suspense>
480+
),
453481
},
454482
{
455483
path: '/reservoir',
@@ -492,17 +520,29 @@ export const mainLayoutChildRoutes: RouteObject[] = [
492520
},
493521
{
494522
path: '/settings',
495-
element: <ConfigurationsPage />,
523+
element: (
524+
<Suspense fallback={<Skeleton active />}>
525+
<ConfigurationsPage />
526+
</Suspense>
527+
),
496528
handle: { labelKey: 'webui.menu.Configurations' },
497529
},
498530
{
499531
path: '/maintenance',
500-
element: <MaintenancePage />,
532+
element: (
533+
<Suspense fallback={<Skeleton active />}>
534+
<MaintenancePage />
535+
</Suspense>
536+
),
501537
handle: { labelKey: 'webui.menu.Maintenance' },
502538
},
503539
{
504540
path: '/diagnostics',
505-
element: <DiagnosticsPage />,
541+
element: (
542+
<Suspense fallback={<Skeleton active />}>
543+
<DiagnosticsPage />
544+
</Suspense>
545+
),
506546
handle: { labelKey: 'webui.menu.Diagnostics' },
507547
},
508548
{
@@ -521,7 +561,11 @@ export const mainLayoutChildRoutes: RouteObject[] = [
521561
},
522562
{
523563
path: '/branding',
524-
element: <BrandingPage />,
564+
element: (
565+
<Suspense fallback={<Skeleton active />}>
566+
<BrandingPage />
567+
</Suspense>
568+
),
525569
handle: { labelKey: 'webui.menu.Branding' },
526570
},
527571
{
@@ -538,17 +582,29 @@ export const mainLayoutChildRoutes: RouteObject[] = [
538582
{
539583
path: '/storage-settings/:hostname',
540584
handle: { labelKey: 'storageHost.StorageSetting' },
541-
Component: StorageHostSettingPage,
585+
element: (
586+
<Suspense fallback={<Skeleton active />}>
587+
<StorageHostSettingPage />
588+
</Suspense>
589+
),
542590
},
543591
{
544592
path: '/information',
545593
handle: { labelKey: 'webui.menu.Information' },
546-
Component: Information,
594+
element: (
595+
<Suspense fallback={<Skeleton active />}>
596+
<Information />
597+
</Suspense>
598+
),
547599
},
548600
{
549601
path: '/usersettings',
550602
handle: { labelKey: 'webui.menu.Settings&Logs' },
551-
Component: UserSettingsPage,
603+
element: (
604+
<Suspense fallback={<Skeleton active />}>
605+
<UserSettingsPage />
606+
</Suspense>
607+
),
552608
},
553609
{
554610
path: '/admin-dashboard',
@@ -566,7 +622,11 @@ export const mainLayoutChildRoutes: RouteObject[] = [
566622
{
567623
path: '/credential',
568624
handle: { labelKey: 'webui.menu.UserCredentials&Policies' },
569-
Component: UserCredentialsPage,
625+
element: (
626+
<Suspense fallback={<Skeleton active />}>
627+
<UserCredentialsPage />
628+
</Suspense>
629+
),
570630
},
571631
{
572632
path: '/logs',
@@ -627,7 +687,9 @@ export const routes: RouteObject[] = [
627687
<LoginView />
628688
</Suspense>
629689
<LogoutEventHandler />
630-
<InteractiveLoginPage />
690+
<Suspense fallback={<Skeleton active />}>
691+
<InteractiveLoginPage />
692+
</Suspense>
631693
</DefaultProvidersForReactRoot>
632694
</BAIErrorBoundary>
633695
),
@@ -638,7 +700,9 @@ export const routes: RouteObject[] = [
638700
element: (
639701
<BAIErrorBoundary>
640702
<DefaultProvidersForReactRoot>
641-
<EmailVerificationPage />
703+
<Suspense fallback={<Skeleton active />}>
704+
<EmailVerificationPage />
705+
</Suspense>
642706
</DefaultProvidersForReactRoot>
643707
</BAIErrorBoundary>
644708
),
@@ -649,7 +713,9 @@ export const routes: RouteObject[] = [
649713
element: (
650714
<BAIErrorBoundary>
651715
<DefaultProvidersForReactRoot>
652-
<ChangePasswordPage />
716+
<Suspense fallback={<Skeleton active />}>
717+
<ChangePasswordPage />
718+
</Suspense>
653719
</DefaultProvidersForReactRoot>
654720
</BAIErrorBoundary>
655721
),
@@ -660,7 +726,9 @@ export const routes: RouteObject[] = [
660726
element: (
661727
<BAIErrorBoundary>
662728
<DefaultProvidersForReactRoot>
663-
<EduAppLauncherPage />
729+
<Suspense fallback={<Skeleton active />}>
730+
<EduAppLauncherPage />
731+
</Suspense>
664732
</DefaultProvidersForReactRoot>
665733
</BAIErrorBoundary>
666734
),
@@ -671,7 +739,9 @@ export const routes: RouteObject[] = [
671739
element: (
672740
<BAIErrorBoundary>
673741
<DefaultProvidersForReactRoot>
674-
<EduAppLauncherPage />
742+
<Suspense fallback={<Skeleton active />}>
743+
<EduAppLauncherPage />
744+
</Suspense>
675745
</DefaultProvidersForReactRoot>
676746
</BAIErrorBoundary>
677747
),

0 commit comments

Comments
 (0)