Merge pull request #570 from rgarmsen2295/fix-initial-state-calls
Refactor remaining uses of getInitialState and componentWillMount
Этот коммит содержится в:
@@ -14,15 +14,9 @@ export default class FeatureTab extends React.Component {
|
|||||||
this.submitValetFeature = this.submitValetFeature.bind(this);
|
this.submitValetFeature = this.submitValetFeature.bind(this);
|
||||||
this.handleValetRadio = this.handleValetRadio.bind(this);
|
this.handleValetRadio = this.handleValetRadio.bind(this);
|
||||||
this.onUpdateSection = this.onUpdateSection.bind(this);
|
this.onUpdateSection = this.onUpdateSection.bind(this);
|
||||||
|
this.setupInitialState = this.setupInitialState.bind(this);
|
||||||
|
|
||||||
this.state = {};
|
this.state = this.setupInitialState();
|
||||||
var team = this.props.team;
|
|
||||||
|
|
||||||
if (team && team.allow_valet) {
|
|
||||||
this.state.allowValet = 'true';
|
|
||||||
} else {
|
|
||||||
this.state.allowValet = 'false';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
componentWillReceiveProps(newProps) {
|
componentWillReceiveProps(newProps) {
|
||||||
var team = newProps.team;
|
var team = newProps.team;
|
||||||
@@ -44,7 +38,7 @@ export default class FeatureTab extends React.Component {
|
|||||||
AsyncClient.getMyTeam();
|
AsyncClient.getMyTeam();
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function fail(err) {
|
function fail(err) {
|
||||||
var state = this.getInitialState();
|
var state = this.setupInitialState();
|
||||||
state.serverError = err;
|
state.serverError = err;
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
@@ -62,6 +56,18 @@ export default class FeatureTab extends React.Component {
|
|||||||
this.props.updateSection('valet');
|
this.props.updateSection('valet');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setupInitialState() {
|
||||||
|
var allowValet;
|
||||||
|
var team = this.props.team;
|
||||||
|
|
||||||
|
if (team && team.allow_valet) {
|
||||||
|
allowValet = 'true';
|
||||||
|
} else {
|
||||||
|
allowValet = 'false';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {allowValet: allowValet};
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
var clientError = null;
|
var clientError = null;
|
||||||
var serverError = null;
|
var serverError = null;
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ export default class TeamSignupSendInvitesPage extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
emailEnabled: !ConfigStore.getSettingAsBoolean('ByPassEmail', false)
|
emailEnabled: !ConfigStore.getSettingAsBoolean('ByPassEmail', false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!this.state.emailEnabled) {
|
||||||
|
this.props.state.wizard = 'username';
|
||||||
|
this.props.updateParent(this.props.state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
submitBack(e) {
|
submitBack(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -75,12 +80,6 @@ export default class TeamSignupSendInvitesPage extends React.Component {
|
|||||||
this.submitNext(e);
|
this.submitNext(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillMount() {
|
|
||||||
if (!this.state.emailEnabled) {
|
|
||||||
this.props.state.wizard = 'username';
|
|
||||||
this.props.updateParent(this.props.state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (!this.state.emailEnabled) {
|
if (!this.state.emailEnabled) {
|
||||||
// Must use keypress not keyup due to event chain of pressing enter
|
// Must use keypress not keyup due to event chain of pressing enter
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export default class TeamSignupWelcomePage extends React.Component {
|
|||||||
this.handleKeyPress = this.handleKeyPress.bind(this);
|
this.handleKeyPress = this.handleKeyPress.bind(this);
|
||||||
|
|
||||||
this.state = {useDiff: false};
|
this.state = {useDiff: false};
|
||||||
|
|
||||||
|
document.addEventListener('keyup', this.handleKeyPress, false);
|
||||||
}
|
}
|
||||||
submitNext(e) {
|
submitNext(e) {
|
||||||
if (!BrowserStore.isLocalStorageSupported()) {
|
if (!BrowserStore.isLocalStorageSupported()) {
|
||||||
@@ -68,9 +70,6 @@ export default class TeamSignupWelcomePage extends React.Component {
|
|||||||
this.submitNext(event);
|
this.submitNext(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillMount() {
|
|
||||||
document.addEventListener('keyup', this.handleKeyPress, false);
|
|
||||||
}
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
document.removeEventListener('keyup', this.handleKeyPress, false);
|
document.removeEventListener('keyup', this.handleKeyPress, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export default class NotificationsTab extends React.Component {
|
|||||||
this.props.updateTab('general');
|
this.props.updateTab('general');
|
||||||
}
|
}
|
||||||
updateSection(section) {
|
updateSection(section) {
|
||||||
this.setState(this.getInitialState());
|
this.setState(getNotificationsStateFromStores());
|
||||||
this.props.updateSection(section);
|
this.props.updateSection(section);
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ export default class SecurityTab extends React.Component {
|
|||||||
this.updateNewPassword = this.updateNewPassword.bind(this);
|
this.updateNewPassword = this.updateNewPassword.bind(this);
|
||||||
this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
|
this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
|
||||||
this.handleClose = this.handleClose.bind(this);
|
this.handleClose = this.handleClose.bind(this);
|
||||||
|
this.setupInitialState = this.setupInitialState.bind(this);
|
||||||
|
|
||||||
this.state = {currentPassword: '', newPassword: '', confirmPassword: ''};
|
this.state = this.setupInitialState();
|
||||||
}
|
}
|
||||||
submitPassword(e) {
|
submitPassword(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -51,10 +52,10 @@ export default class SecurityTab extends React.Component {
|
|||||||
function success() {
|
function success() {
|
||||||
this.props.updateSection('');
|
this.props.updateSection('');
|
||||||
AsyncClient.getMe();
|
AsyncClient.getMe();
|
||||||
this.setState({currentPassword: '', newPassword: '', confirmPassword: ''});
|
this.setState(this.setupInitialState());
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function fail(err) {
|
function fail(err) {
|
||||||
var state = this.getInitialState();
|
var state = this.setupInitialState();
|
||||||
if (err.message) {
|
if (err.message) {
|
||||||
state.serverError = err.message;
|
state.serverError = err.message;
|
||||||
} else {
|
} else {
|
||||||
@@ -88,6 +89,9 @@ export default class SecurityTab extends React.Component {
|
|||||||
|
|
||||||
this.props.updateTab('general');
|
this.props.updateTab('general');
|
||||||
}
|
}
|
||||||
|
setupInitialState() {
|
||||||
|
return {currentPassword: '', newPassword: '', confirmPassword: ''};
|
||||||
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
$('#user_settings').on('hidden.bs.modal', this.handleClose);
|
$('#user_settings').on('hidden.bs.modal', this.handleClose);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user