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 }); } updateState(value) { this.setState({slackChannels: value}); this.props.onChannelChange(value); } updateStateCheckbox(event) { const value = event.target.checked; this.setState({isSlackEnabled: value}); this.props.onSlackOnChange(value); } render() { const formNameSlackOn = this.props.formName && this.props.formName + '[notify][slack][on]'; const formNameChannels = this.props.formName && this.props.formName + '[notify][slack][channel]'; return (
this.updateState(e.target.value)} />
); } } SlackNotification.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, pagePath: PropTypes.string, onChannelChange: PropTypes.func, onSlackOnChange: PropTypes.func, isSlackEnabled: PropTypes.bool, slackChannels: PropTypes.string, formName: PropTypes.string, };