[ARVADOS-WORKBENCH2] updated: 1.2.0-504-g7597dab
Git user
git at public.curoverse.com
Tue Oct 2 01:48:25 EDT 2018
Summary of changes:
src/models/workflow.ts | 8 ++-
src/views/run-process-panel/inputs/file-input.tsx | 2 +-
src/views/run-process-panel/inputs/float-input.tsx | 2 +-
.../run-process-panel/inputs/generic-input.tsx | 17 +++--
src/views/run-process-panel/inputs/int-input.tsx | 2 +-
.../run-process-panel/inputs/string-input.tsx | 2 +-
.../run-process-panel/run-process-inputs-form.tsx | 77 ++++++++++++++--------
7 files changed, 72 insertions(+), 38 deletions(-)
via 7597dab11b25e5bb67becf99db622f7f7737a235 (commit)
from 9c15617f293ab41ea8b8e2962ecd1d109b80a026 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 7597dab11b25e5bb67becf99db622f7f7737a235
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Oct 2 07:22:46 2018 +0200
Improve run process form layout
Feature #13863
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/models/workflow.ts b/src/models/workflow.ts
index 1cb3d46..88ceb6e 100644
--- a/src/models/workflow.ts
+++ b/src/models/workflow.ts
@@ -119,7 +119,7 @@ export const getWorkflowInputs = (workflowDefinition: WorkflowResoruceDefinition
: undefined;
};
export const getInputLabel = (input: CommandInputParameter) => {
- return `${input.label || input.id}${isRequiredInput(input) ? '*' : ''}`;
+ return `${input.label || input.id}`;
};
export const isRequiredInput = ({ type }: CommandInputParameter) => {
@@ -132,6 +132,12 @@ export const isRequiredInput = ({ type }: CommandInputParameter) => {
}
return true;
};
+
+export const isPrimitiveOfType = (input: GenericCommandInputParameter<any, any>, type: CWLType) =>
+ input.type instanceof Array
+ ? input.type.indexOf(type) > -1
+ : input.type === type;
+
export const stringifyInputType = ({ type }: CommandInputParameter) => {
if (typeof type === 'string') {
return type;
diff --git a/src/views/run-process-panel/inputs/file-input.tsx b/src/views/run-process-panel/inputs/file-input.tsx
index a356d82..b018584 100644
--- a/src/views/run-process-panel/inputs/file-input.tsx
+++ b/src/views/run-process-panel/inputs/file-input.tsx
@@ -38,5 +38,5 @@ export const FileInput = ({ input }: FileInputProps) =>
const FileInputComponent = (props: GenericInputProps) =>
<GenericInput
component={props =>
- <Input readOnly value={props.input.value} />}
+ <Input readOnly fullWidth value={props.input.value} />}
{...props} />;
diff --git a/src/views/run-process-panel/inputs/float-input.tsx b/src/views/run-process-panel/inputs/float-input.tsx
index 62093ac..31a7ca5 100644
--- a/src/views/run-process-panel/inputs/float-input.tsx
+++ b/src/views/run-process-panel/inputs/float-input.tsx
@@ -51,4 +51,4 @@ class FloatInputComponent extends React.Component<GenericInputProps> {
}
const Input = (props: GenericInputProps) =>
- <MaterialInput {...props.input} />;
+ <MaterialInput fullWidth {...props.input} />;
diff --git a/src/views/run-process-panel/inputs/generic-input.tsx b/src/views/run-process-panel/inputs/generic-input.tsx
index 8eb1ca3..4ed2654 100644
--- a/src/views/run-process-panel/inputs/generic-input.tsx
+++ b/src/views/run-process-panel/inputs/generic-input.tsx
@@ -4,8 +4,8 @@
import * as React from 'react';
import { WrappedFieldProps } from 'redux-form';
-import { FormGroup, FormLabel, Input, FormHelperText } from '@material-ui/core';
-import { GenericCommandInputParameter, getInputLabel } from '../../../models/workflow';
+import { FormGroup, FormLabel, Input, FormHelperText, FormControl } from '@material-ui/core';
+import { GenericCommandInputParameter, getInputLabel, isRequiredInput } from '../../../models/workflow';
export type GenericInputProps = WrappedFieldProps & {
commandInput: GenericCommandInputParameter<any, any>;
@@ -16,9 +16,16 @@ type GenericInputContainerProps = GenericInputProps & {
};
export const GenericInput = ({ component: Component, ...props }: GenericInputContainerProps) => {
return <FormGroup>
- <FormLabel error={props.meta.touched && props.meta.error}>{getInputLabel(props.commandInput)}</FormLabel>
- <Component {...props} />
- <FormHelperText error={props.meta.touched && props.meta.error}>
+ <FormLabel
+ focused={props.meta.active}
+ required={isRequiredInput(props.commandInput)}
+ error={props.meta.touched && !!props.meta.error}>
+ {getInputLabel(props.commandInput)}
+ </FormLabel>
+ <FormControl>
+ <Component {...props} />
+ </FormControl>
+ <FormHelperText error={props.meta.touched && !!props.meta.error}>
{
props.meta.touched && props.meta.error
? props.meta.error
diff --git a/src/views/run-process-panel/inputs/int-input.tsx b/src/views/run-process-panel/inputs/int-input.tsx
index 6d0307a..1e4c17c 100644
--- a/src/views/run-process-panel/inputs/int-input.tsx
+++ b/src/views/run-process-panel/inputs/int-input.tsx
@@ -32,5 +32,5 @@ const IntInputComponent = (props: GenericInputProps) =>
const Input = (props: GenericInputProps) =>
- <MaterialInput type='number' {...props.input} />;
+ <MaterialInput fullWidth type='number' {...props.input} />;
diff --git a/src/views/run-process-panel/inputs/string-input.tsx b/src/views/run-process-panel/inputs/string-input.tsx
index e952593..dc7075c 100644
--- a/src/views/run-process-panel/inputs/string-input.tsx
+++ b/src/views/run-process-panel/inputs/string-input.tsx
@@ -29,4 +29,4 @@ const StringInputComponent = (props: GenericInputProps) =>
{...props} />;
const Input = (props: GenericInputProps) =>
- <MaterialInput {...props.input} />;
\ No newline at end of file
+ <MaterialInput fullWidth {...props.input} />;
\ No newline at end of file
diff --git a/src/views/run-process-panel/run-process-inputs-form.tsx b/src/views/run-process-panel/run-process-inputs-form.tsx
index de5903b..b928996 100644
--- a/src/views/run-process-panel/run-process-inputs-form.tsx
+++ b/src/views/run-process-panel/run-process-inputs-form.tsx
@@ -4,15 +4,16 @@
import * as React from 'react';
import { reduxForm, InjectedFormProps } from 'redux-form';
-import { WorkflowResource, CommandInputParameter, CWLType, IntCommandInputParameter, BooleanCommandInputParameter, FileCommandInputParameter } from '~/models/workflow';
+import { CommandInputParameter, CWLType, IntCommandInputParameter, BooleanCommandInputParameter, FileCommandInputParameter } from '~/models/workflow';
import { IntInput } from '~/views/run-process-panel/inputs/int-input';
import { StringInput } from '~/views/run-process-panel/inputs/string-input';
-import { StringCommandInputParameter, FloatCommandInputParameter, File } from '../../models/workflow';
+import { StringCommandInputParameter, FloatCommandInputParameter, isPrimitiveOfType } from '../../models/workflow';
import { FloatInput } from '~/views/run-process-panel/inputs/float-input';
import { BooleanInput } from './inputs/boolean-input';
import { FileInput } from './inputs/file-input';
import { connect } from 'react-redux';
import { compose } from 'redux';
+import { Grid, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
const RUN_PROCESS_INPUTS_FORM = 'runProcessInputsForm';
@@ -28,29 +29,49 @@ export const RunProcessInputsForm = compose(
})),
reduxForm<any, RunProcessInputFormProps>({
form: RUN_PROCESS_INPUTS_FORM
- }))((props: InjectedFormProps & RunProcessInputFormProps) =>
- <form>
- {props.inputs.map(input => {
- switch (true) {
- case input.type === CWLType.BOOLEAN:
- return <BooleanInput key={input.id} input={input as BooleanCommandInputParameter} />;
-
- case input.type === CWLType.INT:
- case input.type === CWLType.LONG:
- return <IntInput key={input.id} input={input as IntCommandInputParameter} />;
-
- case input.type === CWLType.FLOAT:
- case input.type === CWLType.DOUBLE:
- return <FloatInput key={input.id} input={input as FloatCommandInputParameter} />;
-
- case input.type === CWLType.STRING:
- return <StringInput key={input.id} input={input as StringCommandInputParameter} />;
-
- case input.type === CWLType.FILE:
- return <FileInput key={input.id} input={input as FileCommandInputParameter} />;
-
- default:
- return null;
- }
- })}
- </form>);
+ }))(
+ (props: InjectedFormProps & RunProcessInputFormProps) =>
+ <form>
+ <Grid container>
+ {props.inputs.map(input =>
+ <InputItem input={input} key={input.id} />)}
+ </Grid>
+ </form>);
+
+type CssRules = 'inputItem';
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+ inputItem: {
+ marginBottom: theme.spacing.unit * 2,
+ }
+});
+
+const InputItem = withStyles(styles)(
+ (props: WithStyles<CssRules> & { input: CommandInputParameter }) =>
+ <Grid item xs={12} className={props.classes.inputItem}>
+ {getInputComponent(props.input)}
+ </Grid>);
+
+const getInputComponent = (input: CommandInputParameter) => {
+ switch (true) {
+ case isPrimitiveOfType(input, CWLType.BOOLEAN):
+ return <BooleanInput input={input as BooleanCommandInputParameter} />;
+
+ case isPrimitiveOfType(input, CWLType.INT):
+ case isPrimitiveOfType(input, CWLType.LONG):
+ return <IntInput input={input as IntCommandInputParameter} />;
+
+ case isPrimitiveOfType(input, CWLType.FLOAT):
+ case isPrimitiveOfType(input, CWLType.DOUBLE):
+ return <FloatInput input={input as FloatCommandInputParameter} />;
+
+ case isPrimitiveOfType(input, CWLType.STRING):
+ return <StringInput input={input as StringCommandInputParameter} />;
+
+ case isPrimitiveOfType(input, CWLType.FILE):
+ return <FileInput input={input as FileCommandInputParameter} />;
+
+ default:
+ return null;
+ }
+};
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list