Reformatted team_settings.jsx to meet style guide requirements.

Этот коммит содержится в:
JoramWilander
2015-09-01 11:39:28 -04:00
родитель 5d44b01f40
Коммит 99b37c0368

Просмотреть файл

@@ -7,30 +7,27 @@ var FeatureTab = require('./team_feature_tab.jsx');
var GeneralTab = require('./team_general_tab.jsx'); var GeneralTab = require('./team_general_tab.jsx');
var utils = require('../utils/utils.jsx'); var utils = require('../utils/utils.jsx');
module.exports = React.createClass({ export default class TeamSettings extends React.Component {
displayName: 'Team Settings', constructor(props) {
propTypes: { super(props);
activeTab: React.PropTypes.string.isRequired,
activeSection: React.PropTypes.string.isRequired, this.onChange = this.onChange.bind(this);
updateSection: React.PropTypes.func.isRequired,
teamDisplayName: React.PropTypes.string.isRequired this.state = {team: TeamStore.getCurrent()};
}, }
componentDidMount: function() { componentDidMount() {
TeamStore.addChangeListener(this.onChange); TeamStore.addChangeListener(this.onChange);
}, }
componentWillUnmount: function() { componentWillUnmount() {
TeamStore.removeChangeListener(this.onChange); TeamStore.removeChangeListener(this.onChange);
}, }
onChange: function() { onChange() {
var team = TeamStore.getCurrent(); var team = TeamStore.getCurrent();
if (!utils.areStatesEqual(this.state.team, team)) { if (!utils.areStatesEqual(this.state.team, team)) {
this.setState({team: team}); this.setState({team: team});
} }
}, }
getInitialState: function() { render() {
return {team: TeamStore.getCurrent()};
},
render: function() {
var result; var result;
switch (this.props.activeTab) { switch (this.props.activeTab) {
case 'general': case 'general':
@@ -48,14 +45,22 @@ module.exports = React.createClass({
case 'feature': case 'feature':
result = ( result = (
<div> <div>
<FeatureTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <FeatureTab
team={this.state.team}
activeSection={this.props.activeSection}
updateSection={this.props.updateSection}
/>
</div> </div>
); );
break; break;
case 'import': case 'import':
result = ( result = (
<div> <div>
<ImportTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <ImportTab
team={this.state.team}
activeSection={this.props.activeSection}
updateSection={this.props.updateSection}
/>
</div> </div>
); );
break; break;
@@ -67,4 +72,16 @@ module.exports = React.createClass({
} }
return result; return result;
} }
}); }
TeamSettings.defaultProps = {
activeTab: '',
activeSection: '',
teamDisplayName: ''
};
TeamSettings.propTypes = {
activeTab: React.PropTypes.string.isRequired,
activeSection: React.PropTypes.string.isRequired,
updateSection: React.PropTypes.func.isRequired,
teamDisplayName: React.PropTypes.string.isRequired
};