mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Refactored the dashboard code, which was allowing each node type to
define its own dashboardURL. There was a typo, while calling the dashboard function of a Node type.
This commit is contained in:
30
web/pgadmin/static/js/nodes/dashboard.js
Normal file
30
web/pgadmin/static/js/nodes/dashboard.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {isString, isFunction} from 'sources/utils';
|
||||
import pgBrowser from 'pgadmin.browser';
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import {isValidData} from 'sources/utils';
|
||||
|
||||
export class TreeNode {
|
||||
constructor(id, data, domNode, parent) {
|
||||
this.id = id;
|
||||
@@ -217,6 +219,6 @@ function findInTree(rootNode, path) {
|
||||
})(rootNode);
|
||||
}
|
||||
|
||||
export function isValidTreeNodeData(treeNodeData) {
|
||||
return !_.isUndefined(treeNodeData) && !_.isNull(treeNodeData);
|
||||
}
|
||||
let isValidTreeNodeData = isValidData;
|
||||
|
||||
export {isValidTreeNodeData};
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import _ from 'underscore';
|
||||
|
||||
export function parseShortcutValue(obj) {
|
||||
var shortcut = '';
|
||||
if (obj.alt) { shortcut += 'alt+'; }
|
||||
@@ -36,3 +38,11 @@ export function findAndSetFocus(container) {
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
let isValidData = (data) => (!_.isUndefined(data) && !_.isNull(data));
|
||||
let isFunction = (fn) => (_.isFunction(fn));
|
||||
let isString = (str) => (_.isString(str));
|
||||
|
||||
export {
|
||||
isValidData, isFunction, isString,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user