From baee4c5f222d2347f9b4ffe6e191847c4d2c95e2 Mon Sep 17 00:00:00 2001 From: pablonyx Date: Mon, 10 Feb 2025 11:51:29 -0800 Subject: [PATCH] Multi tenant specific error page (#3928) Multi tenant specific error page --- web/src/app/admin/api-key/page.tsx | 5 ++- web/src/app/admin/token-rate-limits/page.tsx | 2 +- web/src/app/ee/admin/groups/page.tsx | 5 ++- web/src/app/layout.tsx | 45 ++----------------- .../components/errorPages/CloudErrorPage.tsx | 22 +++++++++ web/src/components/errorPages/ErrorPage.tsx | 44 ++++++++++++++++++ .../components/errorPages/ErrorPageLayout.tsx | 19 ++++++++ web/src/components/logo/Logo.tsx | 19 ++++++-- web/src/components/ui/createButton.tsx | 23 ++++++---- 9 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 web/src/components/errorPages/CloudErrorPage.tsx create mode 100644 web/src/components/errorPages/ErrorPage.tsx create mode 100644 web/src/components/errorPages/ErrorPageLayout.tsx diff --git a/web/src/app/admin/api-key/page.tsx b/web/src/app/admin/api-key/page.tsx index 88ed047703d3..22c03546b30b 100644 --- a/web/src/app/admin/api-key/page.tsx +++ b/web/src/app/admin/api-key/page.tsx @@ -112,7 +112,10 @@ function Main() { } const newApiKeyButton = ( - + setShowCreateUpdateForm(true)} + text="Create API Key" + /> ); if (apiKeys.length === 0) { diff --git a/web/src/app/admin/token-rate-limits/page.tsx b/web/src/app/admin/token-rate-limits/page.tsx index 17947065ed92..656e5b5911d7 100644 --- a/web/src/app/admin/token-rate-limits/page.tsx +++ b/web/src/app/admin/token-rate-limits/page.tsx @@ -140,7 +140,7 @@ function Main() { setModalIsOpen(true)} text="Create a Token Rate Limit" /> {isPaidEnterpriseFeaturesEnabled && ( diff --git a/web/src/app/ee/admin/groups/page.tsx b/web/src/app/ee/admin/groups/page.tsx index a4d322a6a629..24795a12d953 100644 --- a/web/src/app/ee/admin/groups/page.tsx +++ b/web/src/app/ee/admin/groups/page.tsx @@ -53,7 +53,10 @@ const Main = () => { <> {popup} {isAdmin && ( - + setShowForm(true)} + text="Create New User Group" + /> )} {data.length > 0 && (
diff --git a/web/src/app/layout.tsx b/web/src/app/layout.tsx index 8c38d5f044f2..b0059650fe89 100644 --- a/web/src/app/layout.tsx +++ b/web/src/app/layout.tsx @@ -8,6 +8,7 @@ import { CUSTOM_ANALYTICS_ENABLED, GTM_ENABLED, SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED, + NEXT_PUBLIC_CLOUD_ENABLED, } from "@/lib/constants"; import { Metadata } from "next"; import { buildClientUrl } from "@/lib/utilsSS"; @@ -25,6 +26,8 @@ import { LogoType } from "@/components/logo/Logo"; import { Hanken_Grotesk } from "next/font/google"; import { WebVitals } from "./web-vitals"; import { ThemeProvider } from "next-themes"; +import CloudError from "@/components/errorPages/CloudErrorPage"; +import Error from "@/components/errorPages/ErrorPage"; const inter = Inter({ subsets: ["latin"], @@ -129,47 +132,7 @@ export default async function RootLayout({ if (!combinedSettings) { return getPageContent( -
-
- -
- - -

Error

-

- Your Onyx instance was not configured properly and your settings - could not be loaded. This could be due to an admin configuration - issue, an incomplete setup, or backend services that may not be up - and running yet. -

-

- If you're an admin, please check{" "} - - our docs - {" "} - to see how to configure Onyx properly. If you're a user, please - contact your admin to fix this error. -

-

- For additional support and guidance, you can reach out to our - community on{" "} - - Slack - - . -

-
-
+ NEXT_PUBLIC_CLOUD_ENABLED ? : ); } diff --git a/web/src/components/errorPages/CloudErrorPage.tsx b/web/src/components/errorPages/CloudErrorPage.tsx new file mode 100644 index 000000000000..a50475458234 --- /dev/null +++ b/web/src/components/errorPages/CloudErrorPage.tsx @@ -0,0 +1,22 @@ +"use client"; +import ErrorPageLayout from "./ErrorPageLayout"; + +export default function CloudError() { + return ( + +

+ Maintenance in Progress +

+
+

+ Onyx is currently in a maintenance window. Please check back in a + couple of minutes. +

+

+ We apologize for any inconvenience this may cause and appreciate your + patience. +

+
+
+ ); +} diff --git a/web/src/components/errorPages/ErrorPage.tsx b/web/src/components/errorPages/ErrorPage.tsx new file mode 100644 index 000000000000..3821129178b7 --- /dev/null +++ b/web/src/components/errorPages/ErrorPage.tsx @@ -0,0 +1,44 @@ +import { FiAlertCircle } from "react-icons/fi"; +import ErrorPageLayout from "./ErrorPageLayout"; + +export default function Error() { + return ( + +

+

We encountered an issue

+ +

+
+

+ It seems there was a problem loading your Onyx settings. This could be + due to a configuration issue or incomplete setup. +

+

+ If you're an admin, please review our{" "} + + documentation + {" "} + for proper configuration steps. If you're a user, please contact + your admin for assistance. +

+

+ Need help? Join our{" "} + + Slack community + {" "} + for support. +

+
+
+ ); +} diff --git a/web/src/components/errorPages/ErrorPageLayout.tsx b/web/src/components/errorPages/ErrorPageLayout.tsx new file mode 100644 index 000000000000..ff470b6af25b --- /dev/null +++ b/web/src/components/errorPages/ErrorPageLayout.tsx @@ -0,0 +1,19 @@ +import React from "react"; +import { LogoType } from "../logo/Logo"; + +interface ErrorPageLayoutProps { + children: React.ReactNode; +} + +export default function ErrorPageLayout({ children }: ErrorPageLayoutProps) { + return ( +
+
+ +
+
+
{children}
+
+
+ ); +} diff --git a/web/src/components/logo/Logo.tsx b/web/src/components/logo/Logo.tsx index e147b822ae4d..a6ab58f01ecb 100644 --- a/web/src/components/logo/Logo.tsx +++ b/web/src/components/logo/Logo.tsx @@ -9,15 +9,24 @@ export function Logo({ height, width, className, + size = "default", }: { height?: number; width?: number; className?: string; + size?: "small" | "default" | "large"; }) { const settings = useContext(SettingsContext); - height = height || 32; - width = width || 30; + const sizeMap = { + small: { height: 24, width: 22 }, + default: { height: 32, width: 30 }, + large: { height: 48, width: 45 }, + }; + + const { height: defaultHeight, width: defaultWidth } = sizeMap[size]; + height = height || defaultHeight; + width = width || defaultWidth; if ( !settings || @@ -49,7 +58,11 @@ export function Logo({ ); } -export function LogoType() { +export function LogoType({ + size = "default", +}: { + size?: "small" | "default" | "large"; +}) { return ( void; text?: string; } export default function CreateButton({ href, + onClick, text = "Create", }: CreateButtonProps) { - return ( - - - + const content = ( + ); + + if (href) { + return {content}; + } + + return content; }