mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
We tell users to check their firewall and ad blocker settings in case they bump into authentication problems. This also separates out the modal to be only used by the session view.
85 lines
2.0 KiB
TypeScript
85 lines
2.0 KiB
TypeScript
import type {
|
|
ResponseError,
|
|
ResponseParseError,
|
|
} from "@httpd-client/lib/fetcher";
|
|
import type { HomeRoute, HomeLoadedRoute } from "@app/views/home/router";
|
|
import type {
|
|
ProjectLoadedRoute,
|
|
ProjectRoute,
|
|
} from "@app/views/projects/router";
|
|
import type { NodesRoute, NodesLoadedRoute } from "@app/views/nodes/router";
|
|
|
|
import { loadHomeRoute } from "@app/views/home/router";
|
|
import { loadProjectRoute } from "@app/views/projects/router";
|
|
import { loadNodeRoute } from "@app/views/nodes/router";
|
|
|
|
interface BootingRoute {
|
|
resource: "booting";
|
|
}
|
|
|
|
export interface NotFoundRoute {
|
|
resource: "notFound";
|
|
params: { title: string };
|
|
}
|
|
|
|
export interface SessionRoute {
|
|
resource: "session";
|
|
params: {
|
|
id: string;
|
|
signature: string;
|
|
publicKey: string;
|
|
apiAddr: string;
|
|
path?: string;
|
|
};
|
|
}
|
|
|
|
export type ErrorParam = Error | ResponseParseError | ResponseError | undefined;
|
|
|
|
export interface ErrorRoute {
|
|
resource: "error";
|
|
params: {
|
|
title: string;
|
|
description: string;
|
|
error: ErrorParam;
|
|
};
|
|
}
|
|
|
|
export type Route =
|
|
| BootingRoute
|
|
| HomeRoute
|
|
| ErrorRoute
|
|
| NotFoundRoute
|
|
| ProjectRoute
|
|
| NodesRoute
|
|
| SessionRoute;
|
|
|
|
export type LoadedRoute =
|
|
| BootingRoute
|
|
| HomeLoadedRoute
|
|
| ErrorRoute
|
|
| NotFoundRoute
|
|
| ProjectLoadedRoute
|
|
| NodesLoadedRoute
|
|
| SessionRoute;
|
|
|
|
export async function loadRoute(route: Route): Promise<LoadedRoute> {
|
|
if (route.resource === "nodes") {
|
|
return await loadNodeRoute(route.params);
|
|
} else if (route.resource === "home") {
|
|
return await loadHomeRoute();
|
|
} else if (
|
|
route.resource === "project.source" ||
|
|
route.resource === "project.history" ||
|
|
route.resource === "project.commit" ||
|
|
route.resource === "project.issues" ||
|
|
route.resource === "project.newIssue" ||
|
|
route.resource === "project.issue" ||
|
|
route.resource === "project.patches" ||
|
|
route.resource === "project.patch"
|
|
) {
|
|
return await loadProjectRoute(route);
|
|
} else {
|
|
return route;
|
|
}
|
|
}
|