|
1 | 1 | import React from 'react'; |
2 | 2 | import Typography from '@material-ui/core/Typography'; |
3 | | -import { reduxForm, Field, FieldArray } from 'redux-form'; |
4 | | -import Grid from '@material-ui/core/Grid'; |
| 3 | +import { reduxForm } from 'redux-form'; |
5 | 4 | import FormControl from '@material-ui/core/FormControl'; |
6 | 5 | import MenuItem from '@material-ui/core/MenuItem'; |
7 | 6 | import InputLabel from '@material-ui/core/InputLabel'; |
| 7 | +import FormControlLabel from '@material-ui/core/FormControlLabel'; |
8 | 8 | import { TextField, Select } from '../form'; |
| 9 | +import FormSection from '../ui/FormSection'; |
9 | 10 |
|
10 | | -import SimpleMetadataField from '../ui/SimpleMetadataField'; |
| 11 | +import Field from '../ui/Field'; |
11 | 12 | import { required } from '../../utils/FieldValidation'; |
| 13 | +import BoolCheckbox from '../ui/BoolCheckbox'; |
| 14 | +import JobPriority from '../../const/JobPriority'; |
| 15 | +import { KeyValuePairType } from '../ui/FormType'; |
| 16 | +import FieldTypeArray from '../ui/FieldTypeArray'; |
12 | 17 |
|
13 | | -function ImportSidecarForm({ |
14 | | - error, |
15 | | - handleSubmit, |
16 | | -}) { |
| 18 | +const queryParams = () => ( |
| 19 | + <> |
| 20 | + <Field |
| 21 | + name="sidecar" |
| 22 | + label="FileId / URI" |
| 23 | + component={TextField} |
| 24 | + helperText="Either the id of the sidecar file or a URL for locating it" |
| 25 | + required |
| 26 | + fullWidth |
| 27 | + /> |
| 28 | + <Field |
| 29 | + name="startTimeCode" |
| 30 | + label="Start TimeCode" |
| 31 | + component={TextField} |
| 32 | + helperText="Expected start time code of the content" |
| 33 | + fullWidth |
| 34 | + /> |
| 35 | + <FormControlLabel |
| 36 | + control={<Field name="componentImport" component={BoolCheckbox} />} |
| 37 | + label="Component Import" |
| 38 | + helperText="Import sidecar file as a subtitle component." |
| 39 | + /> |
| 40 | + <FormControl fullWidth> |
| 41 | + <InputLabel htmlFor="priority">Priority</InputLabel> |
| 42 | + <Field name="priority" component={Select}> |
| 43 | + {JobPriority.map((priority) => ( |
| 44 | + <MenuItem key={priority} value={priority}> |
| 45 | + {priority} |
| 46 | + </MenuItem> |
| 47 | + ))} |
| 48 | + </Field> |
| 49 | + </FormControl> |
| 50 | + <FieldTypeArray |
| 51 | + name="jobmetadata" |
| 52 | + component={KeyValuePairType} |
| 53 | + label="Job Metadata" |
| 54 | + withHeader={false} |
| 55 | + arrayHeader |
| 56 | + dense |
| 57 | + /> |
| 58 | + <Field |
| 59 | + name="notification" |
| 60 | + label="Notification ID" |
| 61 | + component={TextField} |
| 62 | + helperText="The placeholder job notification to use for this job" |
| 63 | + fullWidth |
| 64 | + /> |
| 65 | + <FieldTypeArray |
| 66 | + name="notificationData" |
| 67 | + component={KeyValuePairType} |
| 68 | + label="Notification Metadata" |
| 69 | + arrayHeader |
| 70 | + withHeader={false} |
| 71 | + dense |
| 72 | + /> |
| 73 | + </> |
| 74 | +); |
| 75 | + |
| 76 | +function ImportSidecarForm({ error, handleSubmit, itemId }) { |
17 | 77 | return ( |
18 | | - <form onSubmit={handleSubmit} style={{ padding: '10px' }}> |
19 | | - <Grid container direction="row" alignItems="center"> |
20 | | - {error |
21 | | - && ( |
22 | | - <Grid item xs={12}> |
23 | | - <Typography color="error">{error}</Typography> |
24 | | - </Grid> |
25 | | - )} |
26 | | - <Grid item xs={12}> |
27 | | - <Field |
28 | | - name="itemId" |
29 | | - label="Item Id" |
30 | | - component={TextField} |
31 | | - validate={[required]} |
32 | | - required |
33 | | - fullWidth |
34 | | - /> |
35 | | - </Grid> |
36 | | - <Grid item xs={12}> |
37 | | - <Field |
38 | | - name="queryParams.sidecar" |
39 | | - label="FileId / URI" |
40 | | - component={TextField} |
41 | | - helperText="Either the id of the sidecar file or a URL for locating it" |
42 | | - required |
43 | | - fullWidth |
44 | | - /> |
45 | | - </Grid> |
46 | | - <Grid item xs={12}> |
47 | | - <Field |
48 | | - name="queryParams.startTimeCode" |
49 | | - label="Start TimeCode" |
50 | | - component={TextField} |
51 | | - helperText="Expected start time code of the content" |
52 | | - fullWidth |
53 | | - /> |
54 | | - </Grid> |
55 | | - <Grid item xs={12}> |
56 | | - <FormControl fullWidth> |
57 | | - <InputLabel htmlFor="priority">Priority</InputLabel> |
58 | | - <Field name="queryParams.priority" component={Select}> |
59 | | - <MenuItem value="HIGHEST">HIGHEST</MenuItem> |
60 | | - <MenuItem value="HIGH">HIGH</MenuItem> |
61 | | - <MenuItem value="MEDIUM">MEDIUM</MenuItem> |
62 | | - <MenuItem value="LOW">LOW</MenuItem> |
63 | | - <MenuItem value="LOWEST">LOWEST</MenuItem> |
64 | | - </Field> |
65 | | - </FormControl> |
66 | | - </Grid> |
67 | | - <Grid item xs={12}> |
68 | | - <FieldArray |
69 | | - name="queryParams.jobmetadata" |
70 | | - label="Job Metadata" |
71 | | - component={SimpleMetadataField} |
72 | | - buttonLabel="Add Job Metadata" |
73 | | - /> |
74 | | - </Grid> |
75 | | - <Grid item xs={12}> |
76 | | - <Field |
77 | | - name="queryParams.notification" |
78 | | - label="Notification ID" |
79 | | - component={TextField} |
80 | | - helperText="The placeholder job notification to use for this job" |
81 | | - fullWidth |
82 | | - /> |
83 | | - </Grid> |
84 | | - <Grid item xs={12}> |
85 | | - <FieldArray |
86 | | - name="queryParams.notificationData" |
87 | | - label="Notification Data" |
88 | | - component={SimpleMetadataField} |
89 | | - buttonLabel="Add Notification Data" |
90 | | - /> |
91 | | - </Grid> |
92 | | - </Grid> |
| 78 | + <form onSubmit={handleSubmit}> |
| 79 | + {error && <Typography color="error">{error}</Typography>} |
| 80 | + {!itemId && ( |
| 81 | + <Field |
| 82 | + name="itemId" |
| 83 | + component={TextField} |
| 84 | + validate={[required]} |
| 85 | + fullWidth |
| 86 | + /> |
| 87 | + )} |
| 88 | + <FormSection |
| 89 | + name="queryParams" |
| 90 | + label="queryParams" |
| 91 | + component={queryParams} |
| 92 | + /> |
| 93 | + <button type="submit" hidden /> |
93 | 94 | </form> |
94 | 95 | ); |
95 | 96 | } |
|
0 commit comments