'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
parent
be3f9570e3
commit
e2ce73d855
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue