mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix issues found in electron testing. #7494
This commit is contained in:
parent
64d7c2c62d
commit
8e16e000c3
@ -38,9 +38,22 @@ let docsURLSubStrings = ['www.enterprisedb.com', 'www.postgresql.org', 'www.pgad
|
||||
process.env['ELECTRON_ENABLE_SECURITY_WARNINGS'] = false;
|
||||
|
||||
// Paths to the rest of the app
|
||||
|
||||
let [pythonPath, pgadminFile] = misc.getAppPaths(__dirname);
|
||||
|
||||
// Do not allow a second instance of pgAdmin to run.
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
if (!gotTheLock) {
|
||||
app.quit();
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (pgAdminMainScreen) {
|
||||
if (pgAdminMainScreen.isMinimized()) pgAdminMainScreen.restore();
|
||||
pgAdminMainScreen.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Override the paths above, if a developer needs to
|
||||
if (fs.existsSync('dev_config.json')) {
|
||||
try {
|
||||
|
@ -1,19 +1,23 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useBeforeUnload } from '../../../../../../static/js/custom_hooks';
|
||||
|
||||
export default function BeforeUnload({enabled, isNewTab, beforeClose, closePanel}) {
|
||||
useBeforeUnload(
|
||||
export default function BeforeUnload({onInit, enabled, isNewTab, beforeClose, closePanel}) {
|
||||
const init = useBeforeUnload(
|
||||
{enabled, isNewTab, beforeClose, closePanel}
|
||||
);
|
||||
|
||||
useEffect(()=>{
|
||||
onInit?.(init);
|
||||
}, [init]);
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
BeforeUnload.propTypes = {
|
||||
onInit: PropTypes.func,
|
||||
enabled: PropTypes.bool,
|
||||
isNewTab: PropTypes.bool,
|
||||
beforeClose: PropTypes.func,
|
||||
closePanel: PropTypes.func,
|
||||
getForceClose: PropTypes.func,
|
||||
closePanel: PropTypes.func
|
||||
};
|
||||
|
@ -357,7 +357,7 @@ export default class ERDTool extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
confirmBeforeClose(forceClose) {
|
||||
confirmBeforeClose() {
|
||||
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={()=>{
|
||||
forceClose();
|
||||
this.forceClose();
|
||||
}}
|
||||
onSave={()=>{
|
||||
bodyObj.onSaveDiagram(false, true);
|
||||
@ -375,7 +375,7 @@ export default class ERDTool extends React.Component {
|
||||
));
|
||||
return false;
|
||||
} else {
|
||||
forceClose();
|
||||
this.forceClose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,11 +886,10 @@ export default class ERDTool extends React.Component {
|
||||
return (
|
||||
<StyledBox ref={this.containerRef} height="100%" display="flex" flexDirection="column">
|
||||
<BeforeUnload
|
||||
onInit={({forceClose})=>{this.forceClose = forceClose;}}
|
||||
enabled={this.state.is_close_tab_warning}
|
||||
isNewTab={this.state.is_new_tab}
|
||||
beforeClose={(forceClose)=>{
|
||||
this.confirmBeforeClose(forceClose);
|
||||
}}
|
||||
beforeClose={this.confirmBeforeClose}
|
||||
closePanel={this.closePanel}
|
||||
/>
|
||||
<ConnectionBar status={this.state.conn_status} bgcolor={this.props.params.bgcolor}
|
||||
|
Loading…
Reference in New Issue
Block a user