Files
superset2/superset/assets/javascripts/explore/components/controls/CheckboxControl.jsx
Maxime Beauchemin e53f3032bb [dashboard] adding an option to duplicate slices when "Saving AS" (#3391)
* [dashboard] adding an option to duplicate slices when "Saving AS"

* Fix tests
2017-08-30 14:09:29 -07:00

43 lines
936 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import ControlHeader from '../ControlHeader';
import Checkbox from '../../../components/Checkbox';
const propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.bool,
label: PropTypes.string,
description: PropTypes.string,
onChange: PropTypes.func,
};
const defaultProps = {
value: false,
onChange: () => {},
};
const checkboxStyle = { paddingRight: '5px' };
export default class CheckboxControl extends React.Component {
onChange(checked) {
this.props.onChange(checked);
}
render() {
return (
<ControlHeader
{...this.props}
leftNode={
<Checkbox
onChange={this.onChange.bind(this)}
style={checkboxStyle}
checked={!!this.props.value}
/>
}
/>
);
}
}
CheckboxControl.propTypes = propTypes;
CheckboxControl.defaultProps = defaultProps;