Bug 1048162 Part 2 - Display an error message if fetching an email link fails r=standard8,darrin

This commit is contained in:
Nicolas Perriault
2014-10-16 21:29:18 -04:00
parent 8ed824d3fc
commit 286a6daebc
8 changed files with 114 additions and 22 deletions

View File

@@ -171,12 +171,10 @@ loop.conversationViews = (function(mozL10n) {
React.DOM.p({className: "btn-label"}, pendingStateString),
React.DOM.div({className: "btn-group call-action-group"},
React.DOM.div({className: "fx-embedded-call-button-spacer"}),
React.DOM.button({className: btnCancelStyles,
onClick: this.cancelCall},
mozL10n.get("initiate_call_cancel_button")
),
React.DOM.div({className: "fx-embedded-call-button-spacer"})
React.DOM.button({className: btnCancelStyles,
onClick: this.cancelCall},
mozL10n.get("initiate_call_cancel_button")
)
)
)
@@ -194,16 +192,23 @@ loop.conversationViews = (function(mozL10n) {
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
store: React.PropTypes.instanceOf(
loop.store.ConversationStore).isRequired,
contact: React.PropTypes.object.isRequired
contact: React.PropTypes.object.isRequired,
// This is used by the UI showcase.
emailLinkError: React.PropTypes.bool,
},
getInitialState: function() {
return {emailLinkButtonDisabled: false};
return {
emailLinkError: this.props.emailLinkError,
emailLinkButtonDisabled: false
};
},
componentDidMount: function() {
this.listenTo(this.props.store, "change:emailLink",
this._onEmailLinkReceived);
this.listenTo(this.props.store, "error:emailLink",
this._onEmailLinkError);
},
componentWillUnmount: function() {
@@ -217,6 +222,20 @@ loop.conversationViews = (function(mozL10n) {
window.close();
},
_onEmailLinkError: function() {
this.setState({
emailLinkError: true,
emailLinkButtonDisabled: false
});
},
_renderError: function() {
if (!this.state.emailLinkError) {
return;
}
return React.DOM.p({className: "error"}, mozL10n.get("unable_retrieve_url"));
},
retryCall: function() {
this.props.dispatcher.dispatch(new sharedActions.RetryCall());
},
@@ -226,7 +245,10 @@ loop.conversationViews = (function(mozL10n) {
},
emailLink: function() {
this.setState({emailLinkButtonDisabled: true});
this.setState({
emailLinkError: false,
emailLinkButtonDisabled: true
});
this.props.dispatcher.dispatch(new sharedActions.FetchEmailLink());
},
@@ -238,6 +260,8 @@ loop.conversationViews = (function(mozL10n) {
React.DOM.p({className: "btn-label"}, mozL10n.get("generic_failure_with_reason2")),
this._renderError(),
React.DOM.div({className: "btn-group call-action-group"},
React.DOM.button({className: "btn btn-cancel",
onClick: this.cancelCall},