Ensure that SQL help should work for EPAS servers. Fixes #6834

This commit is contained in:
Akshay Joshi 2021-10-06 14:49:56 +05:30
parent ab424b27d1
commit 1ed6272e7b
13 changed files with 55 additions and 96 deletions

View File

@ -33,3 +33,4 @@ Bug fixes
| `Issue #6736 <https://redmine.postgresql.org/issues/6736>`_ - Fixed an issue where Refresh view options are not working for materialized view.
| `Issue #6755 <https://redmine.postgresql.org/issues/6755>`_ - Fixed keyerror issue in schema diff for 'attnum' and 'edit_types' parameter.
| `Issue #6759 <https://redmine.postgresql.org/issues/6759>`_ - Ensure that RLS names should not be editable in the collection node of properties tab.
| `Issue #6834 <https://redmine.postgresql.org/issues/6834>`_ - Ensure that SQL help should work for EPAS servers.

View File

@ -796,9 +796,6 @@ def utils():
pg_help_path_pref = prefs.preference('pg_help_path')
pg_help_path = pg_help_path_pref.get()
edbas_help_path_pref = prefs.preference('edbas_help_path')
edbas_help_path = edbas_help_path_pref.get()
# Get sqleditor options
prefs = Preferences.module('sqleditor')
@ -837,7 +834,6 @@ def utils():
layout=layout,
jssnippets=snippets,
pg_help_path=pg_help_path,
edbas_help_path=edbas_help_path,
editor_tab_size=editor_tab_size,
editor_use_spaces=editor_use_spaces,
editor_wrap_code=editor_wrap_code,

View File

@ -36,6 +36,7 @@ define('pgadmin.node.package', [
if (!pgBrowser.Nodes['package']) {
pgBrowser.Nodes['package'] = schemaChild.SchemaChildNode.extend({
type: 'package',
epasHelp: true,
dialogHelp: url_for('help.static', {'filename': 'package_dialog.html'}),
label: gettext('Package'),
collection_type: 'coll-package',

View File

@ -33,6 +33,7 @@ define('pgadmin.node.synonym', [
if (!pgBrowser.Nodes['synonym']) {
pgAdmin.Browser.Nodes['synonym'] = schemaChild.SchemaChildNode.extend({
type: 'synonym',
epasHelp: true,
dialogHelp: url_for('help.static', {'filename': 'synonym_dialog.html'}),
label: gettext('Synonym'),
collection_type: 'coll-synonym',

View File

@ -42,8 +42,7 @@ define('pgadmin.node.compound_trigger', [
hasSQL: true,
hasDepends: true,
width: pgBrowser.stdW.sm + 'px',
sqlAlterHelp: 'sql-altertcompoundtrigger.html',
sqlCreateHelp: 'sql-createcompoundtrigger.html',
epasHelp: true,
dialogHelp: url_for('help.static', {'filename': 'compound_trigger_dialog.html'}),
url_jump_after_node: 'schema',
Init: function() {

View File

@ -32,6 +32,7 @@ define('pgadmin.node.resource_group', [
pgBrowser.Nodes['resource_group'] = pgBrowser.Node.extend({
parent_type: 'server',
type: 'resource_group',
epasHelp: true,
dialogHelp: url_for('help.static', {'filename': 'resource_group_dialog.html'}),
label: gettext('Resource Group'),
hasSQL: true,

View File

@ -854,11 +854,7 @@ define('pgadmin.browser', [
// Construct the URL
var server = pgBrowser.tree.getTreeNodeHierarchy(item).server;
var baseUrl = pgBrowser.utils.pg_help_path;
if (server.server_type == 'ppas') {
baseUrl = pgBrowser.utils.edbas_help_path;
}
var fullUrl = help.getHelpUrl(baseUrl, url, server.version, server.server_type);
var fullUrl = help.getHelpUrl(baseUrl, url, server.version);
window.open(fullUrl, 'postgres_help');
} else if(type == 'dialog_help') {

View File

@ -92,6 +92,7 @@ define('pgadmin.browser.node', [
sqlAlterHelp: '',
sqlCreateHelp: '',
dialogHelp: '',
epasHelp: false,
title: function(o, d) {
return o.label + (d ? (' - ' + d.label) : '');
@ -1265,7 +1266,7 @@ define('pgadmin.browser.node', [
tooltip: gettext('SQL help for this object type.'),
extraClasses: ['btn-primary-icon', 'btn-primary-icon', 'm-1'],
icon: 'fa fa-info',
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false,
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '' && !that.epasHelp) ? true : false,
register: function(btn) {
btn.on('click',() => {
onSqlHelp();
@ -1281,20 +1282,21 @@ define('pgadmin.browser.node', [
var server = pgBrowser.tree.getTreeNodeHierarchy(item).server;
var url = pgBrowser.utils.pg_help_path;
if (server.server_type == 'ppas') {
url = pgBrowser.utils.edbas_help_path;
}
var fullUrl = '';
if (that.sqlCreateHelp == '' && that.sqlAlterHelp != '') {
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version, server.server_type);
} else if (that.sqlCreateHelp != '' && that.sqlAlterHelp == '') {
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version, server.server_type);
if (server.server_type == 'ppas' && that.epasHelp) {
fullUrl = help.getEPASHelpUrl(server.version);
} else {
if (view.model.isNew()) {
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version, server.server_type);
if (that.sqlCreateHelp == '' && that.sqlAlterHelp != '') {
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version);
} else if (that.sqlCreateHelp != '' && that.sqlAlterHelp == '') {
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version);
} else {
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version, server.server_type);
if (view.model.isNew()) {
fullUrl = help.getHelpUrl(url, that.sqlCreateHelp, server.version);
} else {
fullUrl = help.getHelpUrl(url, that.sqlAlterHelp, server.version);
}
}
}
@ -1558,7 +1560,7 @@ define('pgadmin.browser.node', [
tooltip: gettext('SQL help for this object type.'),
extraClasses: ['btn-primary-icon', 'pull-left', 'mx-1'],
icon: 'fa fa-info',
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false,
disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '' && !that.epasHelp) ? true : false,
register: function(btn) {
btn.on('click',() => {
onSqlHelp();

View File

@ -12,7 +12,7 @@ import ReactDOM from 'react-dom';
import pgAdmin from 'sources/pgadmin';
import getApiInstance from 'sources/api_instance';
import {getHelpUrl} from 'pgadmin.help';
import {getHelpUrl, getEPASHelpUrl} from 'pgadmin.help';
import SchemaView from 'sources/SchemaView';
import { generateNodeUrl } from './node_ajax';
import Alertify from 'pgadmin.alertifyjs';
@ -96,20 +96,21 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
if(isSqlHelp) {
let server = treeNodeInfo.server;
let url = pgAdmin.Browser.utils.pg_help_path;
if (server.server_type == 'ppas') {
url = pgAdmin.Browser.utils.edbas_help_path;
}
let fullUrl = '';
if (nodeObj.sqlCreateHelp == '' && nodeObj.sqlAlterHelp != '') {
fullUrl = getHelpUrl(url, nodeObj.sqlAlterHelp, server.version, server.server_type);
} else if (nodeObj.sqlCreateHelp != '' && nodeObj.sqlAlterHelp == '') {
fullUrl = getHelpUrl(url, nodeObj.sqlCreateHelp, server.version, server.server_type);
if (server.server_type == 'ppas' && nodeObj.epasHelp) {
fullUrl = getEPASHelpUrl(server.version);
} else {
if (isNew) {
fullUrl = getHelpUrl(url, nodeObj.sqlCreateHelp, server.version, server.server_type);
if (nodeObj.sqlCreateHelp == '' && nodeObj.sqlAlterHelp != '') {
fullUrl = getHelpUrl(url, nodeObj.sqlAlterHelp, server.version);
} else if (nodeObj.sqlCreateHelp != '' && nodeObj.sqlAlterHelp == '') {
fullUrl = getHelpUrl(url, nodeObj.sqlCreateHelp, server.version);
} else {
fullUrl = getHelpUrl(url, nodeObj.sqlAlterHelp, server.version, server.server_type);
if (isNew) {
fullUrl = getHelpUrl(url, nodeObj.sqlCreateHelp, server.version);
} else {
fullUrl = getHelpUrl(url, nodeObj.sqlAlterHelp, server.version);
}
}
}
@ -195,7 +196,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
confirmOnCloseReset={confirmOnCloseReset}
hasSQL={nodeObj.hasSQL && (actionType === 'create' || actionType === 'edit')}
getSQLValue={getSQLValue}
disableSqlHelp={nodeObj.sqlAlterHelp == '' && nodeObj.sqlCreateHelp == ''}
disableSqlHelp={nodeObj.sqlAlterHelp == '' && nodeObj.sqlCreateHelp == '' && !nodeObj.epasHelp}
disableDialogHelp={nodeObj.dialogHelp == undefined || nodeObj.dialogHelp == ''}
/>, container);
}

View File

@ -70,7 +70,6 @@ define('pgadmin.browser.utils',
pgBrowser.utils = {
layout: '{{ layout }}',
pg_help_path: '{{ pg_help_path }}',
edbas_help_path: '{{ edbas_help_path }}',
tabSize: '{{ editor_tab_size }}',
wrapCode: '{{ editor_wrap_code }}' == 'True',
useSpaces: '{{ editor_use_spaces }}',

View File

@ -63,18 +63,6 @@ class HelpModule(PgAdminModule):
)
)
self.edbas_help_path = self.help_preference.register(
'help', 'edbas_help_path',
gettext("EDB Advanced Server Help Path"), 'text',
'https://www.enterprisedb.com/edb-docs/d/postgresql/reference/'
'manual/$VERSION$/',
category_label=gettext('Help'),
help_str=gettext(
'Path to the EDB Advanced Server documentation. $VERSION$ '
'will be replaced with the major.minor version number.'
)
)
def get_exposed_url_endpoints(self):
"""
Returns the list of URLs exposed to the client.

View File

@ -7,17 +7,13 @@
//
//////////////////////////////////////////////////////////////////////////
export function getHelpUrl(base_path, file, version, server_type) {
export function getHelpUrl(base_path, file, version) {
var major = Math.floor(version / 10000),
minor = Math.floor(version / 100) - (major * 100),
subminor = version - ((major * 10000) + (minor * 100)),
url = '',
replace_string = major + '.' + minor;
// Handle the version number format change in EPAS 9.6 and below
if (server_type == 'ppas' && major < 10) {
replace_string = major + '.' + minor + '.' + subminor;
} else if (server_type == 'pg' && major >= 10) {
if (major >= 10) {
// Handle the version number format change in PG 10+
replace_string = major;
}
@ -30,3 +26,21 @@ export function getHelpUrl(base_path, file, version, server_type) {
return url + file;
}
export function getEPASHelpUrl(version) {
var major = Math.floor(version / 10000),
minor = Math.floor(version / 100) - (major * 100),
epasHelp11Plus = 'https://www.enterprisedb.com/docs/epas/$VERSION$/epas_compat_sql/',
epasHelp = 'https://www.enterprisedb.com/docs/epas/$VERSION$/',
url = '';
url = epasHelp11Plus.replace('$VERSION$', major);
if (major == 10) {
url = epasHelp.replace('$VERSION$', major);
} else if (major < 10) {
url = epasHelp.replace('$VERSION$', major + '.' + minor);
}
return url;
}

View File

@ -51,45 +51,5 @@ describe('Test help functions', function() {
it('it should be able to return a correct URL for PG 12 docs without a trailing slash', function() {
expect(getHelpUrl('https://www.postgresql.org/docs/$VERSION$', 'index.html', 121000, 'pg')).toEqual('https://www.postgresql.org/docs/12/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/edb-docs/d/postgresql/reference/manual/$VERSION$/', 'index.html', 90600, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/9.6.0/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/edb-docs/d/postgresql/reference/manual/$VERSION$/', 'index.html', 100000, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/10.0/index.html');
});
// EPAS 11 docs
it('it should be able to return a correct URL for EPAS 11 docs with a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$/', 'index.html', 110000, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/11.0/index.html');
});
// EPAS 12 docs
it('it should be able to return a correct URL for EPAS 12 docs with a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$/', 'index.html', 120000, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/12.0/index.html');
});
// EPAS 9.6.15 docs
it('it should be able to return a correct URL for EPAS 9.6.15 docs without a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$', 'index.html', 90615, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/9.6.15/index.html');
});
// EPAS 10.13 docs
it('it should be able to return a correct URL for EPAS 10.13 docs without a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$', 'index.html', 101300, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/10.13/index.html');
});
// EPAS 11.5 docs
it('it should be able to return a correct URL for EPAS 11.5 docs without a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$', 'index.html', 110500, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/11.5/index.html');
});
// EPAS 12.3 docs
it('it should be able to return a correct URL for EPAS 12.3 docs without a trailing slash', function() {
expect(getHelpUrl('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/$VERSION$', 'index.html', 120300, 'ppas')).toEqual('https://www.enterprisedb.com/edb-docs/d/postgresql/reference/manual/12.3/index.html');
});
});
});