Animate NewTeamModal close
This commit is contained in:
parent
77472369c1
commit
63fe562349
|
@ -309,27 +309,25 @@ const MainPage = React.createClass({
|
||||||
authServerURL = `${tmpURL.protocol}//${tmpURL.host}`;
|
authServerURL = `${tmpURL.protocol}//${tmpURL.host}`;
|
||||||
authInfo = this.state.loginQueue[0].authInfo;
|
authInfo = this.state.loginQueue[0].authInfo;
|
||||||
}
|
}
|
||||||
var modal;
|
var modal = (
|
||||||
if (this.state.showNewTeamModal) {
|
<NewTeamModal
|
||||||
modal = (
|
show={this.state.showNewTeamModal}
|
||||||
<NewTeamModal
|
onClose={() => {
|
||||||
onClose={() => {
|
this.setState({
|
||||||
this.setState({
|
showNewTeamModal: false
|
||||||
showNewTeamModal: false
|
});
|
||||||
});
|
}}
|
||||||
}}
|
onSave={(newTeam) => {
|
||||||
onSave={(newTeam) => {
|
this.props.teams.push(newTeam);
|
||||||
this.props.teams.push(newTeam);
|
this.setState({
|
||||||
this.setState({
|
showNewTeamModal: false,
|
||||||
showNewTeamModal: false,
|
key: this.props.teams.length - 1
|
||||||
key: this.props.teams.length - 1
|
});
|
||||||
});
|
this.render();
|
||||||
this.render();
|
this.props.onTeamConfigChange(this.props.teams);
|
||||||
this.props.onTeamConfigChange(this.props.teams);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<LoginModal
|
<LoginModal
|
||||||
|
|
|
@ -3,9 +3,10 @@ const {Modal, Button, FormGroup, FormControl, ControlLabel, HelpBlock} = require
|
||||||
const validUrl = require('valid-url');
|
const validUrl = require('valid-url');
|
||||||
|
|
||||||
class NewTeamModal extends React.Component {
|
class NewTeamModal extends React.Component {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.wasShown = false;
|
||||||
this.state = {
|
this.state = {
|
||||||
teamName: '',
|
teamName: '',
|
||||||
teamUrl: '',
|
teamUrl: '',
|
||||||
|
@ -14,6 +15,10 @@ class NewTeamModal extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
this.initializeOnShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeOnShow() {
|
||||||
this.state = {
|
this.state = {
|
||||||
teamName: this.props.team ? this.props.team.name : '',
|
teamName: this.props.team ? this.props.team.name : '',
|
||||||
teamUrl: this.props.team ? this.props.team.url : '',
|
teamUrl: this.props.team ? this.props.team.url : '',
|
||||||
|
@ -105,9 +110,14 @@ class NewTeamModal extends React.Component {
|
||||||
'margin-bottom': 0
|
'margin-bottom': 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.wasShown !== this.props.show && this.props.show) {
|
||||||
|
this.initializeOnShow();
|
||||||
|
}
|
||||||
|
this.wasShown = this.props.show;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
show={true}
|
show={this.props.show}
|
||||||
id='newServerModal'
|
id='newServerModal'
|
||||||
onHide={this.props.onClose}
|
onHide={this.props.onClose}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
|
@ -193,7 +203,8 @@ NewTeamModal.propTypes = {
|
||||||
onClose: React.PropTypes.func,
|
onClose: React.PropTypes.func,
|
||||||
onSave: React.PropTypes.func,
|
onSave: React.PropTypes.func,
|
||||||
team: React.PropTypes.object,
|
team: React.PropTypes.object,
|
||||||
editMode: React.PropTypes.boolean
|
editMode: React.PropTypes.boolean,
|
||||||
|
show: React.PropTypes.boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = NewTeamModal;
|
module.exports = NewTeamModal;
|
||||||
|
|
|
@ -96,49 +96,45 @@ const TeamList = React.createClass({
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
var addServerForm;
|
var addServerForm = (
|
||||||
if (this.props.showAddTeamForm || this.state.showEditTeamForm) {
|
<NewTeamModal
|
||||||
addServerForm = (
|
show={this.props.showAddTeamForm || this.state.showEditTeamForm}
|
||||||
<NewTeamModal
|
editMode={this.state.showEditTeamForm}
|
||||||
editMode={this.state.showEditTeamForm}
|
onClose={() => {
|
||||||
onClose={() => {
|
this.setState({
|
||||||
this.setState({
|
showEditTeamForm: false,
|
||||||
showEditTeamForm: false,
|
team: {
|
||||||
team: {
|
name: '',
|
||||||
name: '',
|
url: '',
|
||||||
url: '',
|
index: false
|
||||||
index: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.props.setAddTeamFormVisibility(false);
|
|
||||||
}}
|
|
||||||
onSave={(newTeam) => {
|
|
||||||
var teamData = {
|
|
||||||
name: newTeam.name,
|
|
||||||
url: newTeam.url
|
|
||||||
};
|
|
||||||
if (this.props.showAddTeamForm) {
|
|
||||||
this.props.addServer(teamData);
|
|
||||||
} else {
|
|
||||||
this.props.updateTeam(newTeam.index, teamData);
|
|
||||||
}
|
}
|
||||||
this.setState({
|
});
|
||||||
showNewTeamModal: false,
|
this.props.setAddTeamFormVisibility(false);
|
||||||
showEditTeamForm: false,
|
}}
|
||||||
team: {
|
onSave={(newTeam) => {
|
||||||
name: '',
|
var teamData = {
|
||||||
url: '',
|
name: newTeam.name,
|
||||||
index: false
|
url: newTeam.url
|
||||||
}
|
};
|
||||||
});
|
if (this.props.showAddTeamForm) {
|
||||||
this.render();
|
this.props.addServer(teamData);
|
||||||
this.props.setAddTeamFormVisibility(false);
|
} else {
|
||||||
}}
|
this.props.updateTeam(newTeam.index, teamData);
|
||||||
team={this.state.team}
|
}
|
||||||
/>);
|
this.setState({
|
||||||
} else {
|
showNewTeamModal: false,
|
||||||
addServerForm = '';
|
showEditTeamForm: false,
|
||||||
}
|
team: {
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
index: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.render();
|
||||||
|
this.props.setAddTeamFormVisibility(false);
|
||||||
|
}}
|
||||||
|
team={this.state.team}
|
||||||
|
/>);
|
||||||
|
|
||||||
const removeServer = this.props.teams[this.state.indexToRemoveServer];
|
const removeServer = this.props.teams[this.state.indexToRemoveServer];
|
||||||
const removeServerModal = (
|
const removeServerModal = (
|
||||||
|
|
|
@ -261,6 +261,7 @@ describe('browser/settings.html', function desc() {
|
||||||
it('should close the window after clicking cancel', () => {
|
it('should close the window after clicking cancel', () => {
|
||||||
return this.app.client.
|
return this.app.client.
|
||||||
click('#cancelNewServerModal').
|
click('#cancelNewServerModal').
|
||||||
|
pause(1000). // Animation
|
||||||
isExisting('#newServerModal').should.eventually.equal(false);
|
isExisting('#newServerModal').should.eventually.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -334,15 +335,16 @@ describe('browser/settings.html', function desc() {
|
||||||
it('should add the team to the config file', (done) => {
|
it('should add the team to the config file', (done) => {
|
||||||
this.app.client.
|
this.app.client.
|
||||||
click('#saveNewServerModal').
|
click('#saveNewServerModal').
|
||||||
click('#btnSave');
|
pause(1000). // Animation
|
||||||
this.app.client.pause(1000).then(() => {
|
click('#btnSave').
|
||||||
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
pause(1000).then(() => {
|
||||||
savedConfig.teams.should.contain({
|
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||||
name: 'TestTeam',
|
savedConfig.teams.should.contain({
|
||||||
url: 'http://example.org'
|
name: 'TestTeam',
|
||||||
|
url: 'http://example.org'
|
||||||
|
});
|
||||||
|
return done();
|
||||||
});
|
});
|
||||||
return done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue