-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoImportRuleForm.jsx
More file actions
109 lines (104 loc) · 3.66 KB
/
AutoImportRuleForm.jsx
File metadata and controls
109 lines (104 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import FormControl from '@material-ui/core/FormControl';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import InputLabel from '@material-ui/core/InputLabel';
import MenuItem from '@material-ui/core/MenuItem';
import Typography from '@material-ui/core/Typography';
import { reduxForm, Field, FormSection } from 'redux-form';
import JobPriority from '../../const/JobPriority';
import { required } from '../../utils/FieldValidation';
import { TextField, Select } from '../form';
import { MetadataType } from '../metadata/MetadataForm';
import { loadShapeTagOptions } from '../shapetag/ShapeTagSelect';
import { loadStorageOptions } from '../storage/StorageSelect';
import BoolCheckbox from '../ui/BoolCheckbox';
import ChipInput from '../ui/ChipInput';
import FieldTypeArray from '../ui/FieldTypeArray';
import { StatefulAsyncSelect } from '../ui/Select';
import { SimpleMetadataTypeForm } from '../ui/SimpleMetadataField';
import UserSelect from '../user/UserSelect';
function FilenameFilterTypeForm() {
return (
<>
<Field name="pattern" label="Filter Pattern" component={TextField} fullWidth />
<Field name="tag" label="Filter Tag" component={ChipInput} simple fullWidth />
</>
);
}
function AutoImportRuleTypeForm() {
return (
<>
<FormControlLabel
control={<Field name="enabled" component={BoolCheckbox} />}
label="Enabled"
/>
<FormControl fullWidth>
<InputLabel htmlFor="priority">Priority</InputLabel>
<Field name="priority" component={Select}>
{JobPriority.map((priority) => (
<MenuItem key={priority} value={priority}>
{priority}
</MenuItem>
))}
</Field>
</FormControl>
<FormControlLabel
control={<Field name="fileNameAsTitle" component={BoolCheckbox} />}
label="File Name As Title"
/>
<FormControlLabel
control={<Field name="ignoreSidecarImport" component={BoolCheckbox} />}
label="Ignore Sidecar Import"
/>
<Field
name="tag"
label="Shape Tag"
component={StatefulAsyncSelect}
loadOptions={loadShapeTagOptions}
cacheOptions
isClearable
fullWidth
isMulti
/>
<Field name="resourceId" label="Resource ID" component={TextField} fullWidth />
<Field name="settingsId" label="Settings ID" component={TextField} fullWidth />
<Field name="projection" label="Projection" component={TextField} fullWidth />
<UserSelect name="user" label="User" isClearable fullWidth />
<FieldTypeArray
name="excludeFilter"
label="Exclude Filter"
component={FilenameFilterTypeForm}
/>
<FieldTypeArray
name="shapeTagFilter"
label="Shape Tag Filter"
component={FilenameFilterTypeForm}
/>
<FormSection name="jobmetadata" component={SimpleMetadataTypeForm} label="Job Metadata" />
<FormSection name="metadata" component={MetadataType} />
</>
);
}
function AutoImportRuleForm({ error, handleSubmit, storageId }) {
return (
<form onSubmit={handleSubmit}>
{error && <Typography color="error">{error}</Typography>}
{!storageId && (
<Field
name="storageId"
label="Storage ID"
component={StatefulAsyncSelect}
loadOptions={loadStorageOptions}
cacheOptions
isClearable
required
fullWidth
disableInitial
validate={[required]}
/>
)}
<FormSection name="autoImportRuleDocument" component={AutoImportRuleTypeForm} />
<button type="submit" hidden />
</form>
);
}
export default reduxForm()(AutoImportRuleForm);