Skip to content

Commit 746b83e

Browse files
authored
Determine valid ptr types using available libraries. Fixes #1173 (#1174)
1 parent 6d35c25 commit 746b83e

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

src/visualizers/panels/OperationInterfaceEditor/OperationInterfaceEditorControl.EventHandlers.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
define([
33
'panels/EasyDAG/EasyDAGControl.WidgetEventHandlers',
44
'deepforge/OperationCode',
5-
'./Colors'
5+
'./Colors',
6+
'text!panels/ForgeActionButton/Libraries.json',
67
], function(
78
EasyDAGControlEventHandlers,
89
OperationCode,
9-
COLORS
10+
COLORS,
11+
LibrariesText
1012
) {
1113
'use strict';
14+
const Libraries = JSON.parse(LibrariesText);
1215
var OperationInterfaceEditorEvents = function() {
1316
this.logger = this._logger;
1417
this._widget.allDataTypeIds = this.allDataTypeIds.bind(this);
@@ -41,22 +44,23 @@ define([
4144
};
4245
};
4346

44-
OperationInterfaceEditorEvents.prototype.allValidReferences = function() {
45-
// Get all meta nodes that...
46-
// - are not data, pipeline or operation (or fco!)
47-
// - have a plugin defined?
48-
// Currently you can't reference operations or pipelines.
49-
var notTypes = ['Data', 'Operation', 'Pipeline'];
47+
OperationInterfaceEditorEvents.prototype.getResourcesNodeTypes = function() {
5048
return this._client.getAllMetaNodes()
51-
.filter(node => {
52-
var plugins = node.getOwnRegistry('validPlugins');
53-
// Convention is enforced; if the plugin generates lua artifacts,
54-
// it should be called `Generate`.. (something)
55-
return plugins && plugins.indexOf('Generate') !== -1;
56-
})
57-
.filter(node => notTypes.reduce((valid, name) =>
58-
valid && !this.hasMetaName(node.getId(), name), true))
59-
.filter(node => node.getAttribute('name') !== 'FCO')
49+
.filter(node => { // Check that the node is a top level type from a library
50+
const name = node.getAttribute('name');
51+
const namespace = node.getNamespace();
52+
if (!namespace) return false;
53+
54+
const isResourceFromLibrary = Libraries.find(library => {
55+
return library.name === namespace &&
56+
library.nodeTypes.includes(name);
57+
});
58+
return isResourceFromLibrary;
59+
});
60+
};
61+
62+
OperationInterfaceEditorEvents.prototype.allValidReferences = function() {
63+
return this.getResourcesNodeTypes()
6064
.map(node => {
6165
return {
6266
node: this._getObjectDescriptor(node.getId())

0 commit comments

Comments
 (0)