Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions apps/dev-playground/client/src/components/error-component.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions apps/dev-playground/client/src/lib/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ServerIcon,
ShieldIcon,
SigmaIcon,
TriangleAlertIcon,
Wand2Icon,
ZapIcon,
} from "lucide-react";
Expand Down Expand Up @@ -194,6 +195,13 @@ export const NAV_GROUPS: ReadonlyArray<NavGroup> = [
"Author UI in variants, pick one live in the browser, and let the agent finalize it into source.",
icon: Wand2Icon,
},
{
to: "/error-page",
label: "Error Page",
description:
"A route that throws, caught by AppKit's ErrorPage instead of the router's default.",
icon: TriangleAlertIcon,
},
],
},
];
Expand Down
21 changes: 21 additions & 0 deletions apps/dev-playground/client/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Route as LakebaseRouteRouteImport } from './routes/lakebase.route'
import { Route as JobsRouteRouteImport } from './routes/jobs.route'
import { Route as GenieRouteRouteImport } from './routes/genie.route'
import { Route as FilesRouteRouteImport } from './routes/files.route'
import { Route as ErrorPageRouteRouteImport } from './routes/error-page.route'
import { Route as DatabaseRouteRouteImport } from './routes/database.route'
import { Route as DataVisualizationRouteRouteImport } from './routes/data-visualization.route'
import { Route as ChartInferenceRouteRouteImport } from './routes/chart-inference.route'
Expand Down Expand Up @@ -102,6 +103,11 @@ const FilesRouteRoute = FilesRouteRouteImport.update({
path: '/files',
getParentRoute: () => rootRouteImport,
} as any)
const ErrorPageRouteRoute = ErrorPageRouteRouteImport.update({
id: '/error-page',
path: '/error-page',
getParentRoute: () => rootRouteImport,
} as any)
const DatabaseRouteRoute = DatabaseRouteRouteImport.update({
id: '/database',
path: '/database',
Expand Down Expand Up @@ -152,6 +158,7 @@ export interface FileRoutesByFullPath {
'/chart-inference': typeof ChartInferenceRouteRoute
'/data-visualization': typeof DataVisualizationRouteRoute
'/database': typeof DatabaseRouteRoute
'/error-page': typeof ErrorPageRouteRoute
'/files': typeof FilesRouteRoute
'/genie': typeof GenieRouteRoute
'/jobs': typeof JobsRouteRoute
Expand All @@ -176,6 +183,7 @@ export interface FileRoutesByTo {
'/chart-inference': typeof ChartInferenceRouteRoute
'/data-visualization': typeof DataVisualizationRouteRoute
'/database': typeof DatabaseRouteRoute
'/error-page': typeof ErrorPageRouteRoute
'/files': typeof FilesRouteRoute
'/genie': typeof GenieRouteRoute
'/jobs': typeof JobsRouteRoute
Expand All @@ -201,6 +209,7 @@ export interface FileRoutesById {
'/chart-inference': typeof ChartInferenceRouteRoute
'/data-visualization': typeof DataVisualizationRouteRoute
'/database': typeof DatabaseRouteRoute
'/error-page': typeof ErrorPageRouteRoute
'/files': typeof FilesRouteRoute
'/genie': typeof GenieRouteRoute
'/jobs': typeof JobsRouteRoute
Expand All @@ -227,6 +236,7 @@ export interface FileRouteTypes {
| '/chart-inference'
| '/data-visualization'
| '/database'
| '/error-page'
| '/files'
| '/genie'
| '/jobs'
Expand All @@ -251,6 +261,7 @@ export interface FileRouteTypes {
| '/chart-inference'
| '/data-visualization'
| '/database'
| '/error-page'
| '/files'
| '/genie'
| '/jobs'
Expand All @@ -275,6 +286,7 @@ export interface FileRouteTypes {
| '/chart-inference'
| '/data-visualization'
| '/database'
| '/error-page'
| '/files'
| '/genie'
| '/jobs'
Expand All @@ -300,6 +312,7 @@ export interface RootRouteChildren {
ChartInferenceRouteRoute: typeof ChartInferenceRouteRoute
DataVisualizationRouteRoute: typeof DataVisualizationRouteRoute
DatabaseRouteRoute: typeof DatabaseRouteRoute
ErrorPageRouteRoute: typeof ErrorPageRouteRoute
FilesRouteRoute: typeof FilesRouteRoute
GenieRouteRoute: typeof GenieRouteRoute
JobsRouteRoute: typeof JobsRouteRoute
Expand Down Expand Up @@ -416,6 +429,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof FilesRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/error-page': {
id: '/error-page'
path: '/error-page'
fullPath: '/error-page'
preLoaderRoute: typeof ErrorPageRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/database': {
id: '/database'
path: '/database'
Expand Down Expand Up @@ -484,6 +504,7 @@ const rootRouteChildren: RootRouteChildren = {
ChartInferenceRouteRoute: ChartInferenceRouteRoute,
DataVisualizationRouteRoute: DataVisualizationRouteRoute,
DatabaseRouteRoute: DatabaseRouteRoute,
ErrorPageRouteRoute: ErrorPageRouteRoute,
FilesRouteRoute: FilesRouteRoute,
GenieRouteRoute: GenieRouteRoute,
JobsRouteRoute: JobsRouteRoute,
Expand Down
10 changes: 8 additions & 2 deletions apps/dev-playground/client/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
ErrorPage,
TooltipProvider,
} from "@databricks/appkit-ui/react";
import {
Expand All @@ -19,7 +20,6 @@ import {
} from "@tanstack/react-router";
import { MenuIcon } from "lucide-react";

import { ErrorComponent } from "@/components/error-component";
import { ThemeSelector } from "@/components/theme-selector";
import { findNavItemForPath, NAV_GROUPS } from "@/lib/nav";

Expand Down Expand Up @@ -122,7 +122,13 @@ function RootComponent() {
onCatch={(error) => {
console.error(error);
}}
errorComponent={(error) => <ErrorComponent error={error} />}
errorComponent={({ error }) => (
// The router's link: going home keeps the app's providers (no page load).
<ErrorPage
error={error}
homeLink={<Link to="/">Back to home</Link>}
/>
)}
>
<Outlet />
</CatchBoundary>
Expand Down
10 changes: 10 additions & 0 deletions apps/dev-playground/client/src/routes/error-page.route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/error-page")({
component: ErrorPageRoute,
});

// Throws on render: the CatchBoundary in __root.tsx shows AppKit's ErrorPage.
function ErrorPageRoute(): never {
throw new Error("This route throws on purpose, to show AppKit's error page.");
}
31 changes: 31 additions & 0 deletions apps/dev-playground/tests/error-page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { expect, test } from "@playwright/test";

import { setupMockAPI } from "./utils/test-utils";

test.describe("Error Page Route Tests", () => {
test.beforeEach(async ({ page }) => {
await setupMockAPI(page);
await page.goto("/error-page", { waitUntil: "networkidle" });
});

test("a route that throws shows AppKit's error page inside the layout", async ({
page,
}) => {
await expect(page.getByText("Something went wrong")).toBeVisible();
await expect(page.getByText("Unexpected Application Error")).toHaveCount(0);
await expect(page.getByRole("button", { name: "Reload" })).toBeVisible();
await expect(
page.getByRole("link", { name: "Back to home" }),
).toHaveAttribute("href", "/");
await expect(
page.getByRole("heading", { name: "AppKit Playground" }),
).toBeVisible();
});

test("shows the thrown error's message in development", async ({ page }) => {
// The suite runs against `pnpm dev`: details show only in development.
await expect(
page.getByText("This route throws on purpose", { exact: false }),
).toBeVisible();
});
});
62 changes: 62 additions & 0 deletions docs/docs/api/appkit-ui/error-page.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/static/appkit-ui/styles.gen.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
--container-sm: 24rem;
--container-md: 28rem;
--container-lg: 32rem;
--container-2xl: 42rem;
--text-xs: 0.75rem;
--text-xs--line-height: calc(1 / 0.75);
--text-sm: 0.875rem;
Expand Down Expand Up @@ -852,6 +853,9 @@
.max-w-\(--skeleton-width\) {
max-width: var(--skeleton-width);
}
.max-w-2xl {
max-width: var(--container-2xl);
}
.max-w-\[80\%\] {
max-width: 80%;
}
Expand Down
1 change: 1 addition & 0 deletions packages/appkit-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"@types/react-dom": "19.2.2",
"react": "19.2.0",
"react-dom": "19.2.0",
"react-router": "7.18.0",
"tailwindcss": "4.1.17",
"tw-animate-css": "1.4.0"
},
Expand Down
Loading
Loading