Files
superset2/superset/assets/javascripts/dashboard/components/RefreshIntervalModal.jsx
Maxime Beauchemin 366ecefbaa Bumping the JS libs to fix the build (#2616)
* bumping the js libs

* New linting rules

* More linting

* More

* Done linting

* npm >=4.5.0

* Bumping node

* Tweaking the build

* Fixing the damn build

* Fixing the apps
2017-04-13 15:04:09 -07:00

58 lines
1.4 KiB
JavaScript

import React from 'react';
import Select from 'react-select';
import ModalTrigger from '../../components/ModalTrigger';
const propTypes = {
triggerNode: React.PropTypes.node.isRequired,
initialRefreshFrequency: React.PropTypes.number,
onChange: React.PropTypes.func,
};
const defaultProps = {
initialRefreshFrequency: 0,
onChange: () => {},
};
const options = [
[0, "Don't refresh"],
[10, '10 seconds'],
[30, '30 seconds'],
[60, '1 minute'],
[300, '5 minutes'],
].map(o => ({ value: o[0], label: o[1] }));
class RefreshIntervalModal extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
refreshFrequency: props.initialRefreshFrequency,
};
}
render() {
return (
<ModalTrigger
triggerNode={this.props.triggerNode}
isButton
modalTitle="Refresh Interval"
modalBody={
<div>
Choose the refresh frequency for this dashboard
<Select
options={options}
value={this.state.refreshFrequency}
onChange={(opt) => {
this.setState({ refreshFrequency: opt.value });
this.props.onChange(opt.value);
}}
/>
</div>
}
/>
);
}
}
RefreshIntervalModal.propTypes = propTypes;
RefreshIntervalModal.defaultProps = defaultProps;
export default RefreshIntervalModal;