[pgAdmin 4][Patch] - RM #4953 - Unable to retrieve table node if trigger is already disabled and user Click on Enable All

Khushboo Vashi <[email protected]> Mon, 2 Dec 2019 14:24:42 +0530
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAFOhELfrQh7=mVbgBwOy3VNyuAy7YBxt5aL76wV0xfxqk-ADTg@mail.gmail.com>
Hi,

Please find the attached patch to fix the RM #4953 - Unable to retrieve
table node if trigger is already disabled and user Click on Enable All.

Thanks,
Khushboo
RM_4953.patch (application/octet-stream, 1.7 KB)
diff --git a/web/pgadmin/static/js/tree/pgadmin_tree_node.js b/web/pgadmin/static/js/tree/pgadmin_tree_node.js
index 2a74fd115..f5a3e6e91 100644
--- a/web/pgadmin/static/js/tree/pgadmin_tree_node.js
+++ b/web/pgadmin/static/js/tree/pgadmin_tree_node.js
@@ -43,6 +43,7 @@ export function getTreeNodeHierarchyFromElement(pgBrowser, treeNode) {
 export function getTreeNodeHierarchyFromIdentifier(aciTreeNodeIdentifier) {
   let identifier = this.treeMenu.translateTreeNodeIdFromACITree(aciTreeNodeIdentifier);
   let currentNode = this.treeMenu.findNode(identifier);
+  if (currentNode === null) return null;
   return getTreeNodeHierarchy.call(this, currentNode);
 }
 
diff --git a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
index d4340833a..999027e9e 100644
--- a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
+++ b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
@@ -211,7 +211,7 @@ _.extend(pgBrowser.browserTreeState, {
       node = data && pgBrowser.Nodes[data._type],
       treeHierarchy = node && node.getTreeNodeHierarchy(item);
 
-    if (!pgBrowser.tree.hasParent(item) || !(self.parent in treeHierarchy))
+    if (treeHierarchy === null || !pgBrowser.tree.hasParent(item) || !(self.parent in treeHierarchy))
       return;
 
     let topParent = treeHierarchy && treeHierarchy[self.parent]['_id'],
@@ -269,7 +269,7 @@ _.extend(pgBrowser.browserTreeState, {
       treeHierarchy = node && node.getTreeNodeHierarchy(item);
 
 
-    if (!pgBrowser.tree.hasParent(item) || !(self.parent in treeHierarchy))
+    if (treeHierarchy === null || !pgBrowser.tree.hasParent(item) || !(self.parent in treeHierarchy))
       return;
 
     // If the server node is open then only we should populate the tree