X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/746ddef70989e802ec52e244033ccd3b8c51f60e..215d0b7a7e1f69765c5f2a1139e52d8c427066eb:/src/views/run-process-panel/inputs/file-input.tsx diff --git a/src/views/run-process-panel/inputs/file-input.tsx b/src/views/run-process-panel/inputs/file-input.tsx index 66070f77bf..218bf4189c 100644 --- a/src/views/run-process-panel/inputs/file-input.tsx +++ b/src/views/run-process-panel/inputs/file-input.tsx @@ -2,35 +2,42 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { memoize } from 'lodash/fp'; import { isRequiredInput, FileCommandInputParameter, File, CWLType -} from '~/models/workflow'; +} from 'models/workflow'; import { Field } from 'redux-form'; -import { ERROR_MESSAGE } from '~/validators/require'; -import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core'; +import { ERROR_MESSAGE } from 'validators/require'; +import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core'; import { GenericInputProps, GenericInput } from './generic-input'; -import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker'; +import { ProjectsTreePicker } from 'views-components/projects-tree-picker/projects-tree-picker'; import { connect, DispatchProp } from 'react-redux'; -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 { CollectionFile, CollectionFileType } from '~/models/collection-file'; +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 { CollectionFile, CollectionFileType } from 'models/collection-file'; export interface FileInputProps { input: FileCommandInputParameter; + options?: { showOnlyOwned: boolean, showOnlyWritable: boolean }; } -export const FileInput = ({ input }: FileInputProps) => + +type DialogContentCssRules = 'root' | 'pickerWrapper'; + +export const FileInput = ({ input, options }: FileInputProps) => ; const format = (value?: File) => value ? value.basename : ''; @@ -54,7 +61,9 @@ interface FileInputComponentState { } const FileInputComponent = connect()( - class FileInputComponent extends React.Component { + class FileInputComponent extends React.Component { state: FileInputComponentState = { open: false, }; @@ -67,11 +76,12 @@ const FileInputComponent = connect()( render() { return <> {this.renderInput()} - {this.renderDialog()} + ; } openDialog = () => { + this.componentDidMount(); this.setState({ open: true }); } @@ -106,32 +116,52 @@ const FileInputComponent = connect()( {...this.props} />; } - renderDialog() { - return - Choose a file - + dialogContentStyles: StyleRulesCallback = ({ spacing }) => ({ + root: { + display: 'flex', + flexDirection: 'column', + }, + pickerWrapper: { + flexBasis: `${spacing.unit * 8}vh`, + flexShrink: 1, + minHeight: 0, + }, + }); + + dialog = withStyles(this.dialogContentStyles)( + ({ classes }: WithStyles) => + + Choose a file + + + + + + + + + ); + + dialogContent = withStyles(this.dialogContentStyles)( + ({ classes }: WithStyles) => +
- - - - - -
; - } - - }); + + ); + });