Sfoglia il codice sorgente

fix: choose a collection from the allowed ones instead of typing a name

Six settings took a collection as free text. Typing one the workflow has no
permission for is accepted, saved, and then fails at run time - and in
http-request's case fails quietly, because the node logs the refusal and carries
on, so downloads simply were not stored and nothing said so.

They now use the same picker the storage nodes use: the collections this
workflow can reach, labelled with their access. A collection it may only read is
not offered where the node writes.

- database-change  collection, cursorCollection
- file-watch       cursorCollection
- http-request     downloadCollection
- image            storageCollection
- sdcpp-fetch-output collection

Checked every node: no collection setting is free text any more. The storage-*
nodes keep their Collection Source switch - picker, or a typed name, or an
expression - which is deliberate, since a collection chosen at run time cannot
be picked from a list at design time.
fszontagh 1 mese fa
parent
commit
aec7d079a2

+ 6 - 0
nodes/core/http-request.js

@@ -72,6 +72,12 @@ const configSchema = {
       default: false
     },
     downloadCollection: {
+        dynamicOptions: {
+            source: 'storage.collections',
+            labelField: 'name',
+            valueField: 'name',
+            filter: { access: 'read-write' }
+        },
       type: 'string',
       title: 'Storage Collection',
       default: 'downloads',

+ 6 - 0
nodes/image/image.js

@@ -45,6 +45,12 @@ const configSchema = {
             showWhen: { field: 'inputSource', value: 'url' }
         },
         storageCollection: {
+            dynamicOptions: {
+                source: 'storage.collections',
+                labelField: 'name',
+                valueField: 'name',
+                filter: {}
+            },
             type: 'string',
             title: 'Storage Collection',
             description: 'Collection name for stored image',

+ 6 - 0
nodes/sdcpp/sdcpp-fetch-output.js

@@ -60,6 +60,12 @@ const configSchema = {
             default: false
         },
         collection: {
+            dynamicOptions: {
+                source: 'storage.collections',
+                labelField: 'name',
+                valueField: 'name',
+                filter: { access: 'read-write' }
+            },
             type: 'string',
             title: 'Collection',
             description: 'Storage collection to save into. Must not begin with an underscore, those silently lose writes',

+ 12 - 0
nodes/triggers/database-change.js

@@ -11,6 +11,12 @@ const configSchema = {
     type: 'object',
     properties: {
         collection: {
+            dynamicOptions: {
+                source: 'storage.collections',
+                labelField: 'name',
+                valueField: 'name',
+                filter: {}
+            },
             type: 'string',
             title: 'Collection',
             description: 'Collection to watch'
@@ -40,6 +46,12 @@ const configSchema = {
             default: false
         },
         cursorCollection: {
+            dynamicOptions: {
+                source: 'storage.collections',
+                labelField: 'name',
+                valueField: 'name',
+                filter: { access: 'read-write' }
+            },
             type: 'string',
             title: 'Cursor Collection',
             default: 'watch_cursors'

+ 6 - 0
nodes/triggers/file-watch.js

@@ -33,6 +33,12 @@ const configSchema = {
             default: false
         },
         cursorCollection: {
+            dynamicOptions: {
+                source: 'storage.collections',
+                labelField: 'name',
+                valueField: 'name',
+                filter: { access: 'read-write' }
+            },
             type: 'string',
             title: 'Cursor Collection',
             description: 'Collection holding the last-seen state',