Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 1 | import { data } from "react-router"; |
| 2 | ||
| 3 | import type { Route } from "./+types/tab-soon"; | |
| 4 | import { page } from "../../lib/meta"; | |
| 5 | import { roadmapItem } from "../../lib/roadmap"; | |
| 6 | import { getViewer, roleIn } from "../../lib/session.server"; | |
| 7 | import { SoonView } from "../repo/soon"; | |
| 8 | ||
| 9 | /** The tab is the last part of the address: `-/teams` or `-/insights`. */ | |
| 10 | const tabOf = (pathname: string) => pathname.replace(/\/+$/, "").split("/").pop() ?? ""; | |
| 11 | ||
| 12 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 13 | const item = roadmapItem(tabOf(args.location.pathname)); | |
| 14 | return page(args, { | |
| 15 | title: `${item?.title ?? "Soon"} · ${params.owner} · g1t`, | |
| 16 | description: item ? `Soon on g1t: ${item.summary}` : null, | |
| 17 | }); | |
| 18 | } | |
| 19 | ||
| 20 | export function loader({ params, context, request }: Route.LoaderArgs) { | |
| 21 | // For the workspace's members, as their tabs are. | |
| 22 | if (!roleIn(getViewer(context), params.owner)) throw data(null, { status: 404 }); | |
| 23 | const item = roadmapItem(tabOf(new URL(request.url).pathname)); | |
| 24 | if (!item || item.section !== "Workspace") throw data(null, { status: 404 }); | |
| 25 | return { item }; | |
| 26 | } | |
| 27 | ||
| 28 | /** A tab of the workspace's page that is coming: Teams, Insights. */ | |
| 29 | export default function WorkspaceTabSoon({ loaderData, params }: Route.ComponentProps) { | |
| 30 | return <SoonView item={loaderData.item} base={`/${params.owner}/-`} newProject={`/new?workspace=${params.owner}`} />; | |
| 31 | } |