Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@radix-ui/react-toggle-group": "^1.1.11",
"@radix-ui/react-tooltip": "^1.2.8",
"@radix-ui/react-visually-hidden": "^1.2.3",
"@rivet-gg/cloud": "https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@7090780",
"@rivet-gg/cloud": "https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2",
"@rivet-gg/icons": "workspace:*",
"@rivetkit/engine-api-full": "workspace:*",
"@sentry/react": "^8.55.0",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/data-providers/engine-data-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export const createGlobalContext = (opts: {
return lastPage.pagination.cursor;
},
select: (data) => data.pages.flatMap((page) => page.namespaces),
retry: shouldRetryAllExpect403,
throwOnError: noThrow,
meta: {
mightRequireAuth,
},
});
},
createNamespaceMutationOptions(opts: {
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/app/inspector-root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Route,
CatchBoundary,
useNavigate,
useRouteContext,
useSearch,
Expand Down Expand Up @@ -50,7 +50,14 @@ export function InspectorRoot() {
<InspectorCredentialsProvider value={ctxValue}>
<RouteLayout>
<Actors actorId={search.actorId} />
{!search.n ? <BuildPrefiller /> : null}
<CatchBoundary
getResetKey={() =>
search.n?.join(",") ?? "no-build-name"
}
errorComponent={() => null}
>
{!search.n ? <BuildPrefiller /> : null}
</CatchBoundary>
</RouteLayout>
</InspectorCredentialsProvider>
);
Expand Down
36 changes: 23 additions & 13 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import {
ScrollArea,
Skeleton,
} from "@/components";
import { useInspectorDataProvider } from "@/components/actors";
import {
useDataProviderCheck,
useInspectorDataProvider,
} from "@/components/actors";
import type { HeaderLinkProps } from "@/components/header/header-link";
import { ensureTrailingSlash } from "@/lib/utils";
import { ActorBuildsList } from "./actor-builds-list";
Expand Down Expand Up @@ -388,6 +391,7 @@ const Subnav = () => {
}
: { to: "/", fuzzy: true },
);
const hasDataProvider = useDataProviderCheck();

if (nsMatch === false) {
return null;
Expand All @@ -405,12 +409,14 @@ const Subnav = () => {
Connect
</HeaderLink>
) : null}
<div className="w-full">
<span className="block text-muted-foreground text-xs px-2 py-1 transition-colors mb-0.5">
Instances
</span>
<ActorBuildsList />
</div>
{hasDataProvider ? (
<div className="w-full">
<span className="block text-muted-foreground text-xs px-2 py-1 transition-colors mb-0.5">
Instances
</span>
<ActorBuildsList />
</div>
) : null}
</div>
);
};
Expand Down Expand Up @@ -535,6 +541,8 @@ function CloudSidebarContent() {
fuzzy: true,
});

const hasDataProvider = useDataProviderCheck();

if (matchNamespace) {
return (
<div className="flex gap-1.5 flex-col">
Expand All @@ -546,12 +554,14 @@ function CloudSidebarContent() {
>
Connect
</HeaderLink>
<div className="w-full pt-1.5">
<span className="block text-muted-foreground text-xs px-1 py-1 transition-colors mb-0.5">
Instances
</span>
<ActorBuildsList />
</div>
{hasDataProvider ? (
<div className="w-full pt-1.5">
<span className="block text-muted-foreground text-xs px-1 py-1 transition-colors mb-0.5">
Instances
</span>
<ActorBuildsList />
</div>
) : null}
</div>
);
}
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/components/actors/data-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
type RegisteredRouter,
type RouteIds,
useMatches,
useMatchRoute,
useRouteContext,
} from "@tanstack/react-router";
import { match } from "ts-pattern";
Expand Down Expand Up @@ -34,6 +36,26 @@ export const useDataProvider = () =>
})
.exhaustive();

export const useDataProviderCheck = () => {
const matchRoute = useMatchRoute();

return matchRoute({
to: match(__APP_TYPE__)
.with("cloud", () => {
return "/orgs/$organization/projects/$project/ns/$namespace" as const;
})
.with("engine", () => {
return "/ns/$namespace" as const;
})
.with("inspector", () => {
return "/" as const;
})
.otherwise(() => {
throw new Error("Not in a valid context");
}),
});
};

export const useEngineDataProvider = () => {
return useRouteContext({
from: "/_context/_engine",
Expand Down
17 changes: 16 additions & 1 deletion frontend/src/components/hooks/use-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,24 @@ export const createDialogHook = <

return (
<IsInModalContext.Provider value={true}>
<Dialog {...dialogProps}>
<Dialog
{...dialogProps}
onOpenChange={
props.dismissible
? () => {}
: props.dialogProps?.onOpenChange
}
>
<DialogContent
{...dialogContentProps}
hideClose={
props.dismissible === false ||
dialogContentProps?.hideClose
}
disableOutsidePointerEvents={
props.dismissible === false ||
dialogContentProps?.disableOutsidePointerEvents
}
onOpenAutoFocus={(e) => {
if (opts.autoFocus === false) {
return e.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/modal-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ModalRenderer() {

function getDialogComponent(dialogKey: string) {
const dialogs = useDialog;
const dialog = dialogs[dialogKey];
const dialog = dialogs[dialogKey as keyof typeof dialogs];

if (!dialog || typeof dialog !== "function") {
return null;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const queryCache = new QueryCache({
"statusCode" in error &&
error.statusCode === 403
) {
modal.open("ProvideEngineCredentials");
modal.open("ProvideEngineCredentials", { dismissible: false });
return;
}
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Route = createFileRoute("/_context")({
return match(__APP_TYPE__)
.with("engine", () => ({
dataProvider: createGlobalEngineContext({
engineToken:
engineToken: () =>
ls.engineCredentials.get(getConfig().apiUrl) || "",
}),
__type: "engine" as const,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export function RouteComponent() {
<>
<CatchBoundary getResetKey={() => actorId ?? "no-actor-id"}>
<Actors actorId={actorId} />
{!n ? <BuildPrefiller /> : null}
<CatchBoundary
getResetKey={() => n?.join(",") ?? "no-build-name"}
errorComponent={() => null}
>
{!n ? <BuildPrefiller /> : null}
</CatchBoundary>
</CatchBoundary>
</>
);
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/routes/_context/_engine/ns.$namespace/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { createFileRoute, useSearch } from "@tanstack/react-router";
import {
CatchBoundary,
createFileRoute,
useSearch,
} from "@tanstack/react-router";
import { Actors } from "@/app/actors";
import { BuildPrefiller } from "@/app/build-prefiller";

Expand All @@ -12,7 +16,13 @@ export function RouteComponent() {
return (
<>
<Actors actorId={actorId} />
{!n ? <BuildPrefiller /> : null}

<CatchBoundary
getResetKey={() => n?.join(",") ?? "no-build-name"}
errorComponent={() => null}
>
{!n ? <BuildPrefiller /> : null}
</CatchBoundary>
</>
);
}
30 changes: 20 additions & 10 deletions frontend/src/routes/_context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createFileRoute, redirect } from "@tanstack/react-router";
import { createFileRoute, isRedirect, redirect } from "@tanstack/react-router";
import { match } from "ts-pattern";
import CreateNamespacesFrameContent from "@/app/dialogs/create-namespace-frame";
import { InspectorRoot } from "@/app/inspector-root";
Expand Down Expand Up @@ -27,17 +27,27 @@ export const Route = createFileRoute("/_context/")({
});
})
.with({ __type: "engine" }, async (ctx) => {
const result = await ctx.queryClient.fetchInfiniteQuery(
ctx.dataProvider.namespacesQueryOptions(),
);
const firstNamespace = result.pages[0]?.namespaces[0];
if (!firstNamespace) {
try {
const result = await ctx.queryClient.fetchInfiniteQuery(
ctx.dataProvider.namespacesQueryOptions(),
);

const firstNamespace = result.pages[0]?.namespaces[0];
if (!firstNamespace) {
return;
}
throw redirect({
to: "/ns/$namespace",
params: { namespace: firstNamespace.name },
});
} catch (e) {
if (isRedirect(e)) {
throw e;
}

// Ignore errors here, they will be handled in the UI
return;
}
throw redirect({
to: "/ns/$namespace",
params: { namespace: firstNamespace.name },
});
})
.with({ __type: "inspector" }, async (ctx) => {
if (!search.t || !search.u) {
Expand Down
19 changes: 11 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading