mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Extract some of the ACI Tree functionalities, and decouple it from the main source. Also - create some abstractions from the repeated code around the enable/disable the schema children object create/edit/delete functionalities, and also created the dialog wrappers for backup and restore dialogs. Reviewed by: Khushboo and Ashesh Refactored by: Ashesh
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import {isValidTreeNodeData} from 'sources/tree/tree';
|
|
|
|
function checkAllowConnIfDatabaseNode(treeNodeData) {
|
|
return (treeNodeData._type === 'database' && treeNodeData.allowConn)
|
|
|| treeNodeData._type !== 'database';
|
|
}
|
|
|
|
function ancestorWithTypeCatalog(treeNode) {
|
|
return treeNode.anyFamilyMember((node) => {
|
|
return node.getData()._type === 'catalog';
|
|
});
|
|
}
|
|
|
|
export function enabled(tree, supportedNodes, treeNodeData, domTreeNode) {
|
|
if (!isValidTreeNodeData(treeNodeData))
|
|
return false;
|
|
|
|
let treeNode = tree.findNodeByDomElement(domTreeNode);
|
|
if (!treeNode) {
|
|
return false;
|
|
}
|
|
|
|
return checkAllowConnIfDatabaseNode(treeNodeData) &&
|
|
_.indexOf(supportedNodes, treeNodeData._type) !== -1 &&
|
|
!ancestorWithTypeCatalog(treeNode);
|
|
}
|
|
|
|
|