Skip to content

Commit 4cfaa72

Browse files
committed
skeleton, html cache
1 parent 1ef0be1 commit 4cfaa72

File tree

9 files changed

+84
-6
lines changed

9 files changed

+84
-6
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { Card, CardContent, CardHeader } from '@/components/ui/card'
2+
import { Skeleton } from '@/components/ui/skeleton'
3+
4+
export function TableSkeleton({ rows = 5 }: { rows?: number }) {
5+
return (
6+
<Card>
7+
<CardHeader>
8+
<Skeleton className="h-6 w-48" />
9+
<Skeleton className="h-4 w-96 mt-2" />
10+
</CardHeader>
11+
<CardContent>
12+
<div className="space-y-3">
13+
{Array.from({ length: rows }).map((_, i) => (
14+
<div key={i} className="flex gap-4">
15+
<Skeleton className="h-12 w-full" />
16+
</div>
17+
))}
18+
</div>
19+
</CardContent>
20+
</Card>
21+
)
22+
}
23+
24+
export function DetailsSkeleton() {
25+
return (
26+
<div className="space-y-6">
27+
<Card>
28+
<CardHeader>
29+
<Skeleton className="h-8 w-64" />
30+
<Skeleton className="h-4 w-96 mt-2" />
31+
</CardHeader>
32+
<CardContent>
33+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
34+
{Array.from({ length: 4 }).map((_, i) => (
35+
<Skeleton key={i} className="h-16 w-full" />
36+
))}
37+
</div>
38+
</CardContent>
39+
</Card>
40+
41+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
42+
{Array.from({ length: 3 }).map((_, i) => (
43+
<Skeleton key={i} className="h-24 w-full" />
44+
))}
45+
</div>
46+
</div>
47+
)
48+
}
49+
50+
export function PageLoading() {
51+
return (
52+
<div className="container mx-auto p-4">
53+
<Skeleton className="h-10 w-32 mb-6" />
54+
<TableSkeleton />
55+
</div>
56+
)
57+
}
58+

ui/src/routes/__root.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import radixCssUrl from '@radix-ui/themes/styles.css?url';
22
import workosWidgetsCssUrl from '@workos-inc/widgets/styles.css?url';
3-
import { HeadContent, Link, Outlet, Scripts, createRootRoute } from '@tanstack/react-router';
3+
import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/react-router';
44
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools';
55
import { Suspense } from 'react';
6-
import { getAuth, getOrganisationDetails, getSignInUrl, signOut } from '@/authkit/serverFunctions';
7-
import Footer from '@/components/footer';
8-
import SignInButton from '@/components/sign-in-button';
6+
import { getAuth, getOrganisationDetails, getSignInUrl } from '@/authkit/serverFunctions';
97
import type { ReactNode } from 'react';
10-
import { Sidebar, SidebarMenuButton, SidebarGroupContent, SidebarGroupLabel, SidebarGroup, SidebarContent, SidebarHeader, SidebarTrigger, SidebarProvider, SidebarMenu, SidebarMenuItem } from '../components/ui/sidebar';
11-
import { GitBranch, Folders, Waves, Settings, CreditCard, LogOut } from 'lucide-react';
128
import globalCssUrl from '@/styles/global.css?url'
139
import { Toaster } from '@/components/ui/toaster';
1410
import { getPublicServerConfig, type Env } from '@/lib/env.server';

ui/src/routes/_authenticated/_dashboard/dashboard/drift.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import { useToast } from '@/hooks/use-toast'
1212
import { getOrgSettingsFn, updateOrgSettingsFn } from '@/api/orchestrator_serverFunctions'
1313
import { testSlackWebhookFn } from '@/api/drift_serverFunctions'
1414
import { ToastAction } from '@/components/ui/toast'
15+
import { PageLoading } from '@/components/LoadingSkeleton'
1516

1617

1718
export const Route = createFileRoute(
1819
'/_authenticated/_dashboard/dashboard/drift',
1920
)({
2021
component: RouteComponent,
22+
pendingComponent: PageLoading,
2123
loader: async ({ context }) => {
2224
const { user, organisationId } = context;
2325
const settings = await getOrgSettingsFn({data: {userId: user?.id || '', organisationId: organisationId || ''}})

ui/src/routes/_authenticated/_dashboard/dashboard/projects.$projectid.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createFileRoute, useLoaderData, Link } from '@tanstack/react-router'
44
import { AlertTriangle, CheckCircle, Clock, FolderOpen, GitBranch, Calendar, ArrowLeft } from 'lucide-react'
55
import { getProjectFn } from '@/api/orchestrator_serverFunctions'
66
import { Button } from '@/components/ui/button'
7+
import { DetailsSkeleton } from '@/components/LoadingSkeleton'
78

89
const getDriftStatusBadge = (status: string) => {
910
switch (status?.toLowerCase()) {
@@ -37,6 +38,12 @@ export const Route = createFileRoute(
3738
'/_authenticated/_dashboard/dashboard/projects/$projectid',
3839
)({
3940
component: RouteComponent,
41+
pendingComponent: () => (
42+
<div className="container mx-auto p-4">
43+
<div className="mb-6"><div className="h-10 w-32" /></div>
44+
<DetailsSkeleton />
45+
</div>
46+
),
4047
loader: async ({ context, params: {projectid} }) => {
4148
const { user, organisationId } = context;
4249
const project = await getProjectFn({data: {projectId: projectid, organisationId, userId: user?.id || ''}})

ui/src/routes/_authenticated/_dashboard/dashboard/projects.index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/com
88
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
99
import { Button } from '@/components/ui/button'
1010
import { ArrowLeft, ExternalLink } from 'lucide-react'
11+
import { PageLoading } from '@/components/LoadingSkeleton'
1112

1213

1314
export const Route = createFileRoute(
1415
'/_authenticated/_dashboard/dashboard/projects/',
1516
)({
1617
component: RouteComponent,
18+
pendingComponent: PageLoading,
1719
loader: async ({ context }) => {
1820
const { user, organisationId } = context;
1921
try {

ui/src/routes/_authenticated/_dashboard/dashboard/repos.$repoId.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { Button } from '@/components/ui/button'
55
import { ArrowLeft } from 'lucide-react'
66
import JobsTable from '@/components/dashboard/JobsTable'
77
import { getRepoDetailsFn } from '@/api/orchestrator_serverFunctions'
8+
import { PageLoading } from '@/components/LoadingSkeleton'
89

910
export const Route = createFileRoute('/_authenticated/_dashboard/dashboard/repos/$repoId')({
1011
component: RouteComponent,
12+
pendingComponent: PageLoading,
1113
loader: async ({ params: {repoId}, context }) => {
1214
const { user, organisationId } = context;
1315
const { repo, allJobs } = await getRepoDetailsFn({data: {repoId, organisationId, userId: user?.id || ''}})

ui/src/routes/_authenticated/_dashboard/dashboard/repos.index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { createFileRoute, Link, Outlet } from '@tanstack/react-router'
55
import { ArrowLeft, Github, Gitlab, GithubIcon as Bitbucket, ExternalLink, PlusCircle } from "lucide-react"
66
import { getReposFn } from '@/api/orchestrator_serverFunctions'
77
import { Repo } from '@/api/orchestrator_types'
8+
import { PageLoading } from '@/components/LoadingSkeleton'
89

910

1011
export const Route = createFileRoute('/_authenticated/_dashboard/dashboard/repos/')({
1112
component: RouteComponent,
13+
pendingComponent: PageLoading,
1214
loader: async ({ context }) => {
1315
const { user, organisationId } = context;
1416
const repos = await getReposFn({data: {organisationId, userId: user?.id || ''}})

ui/src/routes/_authenticated/_dashboard/dashboard/units.$unitId.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { toast } from '@/hooks/use-toast'
2828
import { getUnitFn, getUnitVersionsFn, lockUnitFn, unlockUnitFn, getUnitStatusFn, deleteUnitFn, downloadLatestStateFn, restoreUnitStateVersionFn } from '@/api/statesman_serverFunctions'
2929
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
3030
import { getPublicServerConfig } from '@/lib/env.server'
31+
import { DetailsSkeleton } from '@/components/LoadingSkeleton'
3132
import type { Env } from '@/lib/env.server'
3233
import { downloadJson } from '@/lib/io'
3334

@@ -75,6 +76,12 @@ export const Route = createFileRoute(
7576
'/_authenticated/_dashboard/dashboard/units/$unitId',
7677
)({
7778
component: RouteComponent,
79+
pendingComponent: () => (
80+
<div className="container mx-auto p-4">
81+
<div className="mb-6"><div className="h-10 w-32" /></div>
82+
<DetailsSkeleton />
83+
</div>
84+
),
7885
loader: async ({ context, params: {unitId} }) => {
7986
const { user, organisationId, organisationName } = context;
8087

ui/src/routes/_authenticated/_dashboard/dashboard/units.index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import {
2323
import { useState } from "react"
2424
import UnitCreateForm from "@/components/UnitCreateForm"
2525
import { listUnitsFn } from '@/api/statesman_serverFunctions'
26+
import { PageLoading } from '@/components/LoadingSkeleton'
2627

2728
export const Route = createFileRoute(
2829
'/_authenticated/_dashboard/dashboard/units/',
2930
)({
3031
component: RouteComponent,
32+
pendingComponent: PageLoading,
3133
loader: async ({ context }) => {
3234
const { user, organisationId } = context;
3335
const unitsData = await listUnitsFn({data: {organisationId: organisationId || '', userId: user?.id || '', email: user?.email || ''}})

0 commit comments

Comments
 (0)