Merge branch '17637-not-found-after-trash'
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 18 May 2021 18:01:50 +0000 (15:01 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 18 May 2021 18:01:50 +0000 (15:01 -0300)
Closes #17637

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

cypress/fixtures/workflow_with_array_fields.yaml [new file with mode: 0644]
cypress/integration/favorites.spec.js
src/components/tree/tree.tsx
src/store/tree-picker/tree-picker-actions.ts
src/views/run-process-panel/inputs/directory-array-input.tsx
src/views/run-process-panel/inputs/file-array-input.tsx
src/views/run-process-panel/run-process-inputs-form.tsx

diff --git a/cypress/fixtures/workflow_with_array_fields.yaml b/cypress/fixtures/workflow_with_array_fields.yaml
new file mode 100644 (file)
index 0000000..fc71cf8
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+---
+"$graph":
+- class: Workflow
+  cwlVersion: v1.2
+  hints:
+  - acrContainerImage: 7009415fdc959d0c2819ee2e9db96561+261
+    class: http://arvados.org/cwl#WorkflowRunnerResources
+  id: "#main"
+  inputs:
+  - default: []
+    id: "#main/bar"
+    type:
+      items: Directory
+      type: array
+  - default: []
+    id: "#main/foo"
+    type:
+      items: File
+      type: array
+  outputs: []
+  steps: []
+cwlVersion: v1.2
index 22514beb1e73f0b56694942653196b07bb729fb3..6750650dc2789d66257463e4b37c9bbcf0e4fc70 100644 (file)
@@ -204,4 +204,101 @@ describe('Favorites tests', function () {
                     });
             });
     });
+
+    it('can select multi files when creating workflow', () => {
+        cy.createProject({
+            owningUser: activeUser,
+            projectName: 'myProject1',
+            addToFavorites: true
+        });
+
+        cy.createCollection(adminUser.token, {
+            name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
+        })
+            .as('testCollection');
+
+        cy.createCollection(adminUser.token, {
+            name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:buz\n`
+        })
+            .as('testCollection2');
+
+        cy.getAll('@myProject1', '@testCollection', '@testCollection2')
+            .then(function ([myProject1, testCollection, testCollection2]) {
+                cy.readFile('cypress/fixtures/workflow_with_array_fields.yaml').then(workflow => {
+                    cy.createWorkflow(adminUser.token, {
+                        name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
+                        definition: workflow,
+                        owner_uuid: myProject1.uuid,
+                    })
+                        .as('testWorkflow');
+                });
+
+                cy.loginAs(activeUser);
+
+                cy.get('main').contains(myProject1.name).click();
+
+                cy.get('[data-cy=side-panel-button]').click();
+
+                cy.get('#aside-menu-list').contains('Run a process').click();
+
+                cy.get('@testWorkflow')
+                    .then((testWorkflow) => {
+                        cy.get('main').contains(testWorkflow.name).click();
+                        cy.get('[data-cy=run-process-next-button]').click();
+
+                        cy.get('label').contains('#main/foo').parent('div').find('input').click();
+                        cy.get('div[role=dialog]')
+                            .within(() => {
+                                cy.get('p').contains('Projects').closest('div[role=button]')
+                                    .within(() => {
+                                        cy.get('svg[role=presentation]')
+                                            .click({ multiple: true });
+                                    });
+
+                                cy.get(`[data-id=${testCollection.uuid}]`)
+                                    .find('i').click();
+
+                                cy.contains('bar').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
+
+                                cy.contains('baz').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
+
+                                cy.get('[data-cy=ok-button]').click();
+                            });
+
+                        cy.get('label').contains('#main/bar').parent('div').find('input').click();
+                        cy.get('div[role=dialog]')
+                            .within(() => {
+                                cy.get('p').contains('Projects').closest('div[role=button]')
+                                    .within(() => {
+                                        cy.get('svg[role=presentation]')
+                                            .click({ multiple: true });
+                                    });
+
+                                cy.get(`[data-id=${testCollection.uuid}]`)
+                                    .find('input[type=checkbox]').click();
+
+                                cy.get(`[data-id=${testCollection2.uuid}]`)
+                                    .find('input[type=checkbox]').click();
+
+                                cy.get('[data-cy=ok-button]').click();
+                            });
+                    });
+
+                cy.get('label').contains('#main/foo').parent('div')
+                    .within(() => {
+                        cy.contains('baz');
+                        cy.contains('bar');
+                    });
+
+                cy.get('label').contains('#main/bar').parent('div')
+                    .within(() => {
+                        cy.contains(testCollection.name);
+                        cy.contains(testCollection2.name);
+                    });
+            });
+    });
 });
\ No newline at end of file
index cf4d708daaabab31eddd615baac1b82a298b88a7..e84e0f3afc12680f47410636b33572d75fffc3ba 100644 (file)
@@ -155,6 +155,9 @@ interface FlatTreeProps {
     getProperArrowAnimation: Function;
     itemsMap?: Map<string, TreeItem<any>>;
     classes: any;
+    showSelection: any;
+    useRadioButtons?: boolean;
+    handleCheckboxChange: Function;
 }
 
 const FLAT_TREE_ACTIONS = {
@@ -163,7 +166,7 @@ const FLAT_TREE_ACTIONS = {
     toggleActive: 'TOGGLE_ACTIVE',
 };
 
-const ItemIcon = React.memo(({type, kind, active, groupClass, classes}: any) => {
+const ItemIcon = React.memo(({ type, kind, active, groupClass, classes }: any) => {
     let Icon = ProjectIcon;
 
     if (groupClass === GroupClass.FILTER) {
@@ -184,7 +187,7 @@ const ItemIcon = React.memo(({type, kind, active, groupClass, classes}: any) =>
     }
 
     if (kind) {
-        switch(kind) {
+        switch (kind) {
             case ResourceKind.COLLECTION:
                 Icon = CollectionIcon;
                 break;
@@ -231,6 +234,17 @@ const FlatTree = (props: FlatTreeProps) =>
                             {props.getProperArrowAnimation(item.status, item.items!)}
                         </ListItemIcon>
                     </i>
+                    {props.showSelection(item) && !props.useRadioButtons &&
+                        <Checkbox
+                            checked={item.selected}
+                            className={props.classes.checkbox}
+                            color="primary"
+                            onClick={props.handleCheckboxChange(item)} />}
+                    {props.showSelection(item) && props.useRadioButtons &&
+                        <Radio
+                            checked={item.selected}
+                            className={props.classes.checkbox}
+                            color="primary" />}
                     <div data-action={FLAT_TREE_ACTIONS.toggleActive} className={props.classes.renderContainer}>
                         <span style={{ display: 'flex', alignItems: 'center' }}>
                             <ItemIcon type={item.data.type} active={item.active} kind={item.data.kind} groupClass={item.data.kind === ResourceKind.GROUP ? item.data.groupClass : ''} classes={props.classes} />
@@ -293,29 +307,32 @@ export const Tree = withStyles(styles)(
                         {
                             it.open && it.items && it.items.length > 0 &&
                                 it.flatTree ?
-                                    <FlatTree
-                                        it={it}
-                                        itemsMap={itemsMap}
-                                        classes={this.props.classes}
-                                        levelIndentation={levelIndentation}
+                                <FlatTree
+                                    it={it}
+                                    itemsMap={itemsMap}
+                                    showSelection={showSelection}
+                                    classes={this.props.classes}
+                                    useRadioButtons={useRadioButtons}
+                                    levelIndentation={levelIndentation}
+                                    handleCheckboxChange={this.handleCheckboxChange}
+                                    onContextMenu={this.props.onContextMenu}
+                                    handleToggleItemOpen={this.handleToggleItemOpen}
+                                    toggleItemActive={this.props.toggleItemActive}
+                                    getToggableIconClassNames={this.getToggableIconClassNames}
+                                    getProperArrowAnimation={this.getProperArrowAnimation}
+                                /> :
+                                <Collapse in={it.open} timeout="auto" unmountOnExit>
+                                    <Tree
+                                        showSelection={this.props.showSelection}
+                                        items={it.items}
+                                        render={render}
+                                        disableRipple={disableRipple}
+                                        toggleItemOpen={toggleItemOpen}
+                                        toggleItemActive={toggleItemActive}
+                                        level={level + 1}
                                         onContextMenu={this.props.onContextMenu}
-                                        handleToggleItemOpen={this.handleToggleItemOpen}
-                                        toggleItemActive={this.props.toggleItemActive}
-                                        getToggableIconClassNames={this.getToggableIconClassNames}
-                                        getProperArrowAnimation={this.getProperArrowAnimation}
-                                    /> :
-                                    <Collapse in={it.open} timeout="auto" unmountOnExit>
-                                        <Tree
-                                            showSelection={this.props.showSelection}
-                                            items={it.items}
-                                            render={render}
-                                            disableRipple={disableRipple}
-                                            toggleItemOpen={toggleItemOpen}
-                                            toggleItemActive={toggleItemActive}
-                                            level={level + 1}
-                                            onContextMenu={this.props.onContextMenu}
-                                            toggleItemSelection={this.props.toggleItemSelection} />
-                                    </Collapse>
+                                        toggleItemSelection={this.props.toggleItemSelection} />
+                                </Collapse>
                         }
                     </div>)}
             </List>;
index 5d12b419ebe898e2666131e9d5bb85b4adcb98b0..5157394d16a317f6348791c0c276863dba49e070 100644 (file)
@@ -149,7 +149,6 @@ export const loadCollection = (id: string, pickerId: string) =>
 
             const node = getNode(id)(picker);
             if (node && 'kind' in node.value && node.value.kind === ResourceKind.COLLECTION) {
-
                 const files = await services.collectionService.files(node.value.portableDataHash);
                 const tree = createCollectionFilesTree(files);
                 const sorted = sortFilesTree(tree);
index 8b03a12340386a370efd1ada6653ceea1fb62fe8..2949d07ef0aeaea7928bc3c1187b7980104c3fd2 100644 (file)
@@ -30,6 +30,7 @@ import { ResourceKind } from '~/models/resource';
 
 export interface DirectoryArrayInputProps {
     input: DirectoryArrayCommandInputParameter;
+    options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
 }
 
 export const DirectoryArrayInput = ({ input }: DirectoryArrayInputProps) =>
@@ -93,7 +94,9 @@ const mapStateToProps = createStructuredSelector({
 });
 
 const DirectoryArrayInputComponent = connect(mapStateToProps)(
-    class DirectoryArrayInputComponent extends React.Component<DirectoryArrayInputComponentProps & GenericInputProps & DispatchProp, DirectoryArrayInputComponentState> {
+    class DirectoryArrayInputComponent extends React.Component<DirectoryArrayInputComponentProps & GenericInputProps & DispatchProp & {
+        options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
+    }, DirectoryArrayInputComponentState> {
         state: DirectoryArrayInputComponentState = {
             open: false,
             directories: [],
@@ -157,7 +160,7 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)(
                 .reduce((directories, { value }) =>
                     'kind' in value &&
                         value.kind === ResourceKind.COLLECTION &&
-                        formattedDirectories.find(({ portableDataHash }) => value.portableDataHash === portableDataHash)
+                        formattedDirectories.find(({ portableDataHash, name }) => value.portableDataHash === portableDataHash && value.name === name)
                         ? directories.concat(value)
                         : directories, initialDirectories);
 
@@ -179,7 +182,7 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)(
             });
 
             const orderedDirectories = formattedDirectories.reduce((dirs, formattedDir) => {
-                const dir = directories.find(({ portableDataHash }) => portableDataHash === formattedDir.portableDataHash);
+                const dir = directories.find(({ portableDataHash, name }) => portableDataHash === formattedDir.portableDataHash && name === formattedDir.name);
                 return dir
                     ? [...dirs, dir]
                     : dirs;
@@ -241,6 +244,7 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)(
                 <DialogActions>
                     <Button onClick={this.closeDialog}>Cancel</Button>
                     <Button
+                        data-cy='ok-button'
                         variant='contained'
                         color='primary'
                         onClick={this.submit}>Ok</Button>
@@ -276,6 +280,7 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)(
                             pickerId={this.props.commandInput.id}
                             includeCollections
                             showSelection
+                            options={this.props.options}
                             toggleItemSelection={this.refreshDirectories} />
                     </div>
                     <Divider />
index 14d16824966cfaa6fcd4e4d8ee67753e5e4619d3..953100139541d574a958012f4bf27f342c590109 100644 (file)
@@ -29,6 +29,7 @@ import withStyles, { StyleRulesCallback } from '@material-ui/core/styles/withSty
 
 export interface FileArrayInputProps {
     input: FileArrayCommandInputParameter;
+    options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
 }
 export const FileArrayInput = ({ input }: FileArrayInputProps) =>
     <Field
@@ -92,7 +93,9 @@ const mapStateToProps = createStructuredSelector({
 });
 
 const FileArrayInputComponent = connect(mapStateToProps)(
-    class FileArrayInputComponent extends React.Component<FileArrayInputComponentProps & GenericInputProps & DispatchProp, FileArrayInputComponentState> {
+    class FileArrayInputComponent extends React.Component<FileArrayInputComponentProps & GenericInputProps & DispatchProp & {
+        options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
+    }, FileArrayInputComponentState> {
         state: FileArrayInputComponentState = {
             open: false,
             files: [],
@@ -167,7 +170,6 @@ const FileArrayInputComponent = connect(mapStateToProps)(
             });
 
             this.setFiles(files);
-
         }
 
         refreshFiles = () => {
@@ -223,6 +225,7 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                 <DialogActions>
                     <Button onClick={this.closeDialog}>Cancel</Button>
                     <Button
+                        data-cy='ok-button'
                         variant='contained'
                         color='primary'
                         onClick={this.submit}>Ok</Button>
@@ -259,6 +262,7 @@ const FileArrayInputComponent = connect(mapStateToProps)(
                             includeCollections
                             includeFiles
                             showSelection
+                            options={this.props.options}
                             toggleItemSelection={this.refreshFiles} />
                     </div>
                     <Divider />
index e6a504dbb8d2e9852cde01920d9b4398096f2c36..196655e08283b593f04b693abb32d5bd3807c87f 100644 (file)
@@ -111,10 +111,10 @@ const getInputComponent = (input: CommandInputParameter) => {
             return <FloatArrayInput input={input as FloatArrayCommandInputParameter} />;
 
         case isArrayOfType(input, CWLType.FILE):
-            return <FileArrayInput input={input as FileArrayCommandInputParameter} />;
+            return <FileArrayInput options={{ showOnlyOwned: false, showOnlyWritable: false }} input={input as FileArrayCommandInputParameter} />;
 
         case isArrayOfType(input, CWLType.DIRECTORY):
-            return <DirectoryArrayInput input={input as DirectoryArrayCommandInputParameter} />;
+            return <DirectoryArrayInput options={{ showOnlyOwned: false, showOnlyWritable: false }} input={input as DirectoryArrayCommandInputParameter} />;
 
         default:
             return null;