mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-15 11:12:25 -06:00
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:
parent
16d1df2a1b
commit
f2876cabe8
@ -34,6 +34,7 @@ from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
|
||||
|
||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||
from pgadmin.model import db, Server, Database
|
||||
from pgadmin.browser.utils import underscore_escape
|
||||
|
||||
|
||||
class DatabaseModule(CollectionNodeModule):
|
||||
@ -1041,7 +1042,8 @@ class DatabaseView(PGChildNodeView):
|
||||
auto_reconnect=True)
|
||||
status, errmsg = conn.connect()
|
||||
|
||||
return internal_server_error(errormsg=msg)
|
||||
return internal_server_error(
|
||||
errormsg=underscore_escape(msg))
|
||||
|
||||
return make_json_response(success=1)
|
||||
|
||||
|
@ -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,
|
||||
};
|
@ -35,6 +35,7 @@ import CustomPropTypes from '../../../../../../static/js/custom_prop_types';
|
||||
import ConfirmTransactionContent from '../dialogs/ConfirmTransactionContent';
|
||||
import { isMac } from '../../../../../../static/js/keyboard_shortcuts';
|
||||
import { LayoutDocker } from '../../../../../../static/js/helpers/Layout';
|
||||
import CloseRunningDialog from '../dialogs/CloseRunningDialog';
|
||||
|
||||
const useStyles = makeStyles((theme)=>({
|
||||
root: {
|
||||
@ -288,8 +289,22 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
|
||||
};
|
||||
const warnTxnClose = ()=>{
|
||||
if(!isInTxn() || !queryToolCtx.preferences?.sqleditor.prompt_commit_transaction) {
|
||||
eventBus.fireEvent(QUERY_TOOL_EVENTS.FORCE_CLOSE_PANEL);
|
||||
return;
|
||||
/* This will show Close query tool dialog if there is any query running and transaction is active i.e queryToolConnCtx.connectionStatus is 1 */
|
||||
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)=>(
|
||||
<ConfirmTransactionContent
|
||||
|
Loading…
Reference in New Issue
Block a user