Added tab title placeholder for Query Tool, View/Edit Data, and Debugger. Fixes #4232

This commit is contained in:
Nikhil Mohite
2020-10-20 15:41:54 +05:30
committed by Akshay Joshi
parent 38b90f7b00
commit 18cad32bd4
18 changed files with 317 additions and 112 deletions

View File

@@ -85,6 +85,19 @@ class DebuggerModule(PgAdminModule):
'will be opened in a new browser tab.')
)
self.tab_title = self.preference.register(
'display', 'debugger_tab_title_placeholder',
gettext("Tab title"),
'text', '%FUNCTION%(%ARGS%)',
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Supported placeholders are %FUNCTION%, %ARGS%, %SCHEMA% and'
' %DATABASE%. Users can provide any string with or '
'without placeholders of their choice. The blank title will be'
' revert back to the default title with placeholders.'
)
)
self.preference.register(
'keyboard_shortcuts', 'btn_start',
gettext('Accesskey (Continue/Start)'), 'keyboardshortcut',

View File

@@ -427,6 +427,7 @@ define([
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
debuggerUtils.setDebuggerTitle(panel, self.preferences, treeInfo.function.label, treeInfo.schema.label, treeInfo.database.label);
panel.focus();
@@ -549,6 +550,7 @@ define([
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
debuggerUtils.setDebuggerTitle(panel, self.preferences, newTreeInfo.function.label, newTreeInfo.schema.label, newTreeInfo.database.label);
panel.focus();

View File

@@ -10,9 +10,9 @@
define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser',
'pgadmin.backgrid', 'sources/window', 'wcdocker',
'pgadmin.backgrid', 'sources/window', 'pgadmin.tools.debugger.utils', 'wcdocker',
], function(
gettext, url_for, $, _, Backbone, Alertify, pgAdmin, pgBrowser, Backgrid, pgWindow
gettext, url_for, $, _, Backbone, Alertify, pgAdmin, pgBrowser, Backgrid, pgWindow, debuggerUtils
) {
var wcDocker = window.wcDocker;
@@ -773,6 +773,7 @@ define([
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
debuggerUtils.setDebuggerTitle(panel, self.preferences, treeInfo.function.label, treeInfo.schema.label, treeInfo.database.label);
panel.focus();

View File

@@ -42,8 +42,54 @@ function getProcedureId(treeInfoObject) {
return objectId;
}
function setDebuggerTitle(panel, preferences, function_name, schema_name, database_name) {
var debugger_title_placeholder = preferences['debugger_tab_title_placeholder'];
var placeholders = debugger_title_placeholder.split('%');
var title = '';
placeholders.forEach(function(placeholder) {
if(placeholder == 'FUNCTION'){
var func_name = '';
func_name = get_function_name(function_name);
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>');
}
function get_function_name(function_name) {
var function_data = function_name.split('(');
function_data.splice(-1, 1);
var index = 0;
var func_name = '';
for(index=0; index < function_data.length; index++) {
func_name = func_name.concat(function_data[index]);
if (index != function_data.length -1) {
func_name = func_name.concat('(');
}
}
return func_name;
}
module.exports = {
setFocusToDebuggerEditor: setFocusToDebuggerEditor,
getFunctionId: getFunctionId,
getProcedureId: getProcedureId,
setDebuggerTitle: setDebuggerTitle,
};