Fixed the following issues:

RM-4232:
1. If the user adds a percentage (other than for placeholders) then it is stripped off.
2. Backslash is getting removed in the connection string if we provide the backslash(\) in placeholders or the database name contains it.
3. If the user added only spaces( )in placeholders it is not getting reset to default values.

RM-4230:
1. Rename panel option is not working in the debugger.
2. Added Rename panel for schema diff.

Fixes #4232 #4230
pull/37/head
Nikhil Mohite 2020-10-27 11:03:00 +05:30 committed by Akshay Joshi
parent 892fb83907
commit b5f9fffadd
9 changed files with 75 additions and 77 deletions

View File

@ -202,6 +202,12 @@ def save(pid):
"""
data = request.form if request.form else json.loads(request.data.decode())
if data['name'] in ['vw_edt_tab_title_placeholder',
'qt_tab_title_placeholder',
'debugger_tab_title_placeholder']:
if data['value'].isspace():
data['value'] = ''
res, msg = Preferences.save(
data['mid'], data['category_id'], data['id'], data['value'])
sgm.get_nodes(sgm)

View File

@ -201,22 +201,17 @@ let NewConnectionDialog = {
let tab_title = '';
var qt_title_placeholder = preferences['qt_tab_title_placeholder'];
var placeholders = qt_title_placeholder.split('%');
placeholders.forEach(function(placeholder) {
if(placeholder == 'DATABASE'){
tab_title = tab_title.concat(selected_database_name);
} else if(placeholder == 'USERNAME') {
if(newConnCollectionModel['role']) {
tab_title = tab_title.concat(newConnCollectionModel['role']);
} else {
tab_title = tab_title.concat(newConnCollectionModel['user']);
}
} else if(placeholder == 'SERVER') {
tab_title = tab_title.concat(response.server_name);
} else{
tab_title = tab_title.concat(placeholder);
}
});
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%DATABASE%'), selected_database_name);
if(newConnCollectionModel['role']) {
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%USERNAME%'), newConnCollectionModel['role']);
} else {
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%USERNAME%'), newConnCollectionModel['user']);
}
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%SERVER%'), response.server_name);
tab_title = qt_title_placeholder;
if(!newConnCollectionModel['role']) {
newConnCollectionModel['role'] = null;

View File

@ -224,10 +224,11 @@ define('pgadmin.datagrid', [
queryToolForm +=`<textarea name="sql_filter" hidden>${sql_filter}</textarea>`;
}
/* Escape backslashes as it is stripped by back end */
queryToolForm +=`
</form>
<script>
document.getElementById("title").value = "${_.escape(panel_title)}";
document.getElementById("title").value = "${_.escape(panel_title.replace('\\', '\\\\'))}";
document.getElementById("queryToolForm").submit();
</script>
`;

View File

@ -39,20 +39,11 @@ export function getPanelTitle(pgBrowser, selected_item=null, custom_title=null)
qt_title_placeholder = preferences['qt_tab_title_placeholder'];
}
var placeholders = qt_title_placeholder.split('%');
var title = '';
placeholders.forEach(function(placeholder) {
if(placeholder == 'DATABASE'){
title = title.concat(db_label);
} else if(placeholder == 'USERNAME') {
title = title.concat(parentData.server.user.name);
} else if(placeholder == 'SERVER') {
title = title.concat(parentData.server.label);
} else{
title = title.concat(placeholder);
}
});
return _.escape(title);
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%DATABASE%'), db_label);
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%USERNAME%'), parentData.server.user.name);
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%SERVER%'), parentData.server.label);
return _.escape(qt_title_placeholder);
}
export function setQueryToolDockerTitle(panel, is_query_tool, panel_title, is_file) {

View File

@ -297,23 +297,11 @@ export function generateDatagridTitle(pgBrowser, aciTreeIdentifier, custom_title
dtg_title_placeholder = preferences['vw_edt_tab_title_placeholder'];
}
var placeholders = dtg_title_placeholder.split('%');
var title = '';
placeholders.forEach(function(placeholder) {
if(placeholder == 'DATABASE'){
title = title.concat(db_label);
} else if(placeholder == 'USERNAME') {
title = title.concat(parentData.server.user.name);
} else if(placeholder == 'SERVER') {
title = title.concat(parentData.server.label);
} else if(placeholder == 'SCHEMA') {
title = title.concat(namespaceName);
} else if(placeholder == 'TABLE') {
title = title.concat(node.getData().label);
} else{
title = title.concat(placeholder);
}
});
dtg_title_placeholder = dtg_title_placeholder.replace(new RegExp('%DATABASE%'), db_label);
dtg_title_placeholder = dtg_title_placeholder.replace(new RegExp('%USERNAME%'), parentData.server.user.name);
dtg_title_placeholder = dtg_title_placeholder.replace(new RegExp('%SERVER%'), parentData.server.label);
dtg_title_placeholder = dtg_title_placeholder.replace(new RegExp('%SCHEMA%'), namespaceName);
dtg_title_placeholder = dtg_title_placeholder.replace(new RegExp('%TABLE%'), node.getData().label);
return _.escape(title);
return _.escape(dtg_title_placeholder);
}

View File

@ -579,6 +579,21 @@ define([
method: 'DELETE',
});
});
// Panel Rename event
panel.on(wcDocker.EVENT.RENAME, function(panel_data) {
Alertify.prompt('', panel_data.$titleText[0].textContent,
// We will execute this function when user clicks on the OK button
function(evt, value) {
if(value) {
debuggerUtils.setDebuggerTitle(panel, self.preferences, treeInfo.function.label, treeInfo.schema.label, treeInfo.database.label, value);
}
},
// We will execute this function when user clicks on the Cancel
// button. Do nothing just close it.
function(evt) { evt.cancel = false; }
).set({'title': gettext('Rename Panel')});
});
}
})
.fail(function(e) {

View File

@ -50,33 +50,21 @@ function setDebuggerTitle(panel, preferences, function_name, schema_name, databa
debugger_title_placeholder = preferences['debugger_tab_title_placeholder'];
}
var placeholders = debugger_title_placeholder.split('%');
var function_data = function_name.split('(');
function_name = get_function_name(function_name);
var title = '';
placeholders.forEach(function(placeholder) {
if(placeholder == 'FUNCTION'){
var func_name = '';
func_name = get_function_name(function_name);
var args_list = function_data[function_data.length - 1].split(')');
var args = '';
if(args_list.length > 0) {
args = args.concat(args_list[0]);
}
title = title.concat(func_name);
} else if(placeholder == 'ARGS') {
var args = '';
var function_data = function_name.split('(');
var args_list = function_data[function_data.length - 1].split(')');
if(args_list.length > 0) {
args = args.concat(args_list[0]);
}
function_name = get_function_name(function_name);
title = title.concat(args);
} else if(placeholder == 'SCHEMA'){
title = title.concat(schema_name);
} else if(placeholder == 'DATABASE'){
title = title.concat(database_name);
} else if (placeholder != 'ARGS' ){
title = title.concat(placeholder);
}
});
panel.title('<span>'+ _.escape(title) +'</span>');
debugger_title_placeholder = debugger_title_placeholder.replace(new RegExp('%FUNCTION%'), function_name);
debugger_title_placeholder = debugger_title_placeholder.replace(new RegExp('%ARGS%'), args);
debugger_title_placeholder = debugger_title_placeholder.replace(new RegExp('%SCHEMA%'), schema_name);
debugger_title_placeholder = debugger_title_placeholder.replace(new RegExp('%DATABASE%'), database_name);
panel.title('<span>'+ _.escape(debugger_title_placeholder) +'</span>');
}
function get_function_name(function_name) {

View File

@ -9,9 +9,9 @@
define('pgadmin.schemadiff', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/pgadmin', 'sources/csrf', 'pgadmin.browser.node',
'sources/pgadmin', 'sources/csrf', 'pgadmin.alertifyjs', 'pgadmin.browser.node',
], function(
gettext, url_for, $, _, pgAdmin, csrfToken
gettext, url_for, $, _, pgAdmin, csrfToken, Alertify,
) {
var wcDocker = window.wcDocker,
@ -113,6 +113,21 @@ define('pgadmin.schemadiff', [
var propertiesPanel = pgBrowser.docker.findPanels('properties'),
schemaDiffPanel = pgBrowser.docker.addPanel('frm_schemadiff', wcDocker.DOCK.STACKED, propertiesPanel[0]);
// Rename schema diff tab
schemaDiffPanel.on(wcDocker.EVENT.RENAME, function(panel_data) {
Alertify.prompt('', panel_data.$titleText[0].textContent,
// We will execute this function when user clicks on the OK button
function(evt, value) {
if(value) {
schemaDiffPanel.title('<span>'+ _.escape(value) +'</span>');
}
},
// We will execute this function when user clicks on the Cancel
// button. Do nothing just close it.
function(evt) { evt.cancel = false; }
).set({'title': gettext('Rename Panel')});
});
// Set panel title and icon
schemaDiffPanel.title('<span title="'+panel_tooltip+'">'+panel_title+'</span>');
schemaDiffPanel.icon('pg-font-icon icon-schema-diff');

View File

@ -108,7 +108,6 @@ export default class SchemaDiffUI {
this.resize_panels();
}.bind(self), 200);
});
}
raise_error_on_fail(alert_title, xhr) {