1. Fixed an issue where database name was missing in an error message if name contains any special characters. #6488

2. Add a confirmation dialog before closing a query tool when a query is already running.
This commit is contained in:
Anil Sahoo 2023-11-30 18:23:52 +05:30 committed by GitHub
parent 16d1df2a1b
commit f2876cabe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 3 deletions

View File

@ -34,6 +34,7 @@ from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.model import db, Server, Database from pgadmin.model import db, Server, Database
from pgadmin.browser.utils import underscore_escape
class DatabaseModule(CollectionNodeModule): class DatabaseModule(CollectionNodeModule):
@ -1041,7 +1042,8 @@ class DatabaseView(PGChildNodeView):
auto_reconnect=True) auto_reconnect=True)
status, errmsg = conn.connect() status, errmsg = conn.connect()
return internal_server_error(errormsg=msg) return internal_server_error(
errormsg=underscore_escape(msg))
return make_json_response(success=1) return make_json_response(success=1)

View File

@ -0,0 +1,33 @@
import React from 'react';
import { useModalStyles } from '../../../../../../static/js/helpers/ModalProvider';
import gettext from 'sources/gettext';
import { Box } from '@material-ui/core';
import { DefaultButton, PrimaryButton } from '../../../../../../static/js/components/Buttons';
import CloseIcon from '@material-ui/icons/CloseRounded';
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
import HTMLReactParser from 'html-react-parser';
import PropTypes from 'prop-types';
export default function CloseRunningDialog({closeModal, text, onYes}) {
const classes = useModalStyles();
return (
<Box display="flex" flexDirection="column" height="100%">
<Box flexGrow="1" p={2}>{typeof(text) == 'string' ? HTMLReactParser(text) : text}</Box>
<Box className={classes.footer}>
<DefaultButton data-test="no" startIcon={<CloseIcon />} onClick={()=>{
closeModal();
}} >{gettext('No')}</DefaultButton>
<PrimaryButton data-test="yes" className={classes.margin} startIcon={<CheckRoundedIcon />} onClick={()=>{
onYes?.();
closeModal();
}} >{gettext('Yes')}</PrimaryButton>
</Box>
</Box>
);
}
CloseRunningDialog.propTypes = {
closeModal: PropTypes.func,
text: PropTypes.string,
onYes: PropTypes.func,
};

View File

@ -35,6 +35,7 @@ import CustomPropTypes from '../../../../../../static/js/custom_prop_types';
import ConfirmTransactionContent from '../dialogs/ConfirmTransactionContent'; import ConfirmTransactionContent from '../dialogs/ConfirmTransactionContent';
import { isMac } from '../../../../../../static/js/keyboard_shortcuts'; import { isMac } from '../../../../../../static/js/keyboard_shortcuts';
import { LayoutDocker } from '../../../../../../static/js/helpers/Layout'; import { LayoutDocker } from '../../../../../../static/js/helpers/Layout';
import CloseRunningDialog from '../dialogs/CloseRunningDialog';
const useStyles = makeStyles((theme)=>({ const useStyles = makeStyles((theme)=>({
root: { root: {
@ -288,8 +289,22 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
}; };
const warnTxnClose = ()=>{ const warnTxnClose = ()=>{
if(!isInTxn() || !queryToolCtx.preferences?.sqleditor.prompt_commit_transaction) { if(!isInTxn() || !queryToolCtx.preferences?.sqleditor.prompt_commit_transaction) {
eventBus.fireEvent(QUERY_TOOL_EVENTS.FORCE_CLOSE_PANEL); /* This will show Close query tool dialog if there is any query running and transaction is active i.e queryToolConnCtx.connectionStatus is 1 */
return; if(queryToolConnCtx.connectionStatus==CONNECTION_STATUS.TRANSACTION_STATUS_ACTIVE){
queryToolCtx.modal.showModal(gettext('Close query tool?'), (closeModal)=>(
<CloseRunningDialog
closeModal={closeModal}
text={gettext('There is an active query running currently. Are you sure you want to close?')}
onYes={()=>{
eventBus.fireEvent(QUERY_TOOL_EVENTS.FORCE_CLOSE_PANEL);
}}
/>
));
return;
} else {
eventBus.fireEvent(QUERY_TOOL_EVENTS.FORCE_CLOSE_PANEL);
return;
}
} }
queryToolCtx.modal.showModal(gettext('Commit transaction?'), (closeModal)=>( queryToolCtx.modal.showModal(gettext('Commit transaction?'), (closeModal)=>(
<ConfirmTransactionContent <ConfirmTransactionContent