} 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';
export interface DirectoryArrayInputProps {
input: DirectoryArrayCommandInputParameter;
+ options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
}
export const DirectoryArrayInput = ({ input }: DirectoryArrayInputProps) =>
});
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: [],
this.setState({ open: true });
}
-
closeDialog = () => {
this.setState({ open: false });
}
.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);
});
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;
chipsInput = () =>
<ChipsInput
- value={this.props.input.value}
+ values={this.props.input.value}
onChange={noop}
+ disabled={this.props.commandInput.disabled}
createNewValue={identity}
getLabel={(data: FormattedDirectory) => data.name}
inputComponent={this.textInput} />
{...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 = () =>
<Dialog
<DialogActions>
<Button onClick={this.closeDialog}>Cancel</Button>
<Button
+ data-cy='ok-button'
variant='contained'
color='primary'
onClick={this.submit}>Ok</Button>
pickerId={this.props.commandInput.id}
includeCollections
showSelection
+ options={this.props.options}
toggleItemSelection={this.refreshDirectories} />
</div>
<Divider />
<div className={classes.chips}>
- <Typography variant='subheading'>Selected collections ({this.state.directories.length}):</Typography>
+ <Typography variant='subtitle1'>Selected collections ({this.state.directories.length}):</Typography>
<Chips
orderable
deletable