Fix inconsistency when new team modal is beeing used to edit teams
This commit is contained in:
@@ -85,6 +85,20 @@ class NewTeamModal extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
getSaveButtonLabel() {
|
||||
if (this.props.editMode) {
|
||||
return 'Save';
|
||||
}
|
||||
return 'Add';
|
||||
}
|
||||
|
||||
getModalTitle() {
|
||||
if (this.props.editMode) {
|
||||
return 'Edit Server';
|
||||
}
|
||||
return 'Add Server';
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal
|
||||
@@ -107,7 +121,7 @@ class NewTeamModal extends React.Component {
|
||||
}}
|
||||
>
|
||||
<Modal.Header>
|
||||
<Modal.Title>{'Add Server'}</Modal.Title>
|
||||
<Modal.Title>{this.getModalTitle()}</Modal.Title>
|
||||
</Modal.Header>
|
||||
|
||||
<Modal.Body>
|
||||
@@ -159,7 +173,7 @@ class NewTeamModal extends React.Component {
|
||||
onClick={this.save.bind(this)}
|
||||
disabled={!this.validateForm()}
|
||||
bsStyle='primary'
|
||||
>{'Add'}</Button>
|
||||
>{this.getSaveButtonLabel()}</Button>
|
||||
</Modal.Footer>
|
||||
|
||||
</Modal>
|
||||
@@ -170,7 +184,8 @@ class NewTeamModal extends React.Component {
|
||||
NewTeamModal.propTypes = {
|
||||
onClose: React.PropTypes.func,
|
||||
onSave: React.PropTypes.func,
|
||||
team: React.PropTypes.object
|
||||
team: React.PropTypes.object,
|
||||
editMode: React.PropTypes.boolean
|
||||
};
|
||||
|
||||
module.exports = NewTeamModal;
|
||||
|
@@ -145,6 +145,11 @@ const SettingsPage = React.createClass({
|
||||
showAddTeamForm: !this.state.showAddTeamForm
|
||||
});
|
||||
},
|
||||
setShowTeamFormVisibility(val) {
|
||||
this.setState({
|
||||
showAddTeamForm: val
|
||||
});
|
||||
},
|
||||
handleFlashWindow() {
|
||||
this.setState({
|
||||
notifications: {
|
||||
@@ -182,6 +187,7 @@ const SettingsPage = React.createClass({
|
||||
teams={this.state.teams}
|
||||
showAddTeamForm={this.state.showAddTeamForm}
|
||||
toggleAddTeamForm={this.toggleShowTeamForm}
|
||||
setAddTeamFormVisibility={this.setShowTeamFormVisibility}
|
||||
onTeamsChange={this.handleTeamsChange}
|
||||
updateTeam={this.updateTeam}
|
||||
addServer={this.addServer}
|
||||
|
@@ -11,7 +11,8 @@ const TeamList = React.createClass({
|
||||
teams: React.PropTypes.array,
|
||||
addServer: React.PropTypes.func,
|
||||
updateTeam: React.PropTypes.func,
|
||||
toggleAddTeamForm: React.PropTypes.func
|
||||
toggleAddTeamForm: React.PropTypes.func,
|
||||
setAddTeamFormVisibility: React.PropTypes.func
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
@@ -99,16 +100,17 @@ const TeamList = React.createClass({
|
||||
if (this.props.showAddTeamForm || this.state.showEditTeamForm) {
|
||||
addServerForm = (
|
||||
<NewTeamModal
|
||||
editMode={this.state.showEditTeamForm}
|
||||
onClose={() => {
|
||||
this.setState({
|
||||
showNewTeamModal: false,
|
||||
showEditTeamForm: false,
|
||||
team: {
|
||||
name: '',
|
||||
url: '',
|
||||
index: false
|
||||
}
|
||||
});
|
||||
this.props.toggleAddTeamForm();
|
||||
this.props.setAddTeamFormVisibility(false);
|
||||
}}
|
||||
onSave={(newTeam) => {
|
||||
var teamData = {
|
||||
@@ -130,8 +132,7 @@ const TeamList = React.createClass({
|
||||
}
|
||||
});
|
||||
this.render();
|
||||
|
||||
this.props.onTeamsChange(this.props.teams);
|
||||
this.props.setAddTeamFormVisibility(false);
|
||||
}}
|
||||
team={this.state.team}
|
||||
/>);
|
||||
|
Reference in New Issue
Block a user