import React from 'react'; import PropTypes from 'prop-types'; /** * * @author Yuki Takei * * @export * @class SlackNotification * @extends {React.Component} */ export default class SlackNotification extends React.Component { constructor(props) { super(props); this.state = { isSlackEnabled: this.props.isSlackEnabled, slackChannels: this.props.slackChannels, }; this.updateState = this.updateState.bind(this); this.updateStateCheckbox = this.updateStateCheckbox.bind(this); } componentWillReceiveProps(nextProps) { this.setState({ isSlackEnabled: nextProps.isSlackEnabled, slackChannels: nextProps.slackChannels }); } getCurrentOptionsToSave() { return Object.assign({}, this.state); } updateState(value) { this.setState({slackChannels: value}); // dispatch event if (this.props.onChannelChange != null) { this.props.onChannelChange(value); } } updateStateCheckbox(event) { const value = event.target.checked; this.setState({isSlackEnabled: value}); // dispatch event if (this.props.onEnabledFlagChange != null) { this.props.onEnabledFlagChange(value); } } render() { return (
this.updateState(e.target.value)} />
); } } SlackNotification.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, pagePath: PropTypes.string, isSlackEnabled: PropTypes.bool, slackChannels: PropTypes.string, onChannelChange: PropTypes.func, onEnabledFlagChange: PropTypes.func, }; SlackNotification.defaultProps = { slackChannels: '', };