diff --git a/web/pgadmin/preferences/__init__.py b/web/pgadmin/preferences/__init__.py
index d05c1c89b..f0085518a 100644
--- a/web/pgadmin/preferences/__init__.py
+++ b/web/pgadmin/preferences/__init__.py
@@ -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)
diff --git a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
index b19a50afc..19bdf7da1 100644
--- a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
+++ b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
@@ -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;
diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js
index 7ea546146..1f0c1b7a9 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js
@@ -224,10 +224,11 @@ define('pgadmin.datagrid', [
queryToolForm +=``;
}
+ /* Escape backslashes as it is stripped by back end */
queryToolForm +=`
`;
diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid_panel_title.js b/web/pgadmin/tools/datagrid/static/js/datagrid_panel_title.js
index 3ddcfade4..e40d0c48f 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid_panel_title.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid_panel_title.js
@@ -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) {
diff --git a/web/pgadmin/tools/datagrid/static/js/show_data.js b/web/pgadmin/tools/datagrid/static/js/show_data.js
index 75371f764..f9ec5a832 100644
--- a/web/pgadmin/tools/datagrid/static/js/show_data.js
+++ b/web/pgadmin/tools/datagrid/static/js/show_data.js
@@ -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);
}
diff --git a/web/pgadmin/tools/debugger/static/js/debugger.js b/web/pgadmin/tools/debugger/static/js/debugger.js
index 61056f2fa..ec9250a68 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger.js
@@ -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) {
diff --git a/web/pgadmin/tools/debugger/static/js/debugger_utils.js b/web/pgadmin/tools/debugger/static/js/debugger_utils.js
index 5525bfc21..2451c6050 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger_utils.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger_utils.js
@@ -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(''+ _.escape(title) +'');
+ 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(''+ _.escape(debugger_title_placeholder) +'');
}
function get_function_name(function_name) {
diff --git a/web/pgadmin/tools/schema_diff/static/js/schema_diff.js b/web/pgadmin/tools/schema_diff/static/js/schema_diff.js
index 209941454..8865df663 100644
--- a/web/pgadmin/tools/schema_diff/static/js/schema_diff.js
+++ b/web/pgadmin/tools/schema_diff/static/js/schema_diff.js
@@ -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(''+ _.escape(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')});
+ });
+
// Set panel title and icon
schemaDiffPanel.title(''+panel_title+'');
schemaDiffPanel.icon('pg-font-icon icon-schema-diff');
diff --git a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
index b3025aa68..fad6485c9 100644
--- a/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
+++ b/web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
@@ -108,7 +108,6 @@ export default class SchemaDiffUI {
this.resize_panels();
}.bind(self), 200);
});
-
}
raise_error_on_fail(alert_title, xhr) {