fix: add maintenance mode
This commit is contained in:
@@ -17,5 +17,6 @@ export function useAppContext() {
|
||||
apiUrl: params.apiUrl,
|
||||
dashboardUrl: params.dashboardUrl,
|
||||
isSelfHosted: params.isSelfHosted,
|
||||
isMaintenance: params.isMaintenance ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ interface MyRouterContext {
|
||||
apiUrl: string;
|
||||
dashboardUrl: string;
|
||||
isSelfHosted: boolean;
|
||||
isMaintenance: boolean;
|
||||
}
|
||||
|
||||
export const Route = createRootRouteWithContext<MyRouterContext>()({
|
||||
|
||||
@@ -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 />
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user