X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/36f8f69a5bf5c19ad3c8de57466944e2b7d0c390..1739b7bc6b6602cdfbaca0f5fe899c9e6fd7fe1f:/src/views/run-process-panel/inputs/directory-array-input.tsx diff --git a/src/views/run-process-panel/inputs/directory-array-input.tsx b/src/views/run-process-panel/inputs/directory-array-input.tsx index d4f4cb6d..2949d07e 100644 --- a/src/views/run-process-panel/inputs/directory-array-input.tsx +++ b/src/views/run-process-panel/inputs/directory-array-input.tsx @@ -11,7 +11,7 @@ import { } from '~/models/workflow'; import { Field } from 'redux-form'; import { ERROR_MESSAGE } from '~/validators/require'; -import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, Divider, Grid, WithStyles, Typography } from '@material-ui/core'; +import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, Divider, WithStyles, Typography } from '@material-ui/core'; import { GenericInputProps, GenericInput } from './generic-input'; import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker'; import { connect, DispatchProp } from 'react-redux'; @@ -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 { + class DirectoryArrayInputComponent extends React.Component { state: DirectoryArrayInputComponentState = { open: false, directories: [], @@ -119,7 +122,6 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)( this.setState({ open: true }); } - closeDialog = () => { this.setState({ open: false }); } @@ -158,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); @@ -180,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; @@ -212,8 +214,9 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)( chipsInput = () => data.name} inputComponent={this.textInput} /> @@ -223,9 +226,10 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)( {...props} error={this.props.meta.touched && !!this.props.meta.error} readOnly - onClick={this.openDialog} - onKeyPress={this.openDialog} - onBlur={this.props.input.onBlur} /> + onClick={!this.props.commandInput.disabled ? this.openDialog : undefined} + onKeyPress={!this.props.commandInput.disabled ? this.openDialog : undefined} + onBlur={this.props.input.onBlur} + disabled={this.props.commandInput.disabled} /> dialog = () => @@ -275,11 +280,12 @@ const DirectoryArrayInputComponent = connect(mapStateToProps)( pickerId={this.props.commandInput.id} includeCollections showSelection + options={this.props.options} toggleItemSelection={this.refreshDirectories} />
- Selected collections ({this.state.directories.length}): + Selected collections ({this.state.directories.length}):