diff --git a/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx b/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx index a83fec6a09..301565744f 100644 --- a/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx +++ b/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx @@ -16,6 +16,7 @@ import { modalStyles, trim } from '../../../common/util'; import { weightTypes } from '../enums'; import OverrideConfig from './OverrideConfig/OverrideConfig'; import { useCommonStyles } from '../../../../common.styles'; +import ConditionallyRender from '../../../common/ConditionallyRender'; const payloadOptions = [ { key: 'string', label: 'string' }, @@ -137,6 +138,7 @@ const AddVariant = ({ if (i === index) { o[e.target.name] = e.target.value; } + return o; }) ); @@ -264,16 +266,18 @@ const AddVariant = ({ /> - {overrides.length > 0 && ( -

- Overrides - -

- )} - + 0} + show={ +

+ Overrides + +

+ } + /> - + {' '} ); @@ -294,6 +298,7 @@ AddVariant.propTypes = { validateName: PropTypes.func.isRequired, editVariant: PropTypes.object, title: PropTypes.string, + uiConfig: PropTypes.object, }; export default AddVariant; diff --git a/frontend/src/component/feature/variant/AddVariant/OverrideConfig/OverrideConfig.jsx b/frontend/src/component/feature/variant/AddVariant/OverrideConfig/OverrideConfig.jsx index 5aa035f5e1..ab79ae4f37 100644 --- a/frontend/src/component/feature/variant/AddVariant/OverrideConfig/OverrideConfig.jsx +++ b/frontend/src/component/feature/variant/AddVariant/OverrideConfig/OverrideConfig.jsx @@ -2,13 +2,13 @@ import { connect } from 'react-redux'; import classnames from 'classnames'; import PropTypes from 'prop-types'; -import { Grid, IconButton, Icon } from '@material-ui/core'; +import { Grid, IconButton, Icon, TextField } from '@material-ui/core'; import MySelect from '../../../../common/select'; import InputListField from '../../../../common/input-list-field'; -import { selectStyles } from '../../../../common'; import ConditionallyRender from '../../../../common/ConditionallyRender/ConditionallyRender'; import { useCommonStyles } from '../../../../../common.styles'; import { useStyles } from './OverrideConfig.styles.js'; +import { Autocomplete } from '@material-ui/lab'; const OverrideConfig = ({ overrides, @@ -28,18 +28,14 @@ const OverrideConfig = ({ updateOverrideValues(i, values); }; - const updateSelectValues = i => values => { - updateOverrideValues(i, values ? values.map(v => v.value) : undefined); + const updateSelectValues = i => (e, options) => { + updateOverrideValues(i, options ? options : []); }; - const mapSelectValues = (values = []) => - values.map(v => ({ label: v, value: v })); - return overrides.map((o, i) => { const legalValues = contextDefinitions.find(c => c.name === o.contextName) .legalValues || []; - const options = legalValues.map(v => ({ value: v, label: v, key: v })); return ( @@ -59,16 +55,27 @@ const OverrideConfig = ({ 0} show={ -
- -
+ { + return option === value; + }} + options={legalValues} + onChange={updateSelectValues(i)} + getOptionLabel={option => option} + defaultValue={o.values} + value={o.values} + filterSelectedOptions + size="small" + renderInput={params => ( + + )} + /> } elseShow={ `; -exports[`renders correctly with without variants and no permissions 1`] = ` +exports[`renders correctly without variants and no permissions 1`] = `
'OverrideConfig' ); +const mockStore = { + uiConfig: { + toJS: () => ({ + flags: { + P: true, + }, + }), + }, +}; + +const mockReducer = state => state; + test('renders correctly with without variants', () => { const tree = renderer.create( - - - - - + + + + + + + ); expect(tree).toMatchSnapshot(); }); -test('renders correctly with without variants and no permissions', () => { +test('renders correctly without variants and no permissions', () => { const tree = renderer.create( - - - - - + + + + + + + ); expect(tree).toMatchSnapshot(); @@ -94,20 +112,22 @@ test('renders correctly with with variants', () => { createdAt: '2018-02-04T20:27:52.127Z', }; const tree = renderer.create( - - - - - + + + + + + + ); expect(tree).toMatchSnapshot();