-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Migrate web UI to TanStack Router #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
663b0cb
041833a
0aaa0c1
f91ff23
db957b3
d4908f7
3b7d776
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { QueryClient } from "@tanstack/react-query"; | ||
| import { createRootRouteWithContext, Outlet, redirect } from "@tanstack/react-router"; | ||
|
|
||
| export const Route = createRootRouteWithContext<{ | ||
| queryClient: QueryClient; | ||
| }>()({ | ||
| beforeLoad: ({ location }) => { | ||
| if (location.hash.startsWith("#/runs/")) { | ||
| throw redirect({ | ||
| to: location.hash.slice(1), | ||
| replace: true, | ||
| }); | ||
| } | ||
| }, | ||
| component: RootLayout, | ||
| }); | ||
|
|
||
| function RootLayout() { | ||
| return ( | ||
| <div className="flex min-h-screen flex-col bg-background text-foreground"> | ||
| <Outlet /> | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { Topbar } from "@/components/layout/topbar"; | ||
|
|
||
| export const Route = createFileRoute("/")({ | ||
| component: NoRunSelected, | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Legacy hash URL redirect is missingMedium Severity The PR description states it preserves "a legacy Additional Locations (1)Reviewed by Cursor Bugbot for commit db957b3. Configure here. |
||
|
|
||
| function NoRunSelected() { | ||
| return ( | ||
| <> | ||
| <Topbar runId={null} /> | ||
| <div className="flex flex-1 items-center justify-center p-6"> | ||
| <div className="max-w-md text-center"> | ||
| <h1 className="font-semibold text-lg">No run selected</h1> | ||
| <p className="mt-2 text-muted-foreground text-sm"> | ||
| The URL is missing a <code>/runs/<runId></code> path. Open the app via{" "} | ||
| <code>stage-cli show <path></code>. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { FilesPage } from "@/routes/files-page"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId/files")({ | ||
| component: FilesRoute, | ||
| }); | ||
|
|
||
| function FilesRoute() { | ||
| const { runId } = Route.useParams(); | ||
| return <FilesPage runId={runId} />; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { useMemo } from "react"; | ||
| import { useChapters } from "@/lib/use-chapters"; | ||
| import { useViewStateData } from "@/lib/use-view-state"; | ||
| import { ChaptersIndexPage } from "@/routes/chapters-index-page"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId/")({ | ||
| component: ChaptersRoute, | ||
| }); | ||
|
|
||
| function ChaptersRoute() { | ||
| const { runId } = Route.useParams(); | ||
| const { data, isLoading } = useChapters(runId); | ||
| const { chapterIdSet } = useViewStateData(runId); | ||
| const chapters = data?.chapters; | ||
| const viewedCount = useMemo(() => { | ||
| if (!chapters) return 0; | ||
| let n = 0; | ||
| for (const chapter of chapters) if (chapterIdSet.has(chapter.externalId)) n++; | ||
| return n; | ||
| }, [chapters, chapterIdSet]); | ||
|
dastratakos marked this conversation as resolved.
Outdated
cursor[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| return ( | ||
| <ChaptersIndexPage | ||
| chapters={chapters} | ||
| runId={runId} | ||
| viewedCount={viewedCount} | ||
| isLoading={isLoading} | ||
| /> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { Topbar } from "@/components/layout/topbar"; | ||
| import { PullRequestLayout } from "@/routes/pull-request-layout"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId")({ | ||
| component: RunLayout, | ||
| }); | ||
|
|
||
| function RunLayout() { | ||
| const { runId } = Route.useParams(); | ||
| return ( | ||
| <> | ||
| <Topbar runId={runId} /> | ||
| <PullRequestLayout runId={runId} /> | ||
| </> | ||
| ); | ||
| } |
This file was deleted.
This file was deleted.


Uh oh!
There was an error while loading. Please reload this page.