mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 00:37:36 -06:00
Fix SQL help for EPAS 10+, and refactor the URL generation code into a testable function. Fixes #4099
This commit is contained in:
parent
ae23f146d1
commit
ce073a2856
@ -54,3 +54,4 @@ Bug fixes
|
||||
| `Bug #4073 <https://redmine.postgresql.org/issues/4073>`_ - Change the CodeMirror active line background colour to $color-danger-lighter so it doesn't conflict with the selection colour.
|
||||
| `Bug #4081 <https://redmine.postgresql.org/issues/4081>`_ - Fix the RE-SQL syntax for roles with a VALID UNTIL clause.
|
||||
| `Bug #4090 <https://redmine.postgresql.org/issues/4090>`_ - Improve the German translation for Backup Server.
|
||||
| `Bug #4099 <https://redmine.postgresql.org/issues/4099>`_ - Fix SQL help for EPAS 10+, and refactor the URL generation code into a testable function.
|
@ -189,7 +189,7 @@ define('pgadmin.node.pga_jobstep', [
|
||||
}, helpMessage: S(
|
||||
gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.<br>For more information, please see the documentation on %s')
|
||||
).sprintf(
|
||||
'<a href="https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING" target="_blank">libpq connection strings</a>'
|
||||
'<a href="https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING" target="_blank">libpq connection strings</a>'
|
||||
).value(), mode: ['create', 'edit'],
|
||||
},{
|
||||
id: 'jstonerror', label: gettext('On error'), cell: 'select2',
|
||||
|
@ -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') {
|
||||
|
@ -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() {
|
||||
|
@ -55,7 +55,7 @@ class HelpModule(PgAdminModule):
|
||||
self.pg_help_path = self.help_preference.register(
|
||||
'help', 'pg_help_path',
|
||||
gettext("PostgreSQL Help Path"), 'text',
|
||||
'https://www.postgresql.org/docs/$VERSION$/static/',
|
||||
'https://www.postgresql.org/docs/$VERSION$/',
|
||||
category_label=gettext('Help'),
|
||||
help_str=gettext(
|
||||
'Path to the PostgreSQL documentation. $VERSION$ will be '
|
||||
|
27
web/pgadmin/help/static/js/help.js
Normal file
27
web/pgadmin/help/static/js/help.js
Normal file
@ -0,0 +1,27 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
export function getHelpUrl(base_path, file, version) {
|
||||
var major = Math.floor(version / 10000),
|
||||
minor = Math.floor(version / 100) - (major * 100),
|
||||
url = '';
|
||||
|
||||
// Handle the version number format change in PG 10+
|
||||
if (major >= 10) {
|
||||
url = base_path.replace('$VERSION$', major);
|
||||
} else {
|
||||
url = base_path.replace('$VERSION$', major + '.' + minor);
|
||||
}
|
||||
|
||||
if (url.substr(-1) != '/') {
|
||||
url = url + '/';
|
||||
}
|
||||
|
||||
return url + file;
|
||||
};
|
56
web/regression/javascript/help/help_spec.js
Normal file
56
web/regression/javascript/help/help_spec.js
Normal file
@ -0,0 +1,56 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import { getHelpUrl } from '../../../pgadmin/help/static/js/help';
|
||||
|
||||
describe('Test help functions', function() {
|
||||
describe('when getHelpUrl is called', function(){
|
||||
|
||||
// PG 9.6 docs
|
||||
it('it should be able to return a correct URL for PG 9.6 docs with a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.postgresql.org/docs/$VERSION$/', 'index.html', 90600)).toEqual('https://www.postgresql.org/docs/9.6/index.html');
|
||||
});
|
||||
|
||||
// PG 10 docs
|
||||
it('it should be able to return a correct URL for PG 10 docs with a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.postgresql.org/docs/$VERSION$/', 'index.html', 100000)).toEqual('https://www.postgresql.org/docs/10/index.html');
|
||||
});
|
||||
|
||||
// PG 9.6 docs
|
||||
it('it should be able to return a correct URL for PG 9.6 docs without a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.postgresql.org/docs/$VERSION$', 'index.html', 90600)).toEqual('https://www.postgresql.org/docs/9.6/index.html');
|
||||
});
|
||||
|
||||
// PG 10 docs
|
||||
it('it should be able to return a correct URL for PG 10 docs without a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.postgresql.org/docs/$VERSION$', 'index.html', 100000)).toEqual('https://www.postgresql.org/docs/10/index.html');
|
||||
});
|
||||
|
||||
// EPAS 9.6 docs
|
||||
it('it should be able to return a correct URL for EPAS 9.6 docs with a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.enterprisedb.com/docs/en/$VERSION$/pg/', 'index.html', 90600)).toEqual('https://www.enterprisedb.com/docs/en/9.6/pg/index.html');
|
||||
});
|
||||
|
||||
// EPAS 10 docs
|
||||
it('it should be able to return a correct URL for EPAS 10 docs with a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.enterprisedb.com/docs/en/$VERSION$/pg/', 'index.html', 100000)).toEqual('https://www.enterprisedb.com/docs/en/10/pg/index.html');
|
||||
});
|
||||
|
||||
// EPAS 9.6 docs
|
||||
it('it should be able to return a correct URL for EPAS 9.6 docs without a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.enterprisedb.com/docs/en/$VERSION$/pg', 'index.html', 90600)).toEqual('https://www.enterprisedb.com/docs/en/9.6/pg/index.html');
|
||||
});
|
||||
|
||||
// EPAS 10 docs
|
||||
it('it should be able to return a correct URL for EPAS 10 docs without a trailing slash', function() {
|
||||
expect(getHelpUrl('https://www.enterprisedb.com/docs/en/$VERSION$/pg', 'index.html', 100000)).toEqual('https://www.enterprisedb.com/docs/en/10/pg/index.html');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@ -210,6 +210,7 @@ var webpackShimConfig = {
|
||||
'pgadmin.datagrid': path.join(__dirname, './pgadmin/tools/datagrid/static/js/datagrid'),
|
||||
'pgadmin.file_manager': path.join(__dirname, './pgadmin/misc/file_manager/static/js/file_manager'),
|
||||
'pgadmin.file_utility': path.join(__dirname, './pgadmin/misc/file_manager/static/js/utility'),
|
||||
'pgadmin.help': path.join(__dirname, './pgadmin/help/static/js/help'),
|
||||
'pgadmin.misc.explain': path.join(__dirname, './pgadmin/misc/static/explain/js/explain'),
|
||||
'pgadmin.node.cast': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/casts/static/js/cast'),
|
||||
'pgadmin.node.catalog': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog'),
|
||||
|
Loading…
Reference in New Issue
Block a user