MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / BrowserComponent

Function BrowserComponent

web/pgadmin/static/js/BrowserComponent.jsx:162–241  ·  view source on GitHub ↗
({pgAdmin})

Source from the content-addressed store, hash-verified

160};
161
162export default function BrowserComponent({pgAdmin}) {
163
164 const {isLoading, failed, getPreferencesForModule} = usePreferences();
165 let { name: browser } = useMemo(()=>getBrowser(), []);
166 const [uiReady, setUiReady] = useState(false);
167 const confirmOnClose = getPreferencesForModule('browser').confirm_on_refresh_close;
168 useBeforeUnload({
169 enabled: confirmOnClose,
170 beforeClose: (forceClose)=>{
171 window.electronUI?.focus();
172 pgAdmin.Browser.notifier.confirm(
173 gettext('Quit pgAdmin 4'),
174 gettext('Are you sure you want to quit the application?'),
175 function() { forceClose(); },
176 function() { return true; },
177 gettext('Yes'),
178 gettext('No'),
179 'default',
180 'id-app-quit'
181 );
182 },
183 isNewTab: true,
184 });
185
186 // Called when Install and Restart btn called for auto-update install
187 function installUpdate() {
188 if (window.electronUI) {
189 window.electronUI.sendDataForAppUpdate({
190 'install_update_now': true
191 });
192 }}
193
194 // Listen for auto-update events from the Electron main process and display notifications
195 // to the user based on the update status (e.g., update available, downloading, downloaded, installed, or error).
196 if (window.electronUI && typeof window.electronUI.notifyAppAutoUpdate === 'function') {
197 window.electronUI.notifyAppAutoUpdate((data)=>{
198 if (data?.check_version_update) {
199 pgAdmin.Browser.check_version_update(true);
200 } else if (data.update_downloading) {
201 appAutoUpdateNotifier('Update downloading.', 'info', null, 10000);
202 } else if (data.no_update_available) {
203 appAutoUpdateNotifier('No update available.', 'info', null, 10000);
204 } else if (data.update_downloaded) {
205 const UPDATE_DOWNLOADED_MESSAGE = gettext('An update is ready. Restart the app now to install it, or later to keep using the current version.');
206 appAutoUpdateNotifier(UPDATE_DOWNLOADED_MESSAGE, 'warning', installUpdate, null, 'Update downloaded', 'update_downloaded');
207 } else if (data.error) {
208 appAutoUpdateNotifier(`${data.errMsg}`, 'error');
209 } else if (data.update_installed) {
210 const UPDATE_INSTALLED_MESSAGE = gettext('Update installed successfully!');
211 appAutoUpdateNotifier(UPDATE_INSTALLED_MESSAGE, 'success');
212 }
213 });
214 }
215
216 useEffect(()=>{
217 if(uiReady) {
218 pgAdmin?.Browser?.uiloaded?.();
219 }

Callers

nothing calls this directly

Calls 7

getBrowserFunction · 0.90
useBeforeUnloadFunction · 0.90
appAutoUpdateNotifierFunction · 0.90
gettextFunction · 0.85
forceCloseFunction · 0.85
focusMethod · 0.80
confirmMethod · 0.80

Tested by

no test coverage detected