Reformatted team_settings.jsx to meet style guide requirements.

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

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

@@ -7,64 +7,81 @@ 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':
result = ( result = (
<div> <div>
<GeneralTab <GeneralTab
team={this.state.team} team={this.state.team}
activeSection={this.props.activeSection} activeSection={this.props.activeSection}
updateSection={this.props.updateSection} updateSection={this.props.updateSection}
teamDisplayName={this.props.teamDisplayName} teamDisplayName={this.props.teamDisplayName}
/> />
</div> </div>
); );
break; break;
case 'feature': case 'feature':
result = ( result = (
<div> <div>
<FeatureTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <FeatureTab
</div> team={this.state.team}
); activeSection={this.props.activeSection}
break; updateSection={this.props.updateSection}
case 'import': />
result = ( </div>
<div> );
<ImportTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> break;
</div> case 'import':
); result = (
break; <div>
default: <ImportTab
result = ( team={this.state.team}
<div/> activeSection={this.props.activeSection}
); updateSection={this.props.updateSection}
break; />
</div>
);
break;
default:
result = (
<div/>
);
break;
} }
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
};