spacedrive/interface/ErrorFallback.tsx
Brendan Allan c65d92ee4c
[ENG-380] Interface code structure improvement (#581)
* beginnings of app directory

* settings mostly good

* colocate way more components

* flatten components folder

* reexport QueryClientProvider from client

* move CodeBlock back to interface

* colocate Explorer, KeyManager + more

* goddamn captialisation

* get toasts out of components

* please eslint

* no more src directory

* $ instead of :

* added back RowHeader component

* fix settings modal padding

* more spacing, less margin

* fix sidebar locations button

* fix tags sidebar link

* clean up back button

* added margin to explorer context menu to prevent contact with edge of viewport

* don't export QueryClientProvider from @sd/client

* basic guidelines

* import interface correctly

* remove old demo data

* fix onboarding layout

* fix onboarding navigation

* fix key manager settings button

---------

Co-authored-by: Jamie Pine <ijamespine@me.com>
2023-02-27 21:29:48 -08:00

57 lines
1.4 KiB
TypeScript

import { captureException } from '@sentry/browser';
import { FallbackProps } from 'react-error-boundary';
import { useDebugState } from '@sd/client';
import { Button } from '@sd/ui';
export default ({ error, resetErrorBoundary }: FallbackProps) => (
<ErrorPage
message={error.message}
sendReportBtn={() => {
captureException(error);
resetErrorBoundary();
}}
reloadBtn={resetErrorBoundary}
/>
);
export function ErrorPage({
reloadBtn,
sendReportBtn,
message
}: {
reloadBtn?: () => void;
sendReportBtn?: () => void;
message: string;
}) {
const debug = useDebugState();
return (
<div
data-tauri-drag-region
role="alert"
className="border-app-divider bg-app flex h-screen w-screen flex-col items-center justify-center rounded-lg border p-4"
>
<p className="text-ink-faint m-3 text-sm font-bold">APP CRASHED</p>
<h1 className="text-ink text-2xl font-bold">We're past the event horizon...</h1>
<pre className="text-ink m-2">Error: {message}</pre>
{debug.enabled && (
<pre className="text-ink-dull m-2 text-sm">
Check the console (CMD/CRTL + OPTION + i) for stack trace.
</pre>
)}
<div className="text-ink flex flex-row space-x-2">
{reloadBtn && (
<Button variant="accent" className="mt-2" onClick={reloadBtn}>
Reload
</Button>
)}
{sendReportBtn && (
<Button variant="gray" className="mt-2" onClick={sendReportBtn}>
Send report
</Button>
)}
</div>
</div>
);
}