1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { reduxForm, Field, InjectedFormProps } from 'redux-form';
7 import { Grid, Typography, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
8 import { TextField } from 'components/text-field/text-field';
9 import { ProjectInput, ProjectCommandInputParameter } from 'views/run-process-panel/inputs/project-input';
10 import { PROCESS_NAME_VALIDATION } from 'validators/validators';
11 import { ProjectResource } from 'models/project';
12 import { UserResource } from 'models/user';
13 import { WorkflowResource } from 'models/workflow';
14 import { ArvadosTheme } from 'common/custom-theme';
16 export const RUN_PROCESS_BASIC_FORM = 'runProcessBasicForm';
18 export interface RunProcessBasicFormData {
20 owner?: ProjectResource | UserResource;
23 interface RunProcessBasicFormProps {
24 workflow?: WorkflowResource
27 type CssRules = 'name' | 'description';
29 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
32 color: theme.customs.colors.greyD,
39 export const RunProcessBasicForm =
40 reduxForm<RunProcessBasicFormData, RunProcessBasicFormProps>({
41 form: RUN_PROCESS_BASIC_FORM
42 })(withStyles(styles)((props: InjectedFormProps<RunProcessBasicFormData, RunProcessBasicFormProps> & RunProcessBasicFormProps & WithStyles<CssRules>) =>
44 <Grid container spacing={32}>
46 {props.workflow && <Typography className={props.classes.name}
47 data-cy='workflow-name'>{props.workflow.name}</Typography>}
50 {props.workflow && <Typography className={props.classes.description}
51 data-cy='workflow-description'
52 //dangerouslySetInnerHTML is ok here only if description is sanitized,
53 //which it is before it is loaded into the redux store
54 dangerouslySetInnerHTML={{ __html: props.workflow.description }}
57 <Grid item xs={12} md={6}>
60 component={TextField as any}
61 label="Name for this workflow run"
63 validate={PROCESS_NAME_VALIDATION} />
65 <Grid item xs={12} md={6}>
66 <ProjectInput required input={{
68 label: "Project where the workflow will run"
69 } as ProjectCommandInputParameter}
70 options={{ showOnlyOwned: false, showOnlyWritable: true }} />