'anyFamilyMember' runs the condition function for all nodes in the

hierarchy. No need to run the 'dashboardURL' function in the
'getDashboardURL' function for the current node too.
pull/14/head
Ashesh Vashi 2018-07-26 21:37:36 +05:30
parent be3f9570e3
commit e2ce73d855
1 changed files with 15 additions and 17 deletions

View File

@ -6,24 +6,22 @@ export function url(itemData, item, treeHierarchy) {
let treeNode = pgBrowser.treeMenu.findNodeByDomElement(item);
let url = null;
let getDashboardURL = (node) => {
let nodeData = node.getData();
let browserNode = pgBrowser.Nodes[nodeData._type];
let dashboardURL = browserNode && browserNode.dashboard;
if (isFunction(dashboardURL)) {
dashboardURL = dashboardURL.apply(
browserNode, [node, nodeData, treeHierarchy]
);
}
url = isString(dashboardURL) ? dashboardURL : null;
return (url !== null);
};
if (treeNode) {
if (getDashboardURL(treeNode) === false)
treeNode.anyFamilyMember(getDashboardURL);
treeNode.anyFamilyMember(
(node) => {
let nodeData = node.getData();
let browserNode = pgBrowser.Nodes[nodeData._type];
let dashboardURL = browserNode && browserNode.dashboard;
if (isFunction(dashboardURL)) {
dashboardURL = dashboardURL.apply(
browserNode, [node, nodeData, treeHierarchy]
);
}
url = isString(dashboardURL) ? dashboardURL : null;
return (url !== null);
});
}
return url;