format={formatFiles}
validate={validationSelector(input)} />;
-const parseFiles = (files: CollectionFile[]) =>
- files.length > 0
- ? files.map(parse)
- : undefined;
+const parseFiles = (files: CollectionFile[] | string) =>
+ typeof files === 'string'
+ ? undefined
+ : files.map(parse);
const parse = (file: CollectionFile): File => ({
class: CWLType.FILE,
path: file.path,
});
-const formatFiles = (files: File[] = []) => files.map(format);
+const formatFiles = (files: File[] = []) =>
+ files.map(format);
const format = (file: File): CollectionFile => ({
id: file.location
this.setState({ open: true });
}
-
closeDialog = () => {
this.setState({ open: false });
}
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),
+ })
+ );
});
}
: [...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 = () => {
chipsInput = () =>
<ChipsInput
value={this.props.input.value}
+ disabled={this.props.commandInput.disabled}
onChange={noop}
createNewValue={identity}
getLabel={(file: CollectionFile) => file.name}
{...props}
error={this.props.meta.touched && !!this.props.meta.error}
readOnly
- onClick={this.openDialog}
- onKeyPress={this.openDialog}
+ disabled={this.props.commandInput.disabled}
+ onClick={!this.props.commandInput.disabled ? this.openDialog : undefined}
+ onKeyPress={!this.props.commandInput.disabled ? this.openDialog : undefined}
onBlur={this.props.input.onBlur} />
dialog = () =>
</div>
<Divider />
<div className={classes.chips}>
- <Typography variant='subheading'>Selected files ({this.state.files.length}):</Typography>
+ <Typography variant='subtitle1'>Selected files ({this.state.files.length}):</Typography>
<Chips
orderable
deletable