//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from 'react';
+import React from 'react';
import { connect, DispatchProp } from 'react-redux';
import { memoize } from 'lodash/fp';
import { Field } from 'redux-form';
-import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core';
+import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
import {
isRequiredInput,
DirectoryCommandInputParameter,
CWLType,
Directory
-} from '~/models/workflow';
+} from 'models/workflow';
import { GenericInputProps, GenericInput } from './generic-input';
-import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker';
-import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
-import { TreeItem } from '~/components/tree/tree';
-import { ProjectsTreePickerItem } from '~/views-components/projects-tree-picker/generic-projects-tree-picker';
-import { CollectionResource } from '~/models/collection';
-import { ResourceKind } from '~/models/resource';
-import { ERROR_MESSAGE } from '~/validators/require';
+import { ProjectsTreePicker } from 'views-components/projects-tree-picker/projects-tree-picker';
+import { initProjectsTreePicker } from 'store/tree-picker/tree-picker-actions';
+import { TreeItem } from 'components/tree/tree';
+import { ProjectsTreePickerItem } from 'store/tree-picker/tree-picker-middleware';
+import { CollectionResource } from 'models/collection';
+import { ResourceKind } from 'models/resource';
+import { ERROR_MESSAGE } from 'validators/require';
export interface DirectoryInputProps {
input: DirectoryCommandInputParameter;
options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
}
+
+type DialogContentCssRules = 'root';
+
export const DirectoryInput = ({ input, options }: DirectoryInputProps) =>
<Field
name={input.id}
commandInput={input}
- component={DirectoryInputComponent}
+ component={DirectoryInputComponent as any}
format={format}
parse={parse}
{...{
{...this.props} />;
}
+ dialogContentStyles: StyleRulesCallback<DialogContentCssRules> = ({ spacing }) => ({
+ root: {
+ height: `${spacing.unit * 8}vh`,
+ },
+ });
+
renderDialog() {
return <Dialog
open={this.state.open}
maxWidth='md'>
<DialogTitle>Choose a directory</DialogTitle>
<DialogContent>
- <ProjectsTreePicker
- pickerId={this.props.commandInput.id}
- includeCollections
- options={this.props.options}
- toggleItemActive={this.setDirectory} />
+ <this.dialogContent />
</DialogContent>
<DialogActions>
<Button onClick={this.closeDialog}>Cancel</Button>
</Dialog>;
}
- });
-
+ dialogContent = withStyles(this.dialogContentStyles)(
+ ({ classes }: WithStyles<DialogContentCssRules>) =>
+ <div className={classes.root}>
+ <ProjectsTreePicker
+ pickerId={this.props.commandInput.id}
+ includeCollections
+ options={this.props.options}
+ toggleItemActive={this.setDirectory} />
+ </div>
+ );
+ });