diff --git a/apps/studio/components/ui/ErrorBoundaryState.tsx b/apps/studio/components/ui/ErrorBoundaryState.tsx deleted file mode 100644 index cf29098fe42..00000000000 --- a/apps/studio/components/ui/ErrorBoundaryState.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { isError } from 'lodash' -import { ExternalLink } from 'lucide-react' -import Link from 'next/link' -import { useRouter } from 'next/router' - -import { - AlertDescription_Shadcn_, - AlertTitle_Shadcn_, - Alert_Shadcn_, - Button, - WarningIcon, -} from 'ui' - -// More correct version of FallbackProps from react-error-boundary -export type FallbackProps = { - error: unknown - resetErrorBoundary: (...args: any[]) => void -} - -export const ErrorBoundaryState = ({ error, resetErrorBoundary }: FallbackProps) => { - const router = useRouter() - const checkIsError = isError(error) - - const errorMessage = checkIsError ? error.message : '' - const urlMessage = checkIsError ? `Path name: ${router.pathname}\n\n${error?.stack}` : '' - const isRemoveChildError = checkIsError - ? errorMessage.includes("Failed to execute 'removeChild' on 'Node'") - : false - - return ( -
-
-

- Application error: a client-side exception has occurred (see browser console for more - information) -

-

Error: {errorMessage}

-
- - {isRemoveChildError && ( - - - - This error might be caused by Google translate or third-party browser extensions - - - You may try to avoid using Google translate or disable certain browser extensions to - avoid running into the 'removeChild' on 'Node' error. - - - - - - )} - -
- - {/* [Joshen] For local and staging, allow us to escape the error boundary */} - {/* We could actually investigate how to make this available on prod, but without being able to reliably test this, I'm not keen to do it now */} - {process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? ( - - ) : ( - - )} -
-
- ) -} diff --git a/apps/studio/components/ui/GlobalErrorBoundaryState.tsx b/apps/studio/components/ui/GlobalErrorBoundaryState.tsx new file mode 100644 index 00000000000..fbe2f76a020 --- /dev/null +++ b/apps/studio/components/ui/GlobalErrorBoundaryState.tsx @@ -0,0 +1,158 @@ +import { isError } from 'lodash' +import { ExternalLink } from 'lucide-react' +import Link from 'next/link' +import { useRouter } from 'next/router' +import CopyButton from './CopyButton' + +import Image from 'next/image' +import { + AlertDescription_Shadcn_, + AlertTitle_Shadcn_, + Alert_Shadcn_, + Button, + WarningIcon, + cn, +} from 'ui' +import { InlineLinkClassName } from './InlineLink' + +// More correct version of FallbackProps from react-error-boundary +export type FallbackProps = { + error: unknown + resetErrorBoundary: (...args: any[]) => void +} + +export const GlobalErrorBoundaryState = ({ error, resetErrorBoundary }: FallbackProps) => { + const router = useRouter() + const checkIsError = isError(error) + + const errorMessage = checkIsError ? error.message : '' + const urlMessage = checkIsError ? `Path name: ${router.pathname}\n\n${error?.stack}` : '' + const isRemoveChildError = checkIsError + ? errorMessage.includes("Failed to execute 'removeChild' on 'Node'") + : false + + const handleClearStorage = () => { + try { + localStorage.clear() + sessionStorage.clear() + } catch (e) { + // ignore + } + window.location.reload() + } + + return ( +
+
+ + Supabase + +
+ +
+
+
+

Sorry! An unexpected error occured.

+ +
+

+ Application error: a client-side exception has occurred (see browser console for more + information) +

+

{errorMessage}

+
+ + {isRemoveChildError ? ( + + + + This error might be caused by Google translate or third-party browser extensions + + + You may try to avoid using Google translate or disable certain browser extensions to + avoid running into the 'removeChild' on 'Node' error. + + + + + + ) : ( + + We recommend trying the following: + +
    +
  • + window.location.reload()} + > + Refresh + {' '} + the page +
  • +
  • + router.push('/logout')} + > + Sign out + {' '} + and sign back in +
  • +
  • + + Clear your browser storage + {' '} + to clean potentially outdated data +
  • +
  • + Disable browser extensions that might modify page content (e.g., Google Translate) +
  • +
  • If the problem persists, please contact support for assistance
  • +
+
+
+ )} + +
+ + {/* [Joshen] For local and staging, allow us to escape the error boundary */} + {/* We could actually investigate how to make this available on prod, but without being able to reliably test this, I'm not keen to do it now */} + {process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? ( + + ) : ( + + )} +
+
+
+ ) +} diff --git a/apps/studio/next-env.d.ts b/apps/studio/next-env.d.ts index a4a7b3f5cfa..52e831b4342 100644 --- a/apps/studio/next-env.d.ts +++ b/apps/studio/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. +// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. diff --git a/apps/studio/pages/_app.tsx b/apps/studio/pages/_app.tsx index 82dde900ed4..f8f95bfbb55 100644 --- a/apps/studio/pages/_app.tsx +++ b/apps/studio/pages/_app.tsx @@ -40,7 +40,7 @@ import { FeaturePreviewContextProvider } from 'components/interfaces/App/Feature import FeaturePreviewModal from 'components/interfaces/App/FeaturePreview/FeaturePreviewModal' import { MonacoThemeProvider } from 'components/interfaces/App/MonacoThemeProvider' import { GenerateSql } from 'components/interfaces/SqlGenerator/SqlGenerator' -import { ErrorBoundaryState } from 'components/ui/ErrorBoundaryState' +import { GlobalErrorBoundaryState } from 'components/ui/GlobalErrorBoundaryState' import { useRootQueryClient } from 'data/query-client' import { customFont, sourceCodePro } from 'fonts' import { AuthProvider } from 'lib/auth' @@ -95,7 +95,7 @@ function CustomApp({ Component, pageProps }: AppPropsWithLayout) { const isTestEnv = process.env.NEXT_PUBLIC_NODE_ENV === 'test' return ( - + diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsx index 4cb8529816b..2f13073bbf0 100644 --- a/apps/studio/pages/project/[ref]/index.tsx +++ b/apps/studio/pages/project/[ref]/index.tsx @@ -23,6 +23,7 @@ import { useAppStateSnapshot } from 'state/app-state' import type { NextPageWithLayout } from 'types' import { Badge, + Button, cn, Tabs_Shadcn_, TabsContent_Shadcn_, @@ -81,6 +82,13 @@ const Home: NextPageWithLayout = () => {

{projectName}

+ {isOrioleDb && (