2018-05-20 04:07:41 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import {
|
|
|
|
Row,
|
|
|
|
Col,
|
|
|
|
ControlLabel
|
|
|
|
} from 'react-bootstrap';
|
|
|
|
|
|
|
|
import TB from '../Toggle-Button';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
action: PropTypes.string.isRequired,
|
|
|
|
explain: PropTypes.string,
|
|
|
|
flag: PropTypes.bool.isRequired,
|
|
|
|
flagName: PropTypes.string.isRequired,
|
|
|
|
toggleFlag: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function ToggleSetting({
|
|
|
|
action,
|
|
|
|
explain,
|
|
|
|
flag,
|
|
|
|
flagName,
|
2018-05-25 16:49:47 +01:00
|
|
|
toggleFlag,
|
|
|
|
...restProps
|
2018-05-20 04:07:41 +01:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<Row className='inline-form'>
|
|
|
|
<Col sm={ 8 } xs={ 12 }>
|
2018-05-25 16:49:47 +01:00
|
|
|
<ControlLabel className='toggle-label' htmlFor={ flagName }>
|
2018-05-20 04:07:41 +01:00
|
|
|
<p>
|
|
|
|
<strong>
|
|
|
|
{ action }
|
|
|
|
</strong>
|
|
|
|
<br />
|
|
|
|
{
|
|
|
|
explain ? <em>{explain}</em> : null
|
|
|
|
}
|
|
|
|
</p>
|
|
|
|
</ControlLabel>
|
|
|
|
</Col>
|
|
|
|
<Col sm={ 4 } xs={ 12 }>
|
|
|
|
<TB
|
|
|
|
name={ flagName }
|
|
|
|
onChange={ toggleFlag }
|
|
|
|
value={ flag }
|
2018-05-25 16:49:47 +01:00
|
|
|
{...restProps}
|
2018-05-20 04:07:41 +01:00
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleSetting.displayName = 'ToggleSetting';
|
|
|
|
ToggleSetting.propTypes = propTypes;
|