|
1 | 1 | import React from 'react';
|
2 | 2 | import PropTypes from 'prop-types';
|
3 |
| -import { Row, Col, ControlLabel, FormGroup, Form } from 'patternfly-react'; |
4 |
| -import TagSelector from './tagSelector'; |
5 |
| -import ValueSelector from './valueSelector'; |
| 3 | +import { Row, Col, Form } from 'patternfly-react'; |
6 | 4 |
|
7 |
| -const TagModifier = ({ |
8 |
| - tags, selectedTagCategory, selectedTagValue, onTagCategoryChange, onTagValueChange, header, categoryLabel, valueLabel, multiValue, |
9 |
| -}) => { |
10 |
| - const tagValues = (tags.find(tag => (tag.id === selectedTagCategory.id)) && tags.find(tag => (tag.id === selectedTagCategory.id)).values) || []; |
11 |
| - const tagCategories = tags.map(tag => ({ description: tag.description, id: tag.id, singleValue: tag.singleValue })) || []; |
12 |
| - return ( |
13 |
| - <React.Fragment> |
14 |
| - <Row><Col lg={12}><h2>{header}</h2></Col></Row> |
15 |
| - <Form horizontal> |
16 |
| - <FormGroup> |
17 |
| - <Col xs={12} md={4} lg={6}> |
18 |
| - <ControlLabel>{categoryLabel}</ControlLabel> |
19 |
| - </Col> |
20 |
| - <Col xs={12} md={8} lg={6}> |
21 |
| - <TagSelector tagCategories={tagCategories} onTagCategoryChange={onTagCategoryChange} selectedOption={selectedTagCategory} /> |
22 |
| - </Col> |
23 |
| - </FormGroup> |
24 |
| - <FormGroup> |
25 |
| - <Col xs={12} md={4} lg={6}> |
26 |
| - <ControlLabel>{valueLabel}</ControlLabel> |
27 |
| - </Col> |
28 |
| - <Col xs={12} md={8} lg={6}> |
29 |
| - <ValueSelector tagValues={tagValues} onTagValueChange={onTagValueChange} selectedOption={selectedTagValue} multiValue={multiValue} /> |
30 |
| - </Col> |
31 |
| - </FormGroup> |
32 |
| - </Form> |
| 5 | +const TagModifier = ({ header, children }) => ( |
| 6 | + <React.Fragment> |
| 7 | + <Row><Col lg={12}><h2>{header}</h2></Col></Row> |
| 8 | + <Form horizontal> |
| 9 | + {children} |
| 10 | + </Form> |
33 | 11 |
|
34 |
| - </React.Fragment> |
35 |
| - ); |
36 |
| -}; |
| 12 | + </React.Fragment> |
| 13 | +); |
37 | 14 |
|
38 | 15 | TagModifier.propTypes = {
|
39 |
| - tags: PropTypes.arrayOf(PropTypes.object), |
40 |
| - selectedTagCategory: PropTypes.object.isRequired, |
41 |
| - onTagCategoryChange: PropTypes.func.isRequired, |
42 |
| - selectedTagValue: PropTypes.object.isRequired, |
43 |
| - onTagValueChange: PropTypes.func.isRequired, |
44 | 16 | header: PropTypes.string,
|
45 |
| - categoryLabel: PropTypes.string, |
46 |
| - valueLabel: PropTypes.string, |
47 |
| - multiValue: PropTypes.bool, |
| 17 | + children: PropTypes.arrayOf(PropTypes.element).isRequired, |
48 | 18 | };
|
49 | 19 |
|
50 | 20 | TagModifier.defaultProps = {
|
51 | 21 | header: 'Add/Modify tag',
|
52 |
| - categoryLabel: 'Category:', |
53 |
| - valueLabel: 'Assigned Value:', |
54 |
| - multiValue: true, |
55 | 22 | };
|
56 | 23 |
|
57 | 24 | export default TagModifier;
|
0 commit comments