Merge pull request #241 from rgarmsen2295/mm-1556
MM-1556 Better error handling of channel descriptions that are too large
Этот коммит содержится в:
@@ -6,17 +6,24 @@ var AsyncClient = require('../utils/async_client.jsx');
|
|||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
handleEdit: function(e) {
|
handleEdit: function(e) {
|
||||||
var data = {}
|
var data = {};
|
||||||
data["channel_id"] = this.state.channel_id;
|
data["channel_id"] = this.state.channel_id;
|
||||||
if (data["channel_id"].length !== 26) return;
|
if (data["channel_id"].length !== 26) return;
|
||||||
data["channel_description"] = this.state.description.trim();
|
data["channel_description"] = this.state.description.trim();
|
||||||
|
|
||||||
Client.updateChannelDesc(data,
|
Client.updateChannelDesc(data,
|
||||||
function(data) {
|
function(data) {
|
||||||
|
this.setState({ server_error: "" });
|
||||||
AsyncClient.getChannels(true);
|
AsyncClient.getChannels(true);
|
||||||
|
$(this.refs.modal.getDOMNode()).modal('hide');
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function(err) {
|
function(err) {
|
||||||
AsyncClient.dispatchError(err, "updateChannelDesc");
|
if (err.message === "Invalid channel_description parameter") {
|
||||||
|
this.setState({ server_error: "This description is too long, please enter a shorter one" });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.setState({ server_error: err.message });
|
||||||
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -27,13 +34,15 @@ module.exports = React.createClass({
|
|||||||
var self = this;
|
var self = this;
|
||||||
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
|
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
|
||||||
var button = e.relatedTarget;
|
var button = e.relatedTarget;
|
||||||
self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid') });
|
self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), server_error: "" });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return { description: "", title: "", channel_id: "" };
|
return { description: "", title: "", channel_id: "" };
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var server_error = this.state.server_error ? <div className='form-group has-error'><br/><label className='control-label'>{ this.state.server_error }</label></div> : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal fade" ref="modal" id="edit_channel" role="dialog" aria-hidden="true">
|
<div className="modal fade" ref="modal" id="edit_channel" role="dialog" aria-hidden="true">
|
||||||
<div className="modal-dialog">
|
<div className="modal-dialog">
|
||||||
@@ -44,10 +53,11 @@ module.exports = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<textarea className="form-control no-resize" rows="6" ref="channelDesc" maxLength="1024" value={this.state.description} onChange={this.handleUserInput}></textarea>
|
<textarea className="form-control no-resize" rows="6" ref="channelDesc" maxLength="1024" value={this.state.description} onChange={this.handleUserInput}></textarea>
|
||||||
|
{ server_error }
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
<button type="button" className="btn btn-primary" data-dismiss="modal" onClick={this.handleEdit}>Save</button>
|
<button type="button" className="btn btn-primary" onClick={this.handleEdit}>Save</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user