|
2 | 2 | define([ |
3 | 3 | 'panels/EasyDAG/EasyDAGControl.WidgetEventHandlers', |
4 | 4 | 'deepforge/OperationCode', |
5 | | - './Colors' |
| 5 | + './Colors', |
| 6 | + 'text!panels/ForgeActionButton/Libraries.json', |
6 | 7 | ], function( |
7 | 8 | EasyDAGControlEventHandlers, |
8 | 9 | OperationCode, |
9 | | - COLORS |
| 10 | + COLORS, |
| 11 | + LibrariesText |
10 | 12 | ) { |
11 | 13 | 'use strict'; |
| 14 | + const Libraries = JSON.parse(LibrariesText); |
12 | 15 | var OperationInterfaceEditorEvents = function() { |
13 | 16 | this.logger = this._logger; |
14 | 17 | this._widget.allDataTypeIds = this.allDataTypeIds.bind(this); |
@@ -41,22 +44,23 @@ define([ |
41 | 44 | }; |
42 | 45 | }; |
43 | 46 |
|
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() { |
50 | 48 | 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() |
60 | 64 | .map(node => { |
61 | 65 | return { |
62 | 66 | node: this._getObjectDescriptor(node.getId()) |
|
0 commit comments