diff --git a/docs/en_US/release_notes_8_10.rst b/docs/en_US/release_notes_8_10.rst index f80bef4e2..30ec01e1e 100644 --- a/docs/en_US/release_notes_8_10.rst +++ b/docs/en_US/release_notes_8_10.rst @@ -34,13 +34,15 @@ Housekeeping Bug fixes ********* + | `Issue #3199 `_ - Fixed an issue where paste operation in query tool data grid should skip bytea columns and put the value as NULL instead. | `Issue #4165 `_ - Fixed an issue where the taskbar icon appeared as a red square for the query tool and schema diff when opened in a new window. | `Issue #5345 `_ - Fix issue with missing new added records in download file. | `Issue #5610 `_ - Fixed an issue where the File Open dialog did not show files without a dot extension. | `Issue #6548 `_ - Ensure pgAdmin never makes network requests to Google etc. - | `Issue #6571 `_ - Fixed an issue where pop-up notifications from Object Explorer wouldn't get dismissed automatically if the Query Tool was open. + | `Issue #6571 `_ - Fixed an issue where pop-up notifications from Object Explorer wouldn't get dismissed automatically if the Query Tool was opened. | `Issue #7035 `_ - Fixed the permission denied issue for functions of the pgstattuple extension when accessing statistics with a non-admin user. | `Issue #7511 `_ - Fixed an issue where users could not insert characters at the desired location, as it was added to the end of the line. | `Issue #7554 `_ - Fixed an issue where sorting the database activity table on the dashboard by any column caused the details to expand in the wrong position. | `Issue #7618 `_ - Fix an issue where the preferences JSON file has no effect when an external database is used. | `Issue #7627 `_ - Fixed an issue where users could not autofill their saved passwords in the connect server dialog in the browser. + | `Issue #7638 `_ - Fixed an issue where Generate Script button should be disabled if no objects are selected in the schema diff result. diff --git a/web/pgadmin/static/js/BrowserComponent.jsx b/web/pgadmin/static/js/BrowserComponent.jsx index 5983d1a70..b2cdc2955 100644 --- a/web/pgadmin/static/js/BrowserComponent.jsx +++ b/web/pgadmin/static/js/BrowserComponent.jsx @@ -21,6 +21,7 @@ import usePreferences from '../../preferences/static/js/store'; import { getBrowser } from './utils'; import PropTypes from 'prop-types'; import Processes from '../../misc/bgprocess/static/js/Processes'; +import { useBeforeUnload } from './custom_hooks'; const objectExplorerGroup = { @@ -90,9 +91,23 @@ export default function BrowserComponent({pgAdmin}) { ] }, }; - const {isLoading, failed} = usePreferences(); + 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)=>{ + pgAdmin.Browser.notifier.confirm( + gettext('Quit pgAdmin 4'), + gettext('Are you sure you want to quit the application?'), + function() { forceClose(); }, + function() { return true;}, + ); + }, + isNewTab: true, + }); useEffect(()=>{ if(uiReady) { diff --git a/web/pgadmin/static/js/custom_hooks.js b/web/pgadmin/static/js/custom_hooks.js index b0f579e70..085660d57 100644 --- a/web/pgadmin/static/js/custom_hooks.js +++ b/web/pgadmin/static/js/custom_hooks.js @@ -220,13 +220,24 @@ export function useBeforeUnload({enabled, isNewTab, beforeClose, closePanel }) { const onBeforeUnloadElectron = useCallback((e)=>{ e.preventDefault(); e.returnValue = 'prevent'; - beforeClose?.(); + beforeClose?.(forceClose); }, []); - useEffect(()=>{ - if(getBrowser().name == 'Electron') { - window.addEventListener('beforeunload', onBeforeUnloadElectron); + function forceClose() { + if(getBrowser().name == 'Electron' && isNewTab) { + window.removeEventListener('beforeunload', onBeforeUnloadElectron); + // somehow window.close was not working may becuase the removeEventListener + // was not completely executed. Add timeout. + setTimeout(()=>window.close(), 50); } else { + closePanel?.(); + } + } + + useEffect(()=>{ + if(getBrowser().name == 'Electron' && isNewTab) { + window.addEventListener('beforeunload', onBeforeUnloadElectron); + } else if(getBrowser().name != 'Electron') { if(enabled){ window.addEventListener('beforeunload', onBeforeUnload); } else { @@ -240,17 +251,5 @@ export function useBeforeUnload({enabled, isNewTab, beforeClose, closePanel }) { }; }, [enabled]); - - function forceClose() { - if(getBrowser().name == 'Electron' && isNewTab) { - window.removeEventListener('beforeunload', onBeforeUnloadElectron); - // somehow window.close was not working may becuase the removeEventListener - // was not completely executed. Add timeout. - setTimeout(()=>window.close(), 50); - } else { - closePanel?.(); - } - } - return {forceClose}; } diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/components/BeforeUnload.jsx b/web/pgadmin/tools/erd/static/js/erd_tool/components/BeforeUnload.jsx index e16f6d641..0fd2f4e9f 100644 --- a/web/pgadmin/tools/erd/static/js/erd_tool/components/BeforeUnload.jsx +++ b/web/pgadmin/tools/erd/static/js/erd_tool/components/BeforeUnload.jsx @@ -2,13 +2,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useBeforeUnload } from '../../../../../../static/js/custom_hooks'; -export default function BeforeUnload({enabled, isNewTab, beforeClose, closePanel, getForceClose}) { - const {forceClose} = useBeforeUnload( +export default function BeforeUnload({enabled, isNewTab, beforeClose, closePanel}) { + useBeforeUnload( {enabled, isNewTab, beforeClose, closePanel} ); - getForceClose(forceClose); - return <>; } diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/components/ERDTool.jsx b/web/pgadmin/tools/erd/static/js/erd_tool/components/ERDTool.jsx index 64b9d92bb..f78430260 100644 --- a/web/pgadmin/tools/erd/static/js/erd_tool/components/ERDTool.jsx +++ b/web/pgadmin/tools/erd/static/js/erd_tool/components/ERDTool.jsx @@ -357,7 +357,7 @@ export default class ERDTool extends React.Component { } } - confirmBeforeClose() { + confirmBeforeClose(forceClose) { let bodyObj = this; if(this.state.dirty) { this.closeOnSave = false; @@ -366,7 +366,7 @@ export default class ERDTool extends React.Component { closeModal={closeModal} text={gettext('The diagram has changed. Do you want to save changes?')} onDontSave={()=>{ - bodyObj.forceClose(); + forceClose(); }} onSave={()=>{ bodyObj.onSaveDiagram(false, true); @@ -375,7 +375,7 @@ export default class ERDTool extends React.Component { )); return false; } else { - this.forceClose(); + forceClose(); } } @@ -888,11 +888,10 @@ export default class ERDTool extends React.Component { { - this.confirmBeforeClose(); + beforeClose={(forceClose)=>{ + this.confirmBeforeClose(forceClose); }} closePanel={this.closePanel} - getForceClose={(fn)=>this.forceClose = fn} />