import { Link } from '@tanstack/react-router' import { useParams } from 'common' import { ReactNode } from 'react' import { BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbSeparator, cn } from 'ui' import { PageBreadcrumbs } from 'ui-patterns/PageBreadcrumbs' import { PageContainer } from 'ui-patterns/PageContainer' import { PageHeader, PageHeaderDescription, PageHeaderIcon, PageHeaderMeta, PageHeaderSummary, PageHeaderTitle, } from 'ui-patterns/PageHeader' import { PageNav } from 'ui-patterns/PageNav' import { PageSection, PageSectionContent, PageSectionDescription, PageSectionMeta, PageSectionSummary, PageSectionTitle, } from 'ui-patterns/PageSection' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { PRODUCT_NAME } from '@/lib/constants/compute' // Widths roughly follow the Overview, Invocations, Logs and Activity tab labels const TAB_WIDTHS = ['w-16', 'w-20', 'w-8', 'w-14'] // Widths roughly follow the Instances, Live, Ready and Stale counts const INSTANCE_COUNT_WIDTHS = ['w-20', 'w-10', 'w-12', 'w-12'] // Label and value widths for the Runtime, Version, Base image, Entrypoint and Listening port rows const CONTAINER_ROW_WIDTHS: [string, string][] = [ ['w-16', 'w-16'], ['w-14', 'w-12'], ['w-20', 'w-40'], ['w-20', 'w-32'], ['w-24', 'w-24'], ] // Label and value widths for the Size, Instances, Access and Region rows const RESOURCE_ROW_WIDTHS: [string, string][] = [ ['w-10', 'w-24'], ['w-16', 'w-6'], ['w-14', 'w-14'], ['w-14', 'w-36'], ] const TextLoader = ({ className, height = 'h-5' }: { className: string; height?: string }) => ( ) interface ComputeInstanceDetailSkeletonProps { children: ReactNode } /** * Mirrors the breadcrumbs, header and tabs of `ComputeInstanceDetail` while the instance loads. * Pass the placeholder for the active tab as children. */ export const ComputeInstanceDetailSkeleton = ({ children }: ComputeInstanceDetailSkeletonProps) => { const { ref: projectRef } = useParams() return (
{PRODUCT_NAME} Loading instance
{TAB_WIDTHS.map((width, index) => ( ))}
{children}
) } const SettingsRowSkeleton = ({ labelWidth, valueWidth, isFirst, }: { labelWidth: string valueWidth: string isFirst?: boolean }) => (
) /** * Mirrors the Instances, Container and Resources sections of `ComputeInstanceOverviewTab`. */ export const ComputeInstanceOverviewTabSkeleton = () => ( Instances
{INSTANCE_COUNT_WIDTHS.map((width, index) => (
))}
Container The runtime image and entrypoint resolved for this instance.
{CONTAINER_ROW_WIDTHS.map(([labelWidth, valueWidth], index) => ( ))}
Resources
{RESOURCE_ROW_WIDTHS.map(([labelWidth, valueWidth], index) => ( ))}
)