Skip to content

Commit

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.

syntaqxcommitted Parent530fb53Browse files
7 files+19−120/7 viewed
+12−0
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+}
+2−7
44 * listing tools again, where it reaches, removing it), and what follows
55 * adding one: the browser goes to sign in, or to the connector's page.
66 */
7−import { type ShouldRevalidateFunctionArgs, redirect } from "react-router";
7+import { redirect } from "react-router";
88
99 import type { ConnectorInput, User, WorkspaceConnector } from "@g1t/contracts";
1010
1111 import { addresses } from "./addresses.server";
12−import { connectorCallbackPath, connectorPagePath, needsReload, splitTarget } from "./customize";
12+import { connectorCallbackPath, connectorPagePath, splitTarget } from "./customize";
1313 import { workspaceAgents } from "./services.server";
1414 import type { ActionResult } from "../components/agents/dialogs";
1515 import { answer } from "../components/agents/actions.server";
1717 /** Where a connector's sign-in comes back to: this g1t's own page. */
1818 export function callbackUri(slug: string): string {
1919 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;
2520 }
2621
2722 /** The browser leaves for the connector's sign-in page, or lands on the connector's own page with what happened. */
+1−1
3636 import { skillLibrary, workspaceAgents } from "../../../lib/services.server";
3737 import { requireUser, roleIn } from "../../../lib/session.server";
3838
39−export { shouldRevalidate } from "../../../lib/customize.server";
39+export { shouldRevalidate } from "../../../lib/customize-revalidate";
4040
4141 export function meta({ params, ...args }: Route.MetaArgs) {
4242 return page(args, { title: `Connectors · Customize · ${params.owner} · g1t` });
+1−1
3434 import { workspaceAgents } from "../../../lib/services.server";
3535 import { requireUser, roleIn } from "../../../lib/session.server";
3636
37−export { shouldRevalidate } from "../../../lib/customize.server";
37+export { shouldRevalidate } from "../../../lib/customize-revalidate";
3838
3939 export function meta({ params, ...args }: Route.MetaArgs) {
4040 return page(args, { title: `Customize · ${params.owner} · g1t` });
+1−1
2525 import { workspaceAgents } from "../../../lib/services.server";
2626 import { requireUser, roleIn } from "../../../lib/session.server";
2727
28−export { shouldRevalidate } from "../../../lib/customize.server";
28+export { shouldRevalidate } from "../../../lib/customize-revalidate";
2929
3030 export function meta({ params, ...args }: Route.MetaArgs) {
3131 return page(args, { title: `Marketplaces · Customize · ${params.owner} · g1t` });
+1−1
2929 import { workspaceAgents } from "../../../lib/services.server";
3030 import { requireUser, roleIn } from "../../../lib/session.server";
3131
32−export { shouldRevalidate } from "../../../lib/customize.server";
32+export { shouldRevalidate } from "../../../lib/customize-revalidate";
3333
3434 export function meta({ params, ...args }: Route.MetaArgs) {
3535 return page(args, { title: `Plugins · Customize · ${params.owner} · g1t` });
+1−1
3030 import { skillLibrary, workspaceAgents } from "../../../lib/services.server";
3131 import { requireUser, roleIn } from "../../../lib/session.server";
3232
33−export { shouldRevalidate } from "../../../lib/customize.server";
33+export { shouldRevalidate } from "../../../lib/customize-revalidate";
3434
3535 export function meta({ params, ...args }: Route.MetaArgs) {
3636 return page(args, { title: `Skills · Customize · ${params.owner} · g1t` });