chore: infra update for maintenance mode (#5963)

This commit is contained in:
guru_sainath 2024-11-06 15:13:51 +05:30 committed by GitHub
parent 56755b0e9c
commit 9d1253a61d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View file

@ -0,0 +1,5 @@
"use client";
import { FC, Fragment } from "react";
export const MaintenanceMode: FC = () => <Fragment />;

View file

@ -6,6 +6,8 @@ import { LogoSpinner } from "@/components/common";
import { InstanceNotReady } from "@/components/instance";
// hooks
import { useInstance } from "@/hooks/store";
// plane web components
import { MaintenanceMode } from "@/plane-web/components/maintenance-mode";
type TInstanceWrapper = {
children: ReactNode;
@ -16,9 +18,11 @@ export const InstanceWrapper: FC<TInstanceWrapper> = observer((props) => {
// store
const { isLoading, instance, error, fetchInstanceInfo } = useInstance();
const { isLoading: isInstanceSWRLoading } = useSWR("INSTANCE_INFORMATION", () => fetchInstanceInfo(), {
revalidateOnFocus: false,
});
const { isLoading: isInstanceSWRLoading, error: instanceSWRError } = useSWR(
"INSTANCE_INFORMATION",
async () => await fetchInstanceInfo(),
{ revalidateOnFocus: false }
);
// loading state
if ((isLoading || isInstanceSWRLoading) && !instance)
@ -28,6 +32,8 @@ export const InstanceWrapper: FC<TInstanceWrapper> = observer((props) => {
</div>
);
if (instanceSWRError) return <MaintenanceMode />;
// something went wrong while in the request
if (error && error?.status === "error") return <>{children}</>;

View file

@ -66,6 +66,7 @@ export class InstanceStore implements IInstanceStore {
message: "Failed to fetch instance info",
};
});
throw error;
}
};
}

View file

@ -0,0 +1 @@
export * from "ce/components/maintenance-mode";