mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that the query tool creates a new tab with the appropriate user when pressing Alt+Shift+Q. #5210 (#5350)
This commit is contained in:
@@ -25,7 +25,8 @@ Housekeeping
|
||||
Bug fixes
|
||||
*********
|
||||
|
||||
| `Issue #5188 <https://github.com/pgadmin-org/pgadmin4/issues/5188>`_ - Ensure that the continue/start button should be disabled if the user stops the Debugger for the procedures.
|
||||
| `Issue #5210 <https://github.com/pgadmin-org/pgadmin4/issues/5210>`_ - Ensure that the query tool creates a new tab with the appropriate user when pressing Alt+Shift+Q.
|
||||
| `Issue #5249 <https://github.com/pgadmin-org/pgadmin4/issues/5249>`_ - Added the ability to display the selected text from the query tool in the find/replace box.
|
||||
| `Issue #5262 <https://github.com/pgadmin-org/pgadmin4/issues/5262>`_ - Ensure that the user management dialog should not allow the same email addresses with different letter casings when creating users.
|
||||
| `Issue #5308 <https://github.com/pgadmin-org/pgadmin4/issues/5308>`_ - Ensure that the default value for a column should be used if it is made empty.
|
||||
| `Issue #5188 <https://github.com/pgadmin-org/pgadmin4/issues/5188>`_ - Ensure that the continue/start button should be disabled if the user stops the Debugger for the procedures.
|
||||
|
||||
@@ -284,14 +284,9 @@ def panel(trans_id):
|
||||
if request.args:
|
||||
params = {k: v for k, v in request.args.items()}
|
||||
|
||||
close_url = ''
|
||||
if request.form:
|
||||
params['title'] = request.form['title']
|
||||
close_url = request.form['close_url']
|
||||
if 'sql_filter' in request.form:
|
||||
params['sql_filter'] = request.form['sql_filter']
|
||||
if 'query_url' in request.form:
|
||||
params['query_url'] = request.form['query_url']
|
||||
for key, val in request.form.items():
|
||||
params[key] = val
|
||||
|
||||
params['trans_id'] = trans_id
|
||||
|
||||
@@ -318,7 +313,8 @@ def panel(trans_id):
|
||||
params['fgcolor'] = s.fgcolor or 'black'
|
||||
|
||||
params['server_name'] = underscore_escape(s.name)
|
||||
params['username'] = underscore_escape(s.username)
|
||||
if 'user' not in params:
|
||||
params['user'] = underscore_escape(s.username)
|
||||
params['layout'] = get_setting('SQLEditor/Layout')
|
||||
params['macros'] = get_user_macros()
|
||||
params['is_desktop_mode'] = current_app.PGADMIN_RUNTIME
|
||||
@@ -327,7 +323,6 @@ def panel(trans_id):
|
||||
|
||||
return render_template(
|
||||
"sqleditor/index.html",
|
||||
close_url=close_url,
|
||||
title=underscore_unescape(params['title']),
|
||||
params=json.dumps(params),
|
||||
requirejs=True,
|
||||
@@ -359,15 +354,21 @@ def initialize_sqleditor(trans_id, sgid, sid, did=None):
|
||||
# Read the data if present. Skipping read may cause connection
|
||||
# reset error if data is sent from the client
|
||||
if request.data:
|
||||
_ = request.data
|
||||
data = json.loads(request.data, encoding='utf-8')
|
||||
|
||||
req_args = request.args
|
||||
if ('recreate' in req_args and
|
||||
req_args['recreate'] == '1'):
|
||||
connect = False
|
||||
|
||||
kwargs = {
|
||||
'user': data['user'] if 'user' in data else None,
|
||||
'role': data['role'] if 'role' in data else None,
|
||||
'password': None
|
||||
}
|
||||
|
||||
is_error, errmsg, conn_id, version = _init_sqleditor(
|
||||
trans_id, connect, sgid, sid, did)
|
||||
trans_id, connect, sgid, sid, did, **kwargs)
|
||||
if is_error:
|
||||
return errmsg
|
||||
|
||||
@@ -2437,8 +2438,9 @@ def clear_query_history(trans_id):
|
||||
status, error_msg, conn, trans_obj, session_ob = \
|
||||
check_transaction_status(trans_id)
|
||||
|
||||
filter = request.get_json(silent=True)
|
||||
return QueryHistory.clear(current_user.id, trans_obj.sid, conn.db, filter)
|
||||
filter_json = request.get_json(silent=True)
|
||||
return QueryHistory.clear(current_user.id, trans_obj.sid, conn.db,
|
||||
filter_json)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
|
||||
@@ -13,7 +13,6 @@ import * as toolBar from 'pgadmin.browser.toolbar';
|
||||
import * as panelTitleFunc from './sqleditor_title';
|
||||
import * as commonUtils from 'sources/utils';
|
||||
import $ from 'jquery';
|
||||
import url_for from 'sources/url_for';
|
||||
import _ from 'lodash';
|
||||
import pgWindow from 'sources/window';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
@@ -258,7 +257,7 @@ export default class SQLEditor {
|
||||
}
|
||||
|
||||
|
||||
openQueryToolPanel(trans_id, is_query_tool, panel_title, closeUrl, queryToolForm) {
|
||||
openQueryToolPanel(trans_id, is_query_tool, panel_title, queryToolForm) {
|
||||
let self = this;
|
||||
let browser_preferences = pgBrowser.get_preferences_for_module('browser');
|
||||
let propertiesPanel = pgBrowser.docker.findPanels('properties');
|
||||
@@ -310,21 +309,24 @@ export default class SQLEditor {
|
||||
openQueryToolURL(queryToolPanel);
|
||||
}
|
||||
|
||||
launch(trans_id, panel_url, is_query_tool, panel_title, sURL=null, sql_filter=null) {
|
||||
launch(trans_id, panel_url, is_query_tool, panel_title, params={}) {
|
||||
const self = this;
|
||||
let closeUrl = url_for('sqleditor.close', {'trans_id': trans_id});
|
||||
let queryToolForm = `
|
||||
<form id="queryToolForm" action="${panel_url}" method="post">
|
||||
<input id="title" name="title" hidden />
|
||||
<input id="conn_title" name="conn_title" hidden />
|
||||
<input name="close_url" value="${closeUrl}" hidden />`;
|
||||
<input id="title" name="title" hidden />`;
|
||||
|
||||
|
||||
if(sURL && typeof(sURL) === 'string'){
|
||||
queryToolForm +=`<input name="query_url" value="${sURL}" hidden />`;
|
||||
if(params.query_url && typeof(params.query_url) === 'string'){
|
||||
queryToolForm +=`<input name="query_url" value="${params.query_url}" hidden />`;
|
||||
}
|
||||
if(sql_filter) {
|
||||
queryToolForm +=`<textarea name="sql_filter" hidden>${sql_filter}</textarea>`;
|
||||
if(params.sql_filter) {
|
||||
queryToolForm +=`<textarea name="sql_filter" hidden>${params.sql_filter}</textarea>`;
|
||||
}
|
||||
if(params.user) {
|
||||
queryToolForm +=`<input name="user" value="${_.escape(params.user)}" hidden />`;
|
||||
}
|
||||
if(params.role) {
|
||||
queryToolForm +=`<input name="role" value="${_.escape(params.role)}" hidden />`;
|
||||
}
|
||||
|
||||
/* Escape backslashes as it is stripped by back end */
|
||||
@@ -354,7 +356,7 @@ export default class SQLEditor {
|
||||
/* On successfully initialization find the dashboard panel,
|
||||
* create new panel and add it to the dashboard panel.
|
||||
*/
|
||||
self.openQueryToolPanel(trans_id, is_query_tool, panel_title, closeUrl, queryToolForm);
|
||||
self.openQueryToolPanel(trans_id, is_query_tool, panel_title, queryToolForm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,14 +100,14 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
sgid: params.sgid,
|
||||
sid: params.sid,
|
||||
did: params.did,
|
||||
user: _.unescape(params.username),
|
||||
role: null,
|
||||
user: _.unescape(params.user),
|
||||
role: _.unescape(params.role),
|
||||
title: _.unescape(params.title),
|
||||
fgcolor: params.fgcolor,
|
||||
bgcolor: params.bgcolor,
|
||||
conn_title: getTitle(
|
||||
pgAdmin, null, selectedNodeInfo, true, _.unescape(params.server_name), _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo),
|
||||
_.unescape(params.username), params.is_query_tool == 'true' ? true : false),
|
||||
_.unescape(params.role) || _.unescape(params.user), params.is_query_tool == 'true' ? true : false),
|
||||
server_name: _.unescape(params.server_name),
|
||||
database_name: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo),
|
||||
is_selected: true,
|
||||
@@ -259,7 +259,10 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
...qtState.params,
|
||||
});
|
||||
}
|
||||
api.post(baseUrl, qtState.params.is_query_tool ? null : JSON.stringify(qtState.params.sql_filter))
|
||||
api.post(baseUrl, qtState.params.is_query_tool ? {
|
||||
user: qtState.params.user,
|
||||
role: qtState.params.role,
|
||||
} : JSON.stringify(qtState.params.sql_filter))
|
||||
.then(()=>{
|
||||
setQtState({
|
||||
connected: true,
|
||||
@@ -578,7 +581,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
sid: data.sid,
|
||||
did: data.did,
|
||||
user: data.user,
|
||||
role: data.role ?? null,
|
||||
role: data.role,
|
||||
password: data.password,
|
||||
title: getTitle(pgAdmin, qtState.preferences.browser, null, false, data.server_name, data.database_name, data.role || data.user, true),
|
||||
conn_title: getTitle(pgAdmin, null, null, true, data.server_name, data.database_name, data.role || data.user, true),
|
||||
@@ -629,8 +632,11 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
};
|
||||
|
||||
const gridUrl = showQueryTool.generateUrl(transId, parentData, null);
|
||||
const title = getTitle(pgAdmin, qtState.preferences.browser, null, false, selectedConn.server_name, selectedConn.database_name, selectedConn.user);
|
||||
showQueryTool.launchQueryTool(pgWindow.pgAdmin.Tools.SQLEditor, transId, gridUrl, title, '');
|
||||
const title = getTitle(pgAdmin, qtState.preferences.browser, null, false, selectedConn.server_name, selectedConn.database_name, selectedConn.role || selectedConn.user);
|
||||
showQueryTool.launchQueryTool(pgWindow.pgAdmin.Tools.SQLEditor, transId, gridUrl, title, {
|
||||
user: selectedConn.user,
|
||||
role: selectedConn.role,
|
||||
});
|
||||
};
|
||||
|
||||
const onManageMacros = useCallback(()=>{
|
||||
@@ -734,7 +740,8 @@ QueryToolComponent.propTypes = {
|
||||
bgcolor: PropTypes.string,
|
||||
fgcolor: PropTypes.string,
|
||||
is_query_tool: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]).isRequired,
|
||||
username: PropTypes.string,
|
||||
user: PropTypes.string,
|
||||
role: PropTypes.string,
|
||||
server_name: PropTypes.string,
|
||||
database_name: PropTypes.string,
|
||||
layout: PropTypes.string,
|
||||
|
||||
@@ -135,9 +135,9 @@ export function ConnectionBar({connected, connecting, connectionStatus, connecti
|
||||
onClose={()=>{setConnDropdownOpen(false);}}
|
||||
className={classes.menu}
|
||||
>
|
||||
{(connectionList||[]).map((conn)=>{
|
||||
{(connectionList||[]).map((conn, i)=>{
|
||||
return (
|
||||
<PgMenuItem key={conn.conn_title} hasCheck checked={conn.is_selected} value={conn}
|
||||
<PgMenuItem key={i+conn.conn_title} hasCheck checked={conn.is_selected} value={conn}
|
||||
onClick={onConnItemClick}>{conn.conn_title}</PgMenuItem>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -50,7 +50,6 @@ function generateTitle(pgBrowser, treeIdentifier) {
|
||||
}
|
||||
|
||||
export function showQueryTool(queryToolMod, pgBrowser, url, treeIdentifier, transId) {
|
||||
const sURL = url || '';
|
||||
const queryToolTitle = generateTitle(pgBrowser, treeIdentifier);
|
||||
|
||||
const currentNode = pgBrowser.tree.findNodeByDomElement(treeIdentifier);
|
||||
@@ -69,7 +68,7 @@ export function showQueryTool(queryToolMod, pgBrowser, url, treeIdentifier, tran
|
||||
}
|
||||
|
||||
const gridUrl = generateUrl(transId, parentData);
|
||||
launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, sURL);
|
||||
launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, {query_url: url});
|
||||
}
|
||||
|
||||
export function generateScript(parentData, queryToolMod) {
|
||||
@@ -108,11 +107,11 @@ export function showERDSqlTool(parentData, erdSqlId, queryToolTitle, queryToolMo
|
||||
};
|
||||
|
||||
const gridUrl = generateUrl(transId, parentData, erdSqlId);
|
||||
launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, '');
|
||||
launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, {});
|
||||
}
|
||||
|
||||
export function launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, sURL) {
|
||||
let retVal = queryToolMod.launch(transId, gridUrl, true, queryToolTitle, sURL);
|
||||
export function launchQueryTool(queryToolMod, transId, gridUrl, queryToolTitle, params) {
|
||||
let retVal = queryToolMod.launch(transId, gridUrl, true, queryToolTitle, params);
|
||||
|
||||
if(!retVal) {
|
||||
Notify.alert(
|
||||
|
||||
@@ -165,7 +165,7 @@ function showFilterDialog(pgBrowser, treeNodeInfo, queryToolMod, transId,
|
||||
let helpUrl = url_for('help.static', {'filename': 'viewdata_filter.html'});
|
||||
|
||||
let okCallback = function() {
|
||||
queryToolMod.launch(transId, gridUrl, false, queryToolTitle, null, schema._sessData.filter_sql);
|
||||
queryToolMod.launch(transId, gridUrl, false, queryToolTitle, null, {sql_filter: schema._sessData.filter_sql});
|
||||
};
|
||||
|
||||
getUtilityView(schema, treeNodeInfo, 'create', 'dialog', j[0], panel,
|
||||
|
||||
Reference in New Issue
Block a user