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 = { isNotification: false, notifSlackChannel: '', }; this.init = this.init.bind(this); this.updateState = this.updateState.bind(this); this.updateStateCheckbox = this.updateStateCheckbox.bind(this); } componentWillMount() { const pageId = this.props.pageId; if (pageId) { this.init(); } this.retrieveData = this.retrieveData.bind(this); } init() { if (!this.props.pageId) { return ; } this.retrieveData(); } /** * Load data of comments and store them in state */ retrieveData() { // get data (desc order array) this.props.crowi.apiGet('/pages.updatePost', {path: this.props.pagePath}) .then(res => { if (res.ok) { this.setState({notifSlackChannel: res.updatePost.join(',')}); } }); } updateState(value) { this.setState({notifSlackChannel: value}); } updateStateCheckbox(event) { const value = event.target.checked; this.setState({isNotification: value}); } render() { return (
this.updateState(e.target.value)} />
); } } SlackNotification.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, pagePath: PropTypes.string, };