Fix files selection after dialog opening
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sun, 14 Oct 2018 17:37:14 +0000 (19:37 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sun, 14 Oct 2018 17:37:14 +0000 (19:37 +0200)
Feature #14232

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/views/run-process-panel/inputs/file-array-input.tsx

index 391cc7fe810d7328b417b80c5988dd424403feae..be58eee21262a008b2eeccb9953a279bf098e4df 100644 (file)
@@ -138,14 +138,12 @@ const FileArrayInputComponent = connect(mapStateToProps)(
             this.setState({ files });
 
             const ids = values(getProjectsTreePickerIds(this.props.commandInput.id));
-            deletedFiles.forEach(({ id }) => {
-                ids.forEach(pickerId => {
-                    this.props.dispatch(
-                        treePickerActions.DESELECT_TREE_PICKER_NODE({
-                            pickerId, id,
-                        })
-                    );
-                });
+            ids.forEach(pickerId => {
+                this.props.dispatch(
+                    treePickerActions.DESELECT_TREE_PICKER_NODE({
+                        pickerId, id: deletedFiles.map(({ id }) => id),
+                    })
+                );
             });
 
         }
@@ -159,19 +157,17 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                         : [...addedFiles, file]
                     , []);
 
-            this.setState({ files });
-
             const ids = values(getProjectsTreePickerIds(this.props.commandInput.id));
-            addedFiles.forEach(({ id }) => {
-                ids.forEach(pickerId => {
-                    this.props.dispatch(
-                        treePickerActions.SELECT_TREE_PICKER_NODE({
-                            pickerId, id,
-                        })
-                    );
-                });
+            ids.forEach(pickerId => {
+                this.props.dispatch(
+                    treePickerActions.SELECT_TREE_PICKER_NODE({
+                        pickerId, id: addedFiles.map(({ id }) => id),
+                    })
+                );
             });
 
+            this.setFiles(files);
+
         }
 
         refreshFiles = () => {