Skip to content

Commit b3920c4

Browse files
atrakhConvex, Inc.
authored and
Convex, Inc.
committed
dashboard: show an overlay when self-hosted dashboard is offline (#34284)
GitOrigin-RevId: 9586835a45a273e65afe9a5c6743975bd5f09a62
1 parent fa6a806 commit b3920c4

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

npm-packages/dashboard-common/src/lib/deploymentContext.tsx

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type MaybeConnectedDeployment = {
102102
deployment?: ConnectedDeployment;
103103
deploymentName?: string;
104104
loading: boolean;
105-
errorKind: "None" | "DoesNotExist";
105+
errorKind: "None" | "DoesNotExist" | "NotConnected";
106106
};
107107

108108
export const ConnectedDeploymentContext = createContext<{
@@ -345,6 +345,7 @@ function DeploymentWithConnectionState({
345345
deployment: ConnectedDeployment;
346346
children: ReactNode;
347347
}) {
348+
const { isSelfHosted } = useContext(DeploymentInfoContext);
348349
const { client, deploymentUrl, deploymentName } = deployment;
349350
const [connectionState, setConnectionState] = useState<
350351
"Connected" | "Disconnected" | "LocalDeploymentMismatch" | null
@@ -403,9 +404,12 @@ function DeploymentWithConnectionState({
403404
);
404405
return (
405406
<>
406-
{isDisconnected && deploymentName.startsWith("local-") ? (
407-
<LocalDeploymentDisconnectOverlay />
408-
) : null}
407+
{isDisconnected &&
408+
(deploymentName.startsWith("local-") ? (
409+
<LocalDeploymentDisconnectOverlay />
410+
) : isSelfHosted ? (
411+
<SelfHostedDisconnectOverlay deploymentUrl={deploymentUrl} />
412+
) : null)}
409413
<ConnectedDeploymentContext.Provider value={value}>
410414
{children}
411415
</ConnectedDeploymentContext.Provider>
@@ -421,8 +425,8 @@ function LocalDeploymentDisconnectOverlay() {
421425
backdropFilter: "blur(0.5rem)",
422426
}}
423427
>
424-
<div className="mt-[-3.5rem] max-w-[40rem]">
425-
<h3>You are disconnected from your local deployment!</h3>
428+
<div className="max-w-prose">
429+
<h3 className="mb-4">This local deployment is not online.</h3>
426430
<p className="mb-2">
427431
Check that <code className="text-sm">npx convex dev</code> is running
428432
successfully.
@@ -436,3 +440,29 @@ function LocalDeploymentDisconnectOverlay() {
436440
</div>
437441
);
438442
}
443+
444+
function SelfHostedDisconnectOverlay({
445+
deploymentUrl,
446+
}: {
447+
deploymentUrl: string;
448+
}) {
449+
return (
450+
<div
451+
className="absolute z-50 flex h-full w-full items-center justify-center"
452+
style={{
453+
backdropFilter: "blur(0.5rem)",
454+
}}
455+
>
456+
<div className="max-w-prose">
457+
<h3 className="mb-4">This deployment is not online.</h3>
458+
<p className="mb-2">
459+
Check that your Convex server is running and accessible at{" "}
460+
<code className="text-sm">{deploymentUrl}</code>.
461+
</p>
462+
<p>
463+
If you continue to have issues, try restarting your Convex server.
464+
</p>
465+
</div>
466+
</div>
467+
);
468+
}

npm-packages/dashboard-self-hosted/src/pages/_app.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function App({
4545
<ThemeProvider attribute="class" disableTransitionOnChange>
4646
<ThemeConsumer />
4747
<ToastContainer />
48-
<div className="flex h-screen flex-col">
48+
<div className="flex h-screen flex-col overflow-y-hidden">
4949
<DeploymentInfoProvider deploymentUrl={deploymentUrl}>
5050
<DeploymentApiProvider deploymentOverride="local">
5151
<WaitForDeploymentApi>
@@ -222,12 +222,12 @@ function DeploymentInfoProvider({
222222
);
223223
}
224224
return (
225-
<DeploymentInfoContext.Provider value={finalValue}>
226-
<ErrorBoundary>
227-
<Header onLogout={() => setAdminKey("")} />
228-
{children}
229-
</ErrorBoundary>
230-
</DeploymentInfoContext.Provider>
225+
<div className="relative h-full max-h-full">
226+
<Header onLogout={() => setAdminKey("")} />
227+
<DeploymentInfoContext.Provider value={finalValue}>
228+
<ErrorBoundary>{children}</ErrorBoundary>
229+
</DeploymentInfoContext.Provider>
230+
</div>
231231
);
232232
}
233233

0 commit comments

Comments
 (0)