|
1 | | -import React, { useLayoutEffect, useRef } from 'react'; |
| 1 | +import React, { useCallback, useLayoutEffect, useRef } from 'react'; |
2 | 2 | import ReactDOM from 'react-dom'; |
3 | | -import { resetGlobalCSS, css, Body } from '@mongodb-js/compass-components'; |
| 3 | +import { |
| 4 | + resetGlobalCSS, |
| 5 | + css, |
| 6 | + Body, |
| 7 | + openToast, |
| 8 | +} from '@mongodb-js/compass-components'; |
4 | 9 | import type { AllPreferences } from 'compass-preferences-model'; |
5 | 10 | import { CompassWeb } from '../src/index'; |
6 | 11 | import { SandboxConnectionStorageProvider } from '../src/connection-storage'; |
@@ -86,6 +91,14 @@ const App = () => { |
86 | 91 | getMetaEl('csrf-time').setAttribute('content', csrfTime ?? ''); |
87 | 92 | }, [csrfToken, csrfTime]); |
88 | 93 |
|
| 94 | + const onFailToLoadConnections = useCallback((error: Error) => { |
| 95 | + openToast('failed-to-load-connections', { |
| 96 | + title: 'Failed to load connections', |
| 97 | + description: error.message, |
| 98 | + variant: 'warning', |
| 99 | + }); |
| 100 | + }, []); |
| 101 | + |
89 | 102 | if (status === 'checking') { |
90 | 103 | return null; |
91 | 104 | } |
@@ -132,6 +145,7 @@ const App = () => { |
132 | 145 | onTrack={sandboxTelemetry.track} |
133 | 146 | onDebug={sandboxLogger.debug} |
134 | 147 | onLog={sandboxLogger.log} |
| 148 | + onFailToLoadConnections={onFailToLoadConnections} |
135 | 149 | ></CompassWeb> |
136 | 150 | </Body> |
137 | 151 | </SandboxPreferencesUpdateProvider> |
|
0 commit comments