Customize's pages build for the browser again: the rule for when a page reads its data again moved out of the server-only helpers into its own module, since the site bundles that export for the browser and refused the server import.
7 files+19−120/7 viewed
| 1 | + | /** | |
| 2 | + | * When a Customize page reads its data again: for another page, the other | |
| 3 | + | * view, or a posted form (lib/customize.ts `needsReload`). A route export | |
| 4 | + | * the browser runs, so it lives apart from the server-only helpers. | |
| 5 | + | */ | |
| 6 | + | import type { ShouldRevalidateFunctionArgs } from "react-router"; | |
| 7 | + | ||
| 8 | + | import { needsReload } from "./customize"; | |
| 9 | + | ||
| 10 | + | export function shouldRevalidate({ currentUrl, nextUrl, formMethod, defaultShouldRevalidate }: ShouldRevalidateFunctionArgs): boolean { | |
| 11 | + | return needsReload(currentUrl, nextUrl, formMethod) ? defaultShouldRevalidate : false; | |
| 12 | + | } |
| 4 | 4 | * listing tools again, where it reaches, removing it), and what follows | |
| 5 | 5 | * adding one: the browser goes to sign in, or to the connector's page. | |
| 6 | 6 | */ | |
| 7 | − | import { type ShouldRevalidateFunctionArgs, redirect } from "react-router"; | |
| 7 | + | import { redirect } from "react-router"; | |
| 8 | 8 | ||
| 9 | 9 | import type { ConnectorInput, User, WorkspaceConnector } from "@g1t/contracts"; | |
| 10 | 10 | ||
| 11 | 11 | import { addresses } from "./addresses.server"; | |
| 12 | − | import { connectorCallbackPath, connectorPagePath, needsReload, splitTarget } from "./customize"; | |
| 12 | + | import { connectorCallbackPath, connectorPagePath, splitTarget } from "./customize"; | |
| 13 | 13 | import { workspaceAgents } from "./services.server"; | |
| 14 | 14 | import type { ActionResult } from "../components/agents/dialogs"; | |
| 15 | 15 | import { answer } from "../components/agents/actions.server"; | |
| ⋯ | |||
| 17 | 17 | /** Where a connector's sign-in comes back to: this g1t's own page. */ | |
| 18 | 18 | export function callbackUri(slug: string): string { | |
| 19 | 19 | return `${addresses().site}${connectorCallbackPath(slug)}`; | |
| 20 | − | } | |
| 21 | − | ||
| 22 | − | /** A Customize page reads its data again only for another page, the other view, or a posted form (lib/customize.ts). */ | |
| 23 | − | export function shouldRevalidate({ currentUrl, nextUrl, formMethod, defaultShouldRevalidate }: ShouldRevalidateFunctionArgs): boolean { | |
| 24 | − | return needsReload(currentUrl, nextUrl, formMethod) ? defaultShouldRevalidate : false; | |
| 25 | 20 | } | |
| 26 | 21 | ||
| 27 | 22 | /** The browser leaves for the connector's sign-in page, or lands on the connector's own page with what happened. */ | |
| 36 | 36 | import { skillLibrary, workspaceAgents } from "../../../lib/services.server"; | |
| 37 | 37 | import { requireUser, roleIn } from "../../../lib/session.server"; | |
| 38 | 38 | ||
| 39 | − | export { shouldRevalidate } from "../../../lib/customize.server"; | |
| 39 | + | export { shouldRevalidate } from "../../../lib/customize-revalidate"; | |
| 40 | 40 | ||
| 41 | 41 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 42 | 42 | return page(args, { title: `Connectors · Customize · ${params.owner} · g1t` }); |
| 34 | 34 | import { workspaceAgents } from "../../../lib/services.server"; | |
| 35 | 35 | import { requireUser, roleIn } from "../../../lib/session.server"; | |
| 36 | 36 | ||
| 37 | − | export { shouldRevalidate } from "../../../lib/customize.server"; | |
| 37 | + | export { shouldRevalidate } from "../../../lib/customize-revalidate"; | |
| 38 | 38 | ||
| 39 | 39 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 40 | 40 | return page(args, { title: `Customize · ${params.owner} · g1t` }); |
| 25 | 25 | import { workspaceAgents } from "../../../lib/services.server"; | |
| 26 | 26 | import { requireUser, roleIn } from "../../../lib/session.server"; | |
| 27 | 27 | ||
| 28 | − | export { shouldRevalidate } from "../../../lib/customize.server"; | |
| 28 | + | export { shouldRevalidate } from "../../../lib/customize-revalidate"; | |
| 29 | 29 | ||
| 30 | 30 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 31 | 31 | return page(args, { title: `Marketplaces · Customize · ${params.owner} · g1t` }); |
| 29 | 29 | import { workspaceAgents } from "../../../lib/services.server"; | |
| 30 | 30 | import { requireUser, roleIn } from "../../../lib/session.server"; | |
| 31 | 31 | ||
| 32 | − | export { shouldRevalidate } from "../../../lib/customize.server"; | |
| 32 | + | export { shouldRevalidate } from "../../../lib/customize-revalidate"; | |
| 33 | 33 | ||
| 34 | 34 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 35 | 35 | return page(args, { title: `Plugins · Customize · ${params.owner} · g1t` }); |
| 30 | 30 | import { skillLibrary, workspaceAgents } from "../../../lib/services.server"; | |
| 31 | 31 | import { requireUser, roleIn } from "../../../lib/session.server"; | |
| 32 | 32 | ||
| 33 | − | export { shouldRevalidate } from "../../../lib/customize.server"; | |
| 33 | + | export { shouldRevalidate } from "../../../lib/customize-revalidate"; | |
| 34 | 34 | ||
| 35 | 35 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 36 | 36 | return page(args, { title: `Skills · Customize · ${params.owner} · g1t` }); |