fix: add maintenance mode

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-02 19:16:22 +01:00
parent 25e3a84bf6
commit 522ecc0040
4 changed files with 30 additions and 0 deletions

View File

@@ -17,5 +17,6 @@ export function useAppContext() {
apiUrl: params.apiUrl,
dashboardUrl: params.dashboardUrl,
isSelfHosted: params.isSelfHosted,
isMaintenance: params.isMaintenance ?? false,
};
}

View File

@@ -34,6 +34,7 @@ interface MyRouterContext {
apiUrl: string;
dashboardUrl: string;
isSelfHosted: boolean;
isMaintenance: boolean;
}
export const Route = createRootRouteWithContext<MyRouterContext>()({

View File

@@ -1,5 +1,10 @@
import { FullPageEmptyState } from '@/components/full-page-empty-state';
import { Sidebar } from '@/components/sidebar';
import { Button, LinkButton, buttonVariants } from '@/components/ui/button';
import { useAppContext } from '@/hooks/use-app-context';
import { cn } from '@/utils/cn';
import { Outlet, createFileRoute, redirect } from '@tanstack/react-router';
import { ConstructionIcon } from 'lucide-react';
export const Route = createFileRoute('/_app')({
beforeLoad: async ({ context }) => {
@@ -11,6 +16,28 @@ export const Route = createFileRoute('/_app')({
});
function AppLayout() {
const { isMaintenance } = useAppContext();
if (isMaintenance) {
return (
<FullPageEmptyState
icon={ConstructionIcon}
className="min-h-screen"
title="Maintenance mode"
description="We are currently performing maintenance on the system. Please check back later."
>
<a
href="https://status.openpanel.dev/"
className={cn(buttonVariants())}
target="_blank"
rel="noopener noreferrer"
>
Check out our status page
</a>
</FullPageEmptyState>
);
}
return (
<div className="flex h-screen w-full">
<Sidebar />

View File

@@ -8,6 +8,7 @@ export const getServerEnvs = createServerFn().handler(async () => {
process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL,
),
isSelfHosted: process.env.SELF_HOSTED !== undefined,
isMaintenance: process.env.MAINTENANCE === '1',
};
return envs;