diff --git a/client/www/components/dash/Auth.tsx b/client/www/components/dash/Auth.tsx index 2f0c0b249..1bb0bbeae 100644 --- a/client/www/components/dash/Auth.tsx +++ b/client/www/components/dash/Auth.tsx @@ -200,7 +200,7 @@ export default function Auth(props: { })); }; return ( -
+
diff --git a/client/www/pages/_devtool/index.tsx b/client/www/pages/_devtool/index.tsx index 71c78bb26..9f09803f6 100644 --- a/client/www/pages/_devtool/index.tsx +++ b/client/www/pages/_devtool/index.tsx @@ -5,7 +5,7 @@ import { successToast } from '@/lib/toast'; import { DashResponse, InstantApp } from '@/lib/types'; import config from '@/lib/config'; import { jsonFetch } from '@/lib/fetch'; -import { APIResponse, useAuthToken, useTokenFetch } from '@/lib/auth'; +import { APIResponse, signOut, useAuthToken, useTokenFetch } from '@/lib/auth'; import { Sandbox } from '@/components/dash/Sandbox'; import { Explorer } from '@/components/dash/explorer/Explorer'; import { init } from '@instantdb/react'; @@ -21,6 +21,7 @@ import { Content, twel, useDialog, + ScreenHeading, } from '@/components/ui'; import Auth from '@/components/dash/Auth'; import { isMinRole } from '@/pages/dash/index'; @@ -45,6 +46,7 @@ export default function Devtool() { } | { state: 'error'; + errorMessage: string | undefined; } | { state: 'ready'; @@ -91,14 +93,14 @@ export default function Devtool() { __adminToken: app?.admin_token, devtool: false, }); - setConnection({ state: 'ready', db }); return () => { db._core.shutdown(); }; } catch (error) { - setConnection({ state: 'error' }); + const message = (error as Error).message; + setConnection({ state: 'error', errorMessage: message }); } }, [router.isReady, app]); @@ -108,7 +110,7 @@ export default function Devtool() { if (!authToken) { return ( - <> + } /> - + ); } @@ -130,39 +132,153 @@ export default function Devtool() { } if (dashResponse.error) { + const message = dashResponse.error.message; return ( -
-
Error loading app
- {!isEmptyObj(dashResponse.error) ? ( -
-            {JSON.stringify(dashResponse.error, null, '\t')}{' '}
-          
- ) : null} -
+ +
+
+ 🤕 Failed to load your app + {message ? ( +
+
+ {message} +
+
+ ) : null} +

+ We had some trouble loading your app. Please ping us on{' '} + + discord + {' '} + with details. +

+ +
+
+
); } if (!appId) { return ( -
- No app ID provided. Are you passing an app ID into init? -
+ +
+
+ No app id provided +

+ We didn't receive an app ID. Double check that you passed an{' '} + appId paramater in your init. If you + continue experiencing issues, ping us on Discord. +

+ +
+
+
); } if (!app) { + const user = dashResponse.data?.user; return ( -
- Cound not find app. Are you logged in to the correct account? -
+ +
+
+ 🔎 We couldn't find your app +

+ {user ? ( + <> + You're logged in as {user.email}.{' '} + + ) : null} + We tried to access your app but couldn't. +

+
+ +
+

+ Are you sure you have access? Contact the app owner, or sign out + and log into a different account: +

+ +
+
+
); } if (connection.state === 'error') { + const message = connection.errorMessage; return ( -
- Failed to connect to Instant backend. -
+ +
+
+ + 🤕 Failed connect to Instant's backend + + {message ? ( +
+
+ {message} +
+
+ ) : null} + +

+ We had some trouble connect to Instant's backend. Please ping us + on{' '} + + discord + {' '} + with details. +

+ +
+
+
); } @@ -175,41 +291,11 @@ export default function Devtool() { } return ( -
+
-
-
- Instant Devtools {app?.title ? `• ${app?.title}` : ''} -
- { - parent.postMessage( - { - type: 'close', - }, - '*', - ); - }} - /> -
-
- App ID - { - const node = e.currentTarget; - const selection = window.getSelection(); - const range = document.createRange(); - range.selectNodeContents(node); - selection?.removeAllRanges(); - selection?.addRange(range); - }} - > - {app.id ?? <> } - +
+
) : tab === 'help' ? ( -
+
+
) : null}
+
+ ); +} + +function DevtoolWindow({ + app, + children, +}: { + app?: InstantApp; + children: React.ReactNode; +}) { + return ( +
+
+
+
+ Instant Devtools {app?.title ? `• ${app?.title}` : ''} +
+ { + parent.postMessage( + { + type: 'close', + }, + '*', + ); + }} + /> +
+
{children}
+
+
+ ); +} + +function AppIdLabel({ appId }: { appId: string }) { + return ( +
+ App ID + { + const node = e.currentTarget; + const selection = window.getSelection(); + const range = document.createRange(); + range.selectNodeContents(node); + selection?.removeAllRanges(); + selection?.addRange(range); + }} + > + {appId} +
); } @@ -376,6 +525,7 @@ function Help() { Discord