Merge pull request #226 from nickago/MM-1546

MM-1546 Clear error messages on modal close and channel switch
Этот коммит содержится в:
Joram Wilander
2015-07-24 11:40:42 -04:00
родитель b813234f4c dbbe40e893
Коммит 4f9c40e60b
5 изменённых файлов: 64 добавлений и 5 удалений

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

@@ -275,7 +275,7 @@ module.exports = React.createClass({
messageText = draft['message'];
uploadsInProgress = draft['uploadsInProgress'];
}
this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress });
this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, limit_error: null, server_error: null, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress });
}
},
_onActiveThreadChanged: function(rootId, parentId) {

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

@@ -30,12 +30,19 @@ module.exports = React.createClass({
handleUserInput: function(e) {
this.setState({ description: e.target.value });
},
handleClose: function() {
this.setState({description: "", server_error: ""});
},
componentDidMount: function() {
var self = this;
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
var button = e.relatedTarget;
self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), server_error: "" });
});
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', this.handleClose)
},
componentWillUnmount: function() {
$(this.refs.modal.getDOMNode()).off('hidden.bs.modal', this.handleClose)
},
getInitialState: function() {
return { description: "", title: "", channel_id: "" };

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

@@ -89,12 +89,19 @@ module.exports = React.createClass({
this.refs.channel_name.getDOMNode().value = channel_name;
this.setState({ channel_name: channel_name })
},
handleClose: function() {
this.setState({display_name: "", channel_name: "", display_name_error: "", server_error: "", name_error: ""});
},
componentDidMount: function() {
var self = this;
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
self.setState({ display_name: button.attr('data-display'), title: button.attr('data-name'), channel_id: button.attr('data-channelid') });
});
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', this.handleClose);
},
componentWillUnmount: function() {
$(this.refs.modal.getDOMNode()).off('hidden.bs.modal', this.handleClose);
},
getInitialState: function() {
return { display_name: "", channel_name: "", channel_id: "" };

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

@@ -44,11 +44,14 @@ module.exports = React.createClass({
onNameChange: function() {
this.setState({ name: this.refs.name.getDOMNode().value })
},
handleClose: function() {
this.setState({ name: this.props.teamDisplayName, name_error: "", server_error: ""});
},
componentDidMount: function() {
var self = this;
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) {
self.setState({ name: self.props.teamDisplayName });
});
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', this.handleClose);
},
componentWillUnmount: function() {
$(this.refs.modal.getDOMNode()).off('hidden.bs.modal', this.handleClose);
},
getInitialState: function() {
return { name: this.props.teamDisplayName };

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

@@ -11,6 +11,7 @@ var client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var utils = require('../utils/utils.jsx');
var Constants = require('../utils/constants.jsx');
var assign = require('object-assign');
function getNotificationsStateFromStores() {
var user = UserStore.getCurrentUser();
@@ -95,11 +96,20 @@ var NotificationsTab = React.createClass({
}.bind(this)
);
},
handleClose: function() {
$(this.getDOMNode()).find(".form-control").each(function() {
this.value = "";
});
this.setState(assign({},getNotificationsStateFromStores(),{server_error: null}));
},
componentDidMount: function() {
UserStore.addChangeListener(this._onChange);
$('#user_settings1').on('hidden.bs.modal', this.handleClose);
},
componentWillUnmount: function() {
UserStore.removeChangeListener(this._onChange);
$('#user_settings1').off('hidden.bs.modal', this.handleClose);
},
_onChange: function() {
var newState = getNotificationsStateFromStores();
@@ -502,6 +512,18 @@ var SecurityTab = React.createClass({
handleDevicesOpen: function() {
$("#user_settings1").modal('hide');
},
handleClose: function() {
$(this.getDOMNode()).find(".form-control").each(function() {
this.value = "";
});
this.setState({current_password: '', new_password: '', confirm_password: '', server_error: null, password_error: null});
},
componentDidMount: function() {
$('#user_settings1').on('hidden.bs.modal', this.handleClose);
},
componentWillUnmount: function() {
$('#user_settings1').off('hidden.bs.modal', this.handleClose);
},
getInitialState: function() {
return { current_password: '', new_password: '', confirm_password: '' };
},
@@ -751,6 +773,19 @@ var GeneralTab = React.createClass({
this.submitActive = false
this.props.updateSection(section);
},
handleClose: function() {
$(this.getDOMNode()).find(".form-control").each(function() {
this.value = "";
});
this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null}));
},
componentDidMount: function() {
$('#user_settings1').on('hidden.bs.modal', this.handleClose);
},
componentWillUnmount: function() {
$('#user_settings1').off('hidden.bs.modal', this.handleClose);
},
getInitialState: function() {
var user = this.props.user;
@@ -994,10 +1029,14 @@ var AppearanceTab = React.createClass({
var hex = utils.rgb2hex(e.target.style.backgroundColor);
this.setState({ theme: hex.toLowerCase() });
},
handleClose: function() {
this.setState({server_error: null});
},
componentDidMount: function() {
if (this.props.activeSection === "theme") {
$(this.refs[this.state.theme].getDOMNode()).addClass('active-border');
}
$('#user_settings1').on('hidden.bs.modal', this.handleClose);
},
componentDidUpdate: function() {
if (this.props.activeSection === "theme") {
@@ -1005,6 +1044,9 @@ var AppearanceTab = React.createClass({
$(this.refs[this.state.theme].getDOMNode()).addClass('active-border');
}
},
componentWillUnmount: function() {
$('#user_settings1').off('hidden.bs.modal', this.handleClose);
},
getInitialState: function() {
var user = UserStore.getCurrentUser();
var theme = config.ThemeColors != null ? config.ThemeColors[0] : "#2389d7";