1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Select, FormControl, InputLabel, MenuItem, Tooltip, withStyles, WithStyles } from '@material-ui/core';
7 import { WorkflowResource } from '~/models/workflow';
8 import { DetailsIcon } from '~/components/icon/icon';
10 export interface WorkflowPresetSelectProps {
11 workflow: WorkflowResource;
12 selectedPreset: WorkflowResource;
13 presets: WorkflowResource[];
14 onChange: (preset: WorkflowResource) => void;
17 type CssRules = 'root' | 'icon';
19 export const WorkflowPresetSelect = withStyles<CssRules>(theme => ({
24 color: theme.palette.text.hint,
29 class extends React.Component<WorkflowPresetSelectProps & WithStyles<CssRules>> {
33 const { selectedPreset, workflow, presets, classes } = this.props;
36 <div className={classes.root}>
37 <FormControl fullWidth>
38 <InputLabel>Preset</InputLabel>
40 value={selectedPreset.uuid}
41 onChange={this.handleChange}>
42 <MenuItem value={workflow.uuid}>
46 ({ uuid, name }) => <MenuItem key={uuid} value={uuid}>{name}</MenuItem>
50 <Tooltip title='List of already defined set of inputs to run a workflow'>
51 <DetailsIcon className={classes.icon} />
57 handleChange = ({ target }: React.ChangeEvent<HTMLSelectElement>) => {
59 const { workflow, presets, onChange } = this.props;
61 const selectedPreset = [workflow, ...presets]
62 .find(({ uuid }) => uuid === target.value);
65 onChange(selectedPreset);