1. Disable ERD for system Catalogs. #5849

2. Disable Debugger for system catalogs. #6060
3. Fixed an issue where the keyboard shortcut for launching the debugger from Object Explorer was not working.
This commit is contained in:
Pravesh Sharma 2024-05-08 15:29:01 +05:30 committed by GitHub
parent 9edc1d225e
commit afc28d95cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 32 deletions

View File

@ -125,6 +125,9 @@ define('pgadmin.node.table', [
name: 'generate_erd', node: 'table', module: this,
applies: ['object', 'context'], callback: 'generate_erd',
category: 'erd', priority: 5, label: gettext('ERD For Table'),
enable: (_, item) => {
return !('catalog' in pgAdmin.Browser.tree.getTreeNodeHierarchy(item));
}
}
]);
pgBrowser.Events.on(

View File

@ -279,9 +279,9 @@ _.extend(pgBrowser.keyboardNavigation, {
if (!tree.d || (type !== 'function' && type !== 'procedure'))
return;
if (pgAdmin.Tools.Debugger.can_debug(tree.d, tree.i, {'debug_type': 'direct'})) {
if (pgAdmin.Tools.Debugger.canDebug(tree.d, tree.i, {'debug_type': 'direct'})) {
// Call debugger callback
pgAdmin.Tools.Debugger.get_function_information(pgAdmin.Browser.Nodes[type]);
pgAdmin.Tools.Debugger.getFunctionInformation(pgAdmin.Browser.Nodes[type]);
}
},
isPropertyPanelVisible: function() {

View File

@ -92,7 +92,7 @@ export default class DebuggerModule {
data: {
object: 'procedure',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'procedure_indirect_debugger',
node: 'procedure',
@ -106,7 +106,7 @@ export default class DebuggerModule {
object: 'procedure',
debug_type: 'indirect',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'trigger_function_indirect_debugger',
node: 'trigger_function',
@ -120,7 +120,7 @@ export default class DebuggerModule {
object: 'trigger_function',
debug_type: 'indirect',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'trigger_indirect_debugger',
node: 'trigger',
@ -134,7 +134,7 @@ export default class DebuggerModule {
object: 'trigger',
debug_type: 'indirect',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'package_function_direct_debugger',
node: 'edbfunc',
@ -147,7 +147,7 @@ export default class DebuggerModule {
data: {
object: 'edbfunc',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'package_function_global_debugger',
node: 'edbfunc',
@ -161,7 +161,7 @@ export default class DebuggerModule {
object: 'edbfunc',
debug_type: 'indirect',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'package_procedure_direct_debugger',
node: 'edbproc',
@ -174,7 +174,7 @@ export default class DebuggerModule {
data: {
object: 'edbproc',
},
enable: 'can_debug',
enable: 'canDebug',
}, {
name: 'package_procedure_global_debugger',
node: 'edbproc',
@ -188,35 +188,23 @@ export default class DebuggerModule {
object: 'edbproc',
debug_type: 'indirect',
},
enable: 'can_debug',
enable: 'canDebug',
}
]);
}
// It will check weather the function is actually debuggable or not with pre-required condition.
canDebug(itemData, item, data) {
let t = this.pgBrowser.tree,
i = item,
d = itemData;
// To iterate over tree to check parent node
while (i) {
if ('catalog' == d._type) {
//Check if we are not child of catalog
return false;
}
i = t.hasParent(i) ? t.parent(i) : null;
d = i ? t.itemData(i) : null;
}
// Find the function is really available in database
let tree = this.pgBrowser.tree,
info = tree.selected(),
d_ = info ? tree.itemData(info) : undefined;
d = itemData,
treeInfo = tree.getTreeNodeHierarchy(item);
if (!d_)
// Disable debugging for catalog functions
if ('catalog' in treeInfo)
return false;
let treeInfo = tree.getTreeNodeHierarchy(info);
if (!d)
return false;
// For indirect debugging user must be super user
if (data?.debug_type == 'indirect' && !treeInfo.server.user.is_superuser)
@ -231,14 +219,14 @@ export default class DebuggerModule {
return false;
// For trigger node, language will be undefined - we should allow indirect debugging for trigger node
if ((d_.language == undefined && d_._type == 'trigger') ||
(d_.language == undefined && d_._type == 'edbfunc') ||
(d_.language == undefined && d_._type == 'edbproc')) {
if ((d.language == undefined && d._type == 'trigger') ||
(d.language == undefined && d._type == 'edbfunc') ||
(d.language == undefined && d._type == 'edbproc')) {
return true;
}
let returnValue = true;
if (d_.language != 'plpgsql' && d_.language != 'edbspl') {
if (d.language != 'plpgsql' && d.language != 'edbspl') {
returnValue = false;
}