Skip to content

Commit

Permalink
Return [] if node cannot be loaded. Fixes #1991 (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Feb 10, 2021
1 parent cc96c7f commit 331c76d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/visualizers/panels/ForgeActionButton/ForgeActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,21 @@ define([
};

ForgeActionButton.prototype.findActionsFor = function(nodeId) {
var node = this.client.getNode(nodeId),
base = this.client.getNode(node.getMetaTypeId()),
isMeta = base && base.getId() === node.getId(),
suffix = isMeta ? '_META' : '',
actions,
const node = this.client.getNode(nodeId);
if (!node) {
return [];
}
let base = this.client.getNode(node.getMetaTypeId());
const isMeta = base && base.getId() === node.getId();
const suffix = isMeta ? '_META' : '';
let actions,
basename;

if (!base) { // must be ROOT or FCO
basename = node.getAttribute('name') || 'ROOT_NODE';
actions = this.getDefinedActionsFor(basename, node)
.filter(action => !action.filter || action.filter.call(this));
return actions.concat(this._registry);
return actions;
}

while (base && !(actions && actions.length)) {
Expand All @@ -127,7 +130,7 @@ define([
}
}

return actions.concat(this._registry);
return actions;
};

ForgeActionButton.prototype.getDefinedActionsFor = function(basename, node) {
Expand All @@ -148,7 +151,7 @@ define([
};

ForgeActionButton.prototype.addActionsForObject = function(nodeId) {
var actions = this.findActionsFor(nodeId),
var actions = this.findActionsFor(nodeId).concat(this._registry),
i;

// Remove old actions
Expand Down

0 comments on commit 331c76d

Please sign in to comment.