'use strict'; const React = require('react'); const FeatureForm = require('./FeatureForm'); const LogEntryList = require('../log/LogEntryList'); const eventStore = require('../../stores/EventStore'); const Feature = React.createClass({ getInitialState() { return { editMode: false, showHistory: false, events: [], }; }, handleEventsResponse(response) { this.setState({ events: response }); }, toggleHistory() { eventStore.getEventsByName(this.props.feature.name).then(this.handleEventsResponse); this.setState({ showHistory: !this.state.showHistory }); }, toggleEditMode() { this.setState({ editMode: !this.state.editMode }); }, saveFeature(feature) { this.props.onChange(feature); this.toggleEditMode(); }, archiveFeature() { if (window.confirm(`Are you sure you want to delete ${this.props.feature.name}?`)) { // eslint-disable-line no-alert this.props.onArchive(this.props.feature); } }, renderEditMode() { return ( ); }, render() { return ( {this.props.feature.name}
{this.props.feature.description || '\u00a0'} {this.props.feature.strategy}
{this.state.editMode ? this.renderEditMode() : this.renderEmptyRow()} {this.state.showHistory ? this.renderHistory() : this.renderEmptyRow()} ); }, renderEmptyRow() { return (); }, renderHistory() { return ( ); }, }); module.exports = Feature;