Fix SQL help for EPAS 10+, and refactor the URL generation code into a testable function. Fixes #4099

This commit is contained in:
Dave Page
2019-03-22 14:09:24 +00:00
parent ae23f146d1
commit ce073a2856
8 changed files with 106 additions and 30 deletions
+7 -13
View File
@@ -11,9 +11,9 @@ define('pgadmin.browser', [
'sources/tree/tree',
'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore', 'underscore.string',
'bootstrap', 'sources/pgadmin', 'pgadmin.alertifyjs', 'bundled_codemirror',
'sources/check_node_visibility', './toolbar', 'pgadmin.browser.utils', 'wcdocker',
'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree', 'pgadmin.browser.preferences',
'pgadmin.browser.messages',
'sources/check_node_visibility', './toolbar', 'pgadmin.help', 'pgadmin.browser.utils',
'wcdocker', 'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree',
'pgadmin.browser.preferences', 'pgadmin.browser.messages',
'pgadmin.browser.menu', 'pgadmin.browser.panel',
'pgadmin.browser.error', 'pgadmin.browser.frame',
'pgadmin.browser.node', 'pgadmin.browser.collection',
@@ -21,8 +21,9 @@ define('pgadmin.browser', [
'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state',
], function(
tree,
gettext, url_for, require, $, _, S, Bootstrap, pgAdmin, Alertify,
codemirror, checkNodeVisibility, toolBar
gettext, url_for, require, $, _, S,
Bootstrap, pgAdmin, Alertify, codemirror,
checkNodeVisibility, toolBar, help
) {
window.jQuery = window.$ = $;
// Some scripts do export their object in the window only.
@@ -653,14 +654,7 @@ define('pgadmin.browser', [
baseUrl = pgBrowser.utils.edbas_help_path;
}
var major = Math.floor(server.version / 10000),
minor = Math.floor(server.version / 100) - (major * 100);
baseUrl = baseUrl.replace('$VERSION$', major + '.' + minor);
if (!S(baseUrl).endsWith('/')) {
baseUrl = baseUrl + '/';
}
var fullUrl = baseUrl + url;
var fullUrl = help.getHelpUrl(baseUrl, url, server.version);
window.open(fullUrl, 'postgres_help');
} else if(type == 'dialog_help') {
+12 -15
View File
@@ -11,11 +11,14 @@ define('pgadmin.browser.node', [
'sources/tree/pgadmin_tree_node', 'sources/url_for',
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin',
'pgadmin.browser.menu', 'backbone', 'pgadmin.alertifyjs', 'pgadmin.browser.datamodel',
'backform', 'sources/browser/generate_url', 'sources/utils', 'pgadmin.browser.utils',
'pgadmin.backform',
'backform', 'sources/browser/generate_url', 'pgadmin.help', 'sources/utils',
'pgadmin.browser.utils', 'pgadmin.backform',
], function(
pgadminTreeNode, url_for,
gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform, generateUrl, commonUtils
gettext, $, _, S, pgAdmin,
Menu, Backbone, Alertify, pgBrowser,
Backform, generateUrl, help,
commonUtils
) {
var wcDocker = window.wcDocker,
@@ -1218,26 +1221,20 @@ define('pgadmin.browser.node', [
url = pgBrowser.utils.edbas_help_path;
}
var major = Math.floor(server.version / 10000),
minor = Math.floor(server.version / 100) - (major * 100);
url = url.replace('$VERSION$', major + '.' + minor);
if (!S(url).endsWith('/')) {
url = url + '/';
}
var fullUrl = '';
if (that.sqlCreateHelp == '' && that.sqlAlterHelp != '') {
url = url + that.sqlAlterHelp;
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version);
} else if (that.sqlCreateHelp != '' && that.sqlAlterHelp == '') {
url = url + that.sqlCreateHelp;
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version);
} else {
if (view.model.isNew()) {
url = url + that.sqlCreateHelp;
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version);
} else {
url = url + that.sqlAlterHelp;
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version);
}
}
window.open(url, 'postgres_help');
window.open(fullUrl, 'postgres_help');
}.bind(panel),
onDialogHelp = function() {