{enabled && }
{
pgAdmin.Browser.docker.default_workspace = obj;
}}
defaultLayout={defaultLayout}
layoutId='Browser/Layout'
savedLayout={pgAdmin.Browser.utils.layout['Browser/Layout']}
groups={{
'object-explorer': objectExplorerGroup,
'playground': getMorePanelGroup(defaultTabsData),
}}
noContextGroups={['object-explorer']}
resetToTabPanel={BROWSER_PANELS.MAIN}
enableToolEvents
isLayoutVisible={!enabled || currentWorkspace == WORKSPACES.DEFAULT}
/>
{enabled && config.map((item)=>(
{
pgAdmin.Browser.docker[item.docker] = obj;
obj.eventBus.fireEvent(LAYOUT_EVENTS.INIT);
}}
defaultLayout={item.layout}
layoutId={`Workspace/Layout-${item.workspace}`}
savedLayout={pgAdmin.Browser.utils.layout[`Workspace/Layout-${item.workspace}`]}
groups={{
'playground': item?.tabsData ? getMorePanelGroup(item?.tabsData) : {...getDefaultGroup()},
}}
resetToTabPanel={BROWSER_PANELS.MAIN}
isLayoutVisible={currentWorkspace == item.workspace}
/>
))}
);
}
Layouts.propTypes = {
browser: PropTypes.string,
};
export default function BrowserComponent({pgAdmin}) {
const {isLoading, failed, getPreferencesForModule} = usePreferences();
let { name: browser } = useMemo(()=>getBrowser(), []);
const [uiReady, setUiReady] = useState(false);
const confirmOnClose = getPreferencesForModule('browser').confirm_on_refresh_close;
useBeforeUnload({
enabled: confirmOnClose,
beforeClose: (forceClose)=>{
window.electronUI?.focus();
pgAdmin.Browser.notifier.confirm(
gettext('Quit pgAdmin 4'),
gettext('Are you sure you want to quit the application?'),
function() { forceClose(); },
function() { return true; },
gettext('Yes'),
gettext('No'),
'default',
'id-app-quit'
);
},
isNewTab: true,
});
// Called when Install and Restart btn called for auto-update install
function installUpdate() {
if (window.electronUI) {
window.electronUI.sendDataForAppUpdate({
'install_update_now': true
});
}}
// Listen for auto-update events from the Electron main process and display notifications
// to the user based on the update status (e.g., update available, downloading, downloaded, installed, or error).
if (window.electronUI && typeof window.electronUI.notifyAppAutoUpdate === 'function') {
window.electronUI.notifyAppAutoUpdate((data)=>{
if (data?.check_version_update) {
pgAdmin.Browser.check_version_update(true);
} else if (data.update_downloading) {
appAutoUpdateNotifier('Update downloading.', 'info', null, 10000);
} else if (data.no_update_available) {
appAutoUpdateNotifier('No update available.', 'info', null, 10000);
} else if (data.update_downloaded) {
const UPDATE_DOWNLOADED_MESSAGE = gettext('An update is ready. Restart the app now to install it, or later to keep using the current version.');
appAutoUpdateNotifier(UPDATE_DOWNLOADED_MESSAGE, 'warning', installUpdate, null, 'Update downloaded', 'update_downloaded');
} else if (data.error) {
appAutoUpdateNotifier(`${data.errMsg}`, 'error');
} else if (data.update_installed) {
const UPDATE_INSTALLED_MESSAGE = gettext('Update installed successfully!');
appAutoUpdateNotifier(UPDATE_INSTALLED_MESSAGE, 'success');
}
});
}
useEffect(()=>{
if(uiReady) {
pgAdmin?.Browser?.uiloaded?.();
}
}, [uiReady]);
if(isLoading) {
return <>>;
}
if(failed) {
return <>Failed to load preferences>;
}
return (