Bug 1088672 - Part 5. Rewrite Loop's incoming call handling in the flux style. Correct the Call failed view to show only what's needed for incoming calls. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Thu, 12 Mar 2015 14:01:38 +0000
changeset 233231 a009386fbb96577f6db09c5aac248908d7dc2c4b
parent 233230 132acc4464e6ca66a36ffc3c8dadd28dad94d987
child 233232 ea81bbb5d288cf80edb126c6d75a45f4b19fa53c
push id11728
push usermbanner@mozilla.com
push dateThu, 12 Mar 2015 14:02:24 +0000
treeherderfx-team@c154c877d4e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1088672
milestone39.0a1
Bug 1088672 - Part 5. Rewrite Loop's incoming call handling in the flux style. Correct the Call failed view to show only what's needed for incoming calls. r=mikedeboer
browser/components/loop/content/js/conversationViews.js
browser/components/loop/content/js/conversationViews.jsx
--- a/browser/components/loop/content/js/conversationViews.js
+++ b/browser/components/loop/content/js/conversationViews.js
@@ -741,16 +741,17 @@ loop.conversationViews = (function(mozL1
       sharedMixins.WindowCloseMixin
     ],
 
     propTypes: {
       dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
       contact: React.PropTypes.object.isRequired,
       // This is used by the UI showcase.
       emailLinkError: React.PropTypes.bool,
+      outgoing: React.PropTypes.bool.isRequired
     },
 
     getInitialState: function() {
       return {
         emailLinkError: this.props.emailLinkError,
         emailLinkButtonDisabled: false
       };
     },
@@ -822,35 +823,57 @@ loop.conversationViews = (function(mozL1
       });
 
       this.props.dispatcher.dispatch(new sharedActions.FetchRoomEmailLink({
         roomOwner: navigator.mozLoop.userProfile.email,
         roomName: _getContactDisplayName(this.props.contact)
       }));
     },
 
+    _renderMessage: function() {
+      if (this.props.outgoing) {
+        return  (React.createElement("p", {className: "btn-label"}, mozL10n.get("generic_failure_with_reason2")));
+      }
+
+      return null;
+    },
+
     render: function() {
+      var cx = React.addons.classSet;
+
+      var retryClasses = cx({
+        btn: true,
+        "btn-info": true,
+        "btn-retry": true,
+        hide: !this.props.outgoing
+      });
+      var emailClasses = cx({
+        btn: true,
+        "btn-info": true,
+        "btn-email": true,
+        hide: !this.props.outgoing
+      });
+
       return (
         React.createElement("div", {className: "call-window"}, 
           React.createElement("h2", null,  this._getTitleMessage() ), 
 
-          React.createElement("p", {className: "btn-label"}, mozL10n.get("generic_failure_with_reason2")), 
-
+          this._renderMessage(), 
           this._renderError(), 
 
           React.createElement("div", {className: "btn-group call-action-group"}, 
             React.createElement("button", {className: "btn btn-cancel", 
                     onClick: this.cancelCall}, 
               mozL10n.get("cancel_button")
             ), 
-            React.createElement("button", {className: "btn btn-info btn-retry", 
+            React.createElement("button", {className: retryClasses, 
                     onClick: this.retryCall}, 
               mozL10n.get("retry_call_button")
             ), 
-            React.createElement("button", {className: "btn btn-info btn-email", 
+            React.createElement("button", {className: emailClasses, 
                     onClick: this.emailLink, 
                     disabled: this.state.emailLinkButtonDisabled}, 
               mozL10n.get("share_button2")
             )
           )
         )
       );
     }
@@ -1013,17 +1036,18 @@ loop.conversationViews = (function(mozL1
       switch (this.state.callState) {
         case CALL_STATES.CLOSE: {
           this._closeWindow();
           return null;
         }
         case CALL_STATES.TERMINATED: {
           return (React.createElement(CallFailedView, {
             dispatcher: this.props.dispatcher, 
-            contact: this.state.contact}
+            contact: this.state.contact, 
+            outgoing: this.state.outgoing}
           ));
         }
         case CALL_STATES.ONGOING: {
           return (React.createElement(OngoingConversationView, {
             dispatcher: this.props.dispatcher, 
             video: {enabled: !this.state.videoMuted}, 
             audio: {enabled: !this.state.audioMuted}}
             )
--- a/browser/components/loop/content/js/conversationViews.jsx
+++ b/browser/components/loop/content/js/conversationViews.jsx
@@ -741,16 +741,17 @@ loop.conversationViews = (function(mozL1
       sharedMixins.WindowCloseMixin
     ],
 
     propTypes: {
       dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
       contact: React.PropTypes.object.isRequired,
       // This is used by the UI showcase.
       emailLinkError: React.PropTypes.bool,
+      outgoing: React.PropTypes.bool.isRequired
     },
 
     getInitialState: function() {
       return {
         emailLinkError: this.props.emailLinkError,
         emailLinkButtonDisabled: false
       };
     },
@@ -822,35 +823,57 @@ loop.conversationViews = (function(mozL1
       });
 
       this.props.dispatcher.dispatch(new sharedActions.FetchRoomEmailLink({
         roomOwner: navigator.mozLoop.userProfile.email,
         roomName: _getContactDisplayName(this.props.contact)
       }));
     },
 
+    _renderMessage: function() {
+      if (this.props.outgoing) {
+        return  (<p className="btn-label">{mozL10n.get("generic_failure_with_reason2")}</p>);
+      }
+
+      return null;
+    },
+
     render: function() {
+      var cx = React.addons.classSet;
+
+      var retryClasses = cx({
+        btn: true,
+        "btn-info": true,
+        "btn-retry": true,
+        hide: !this.props.outgoing
+      });
+      var emailClasses = cx({
+        btn: true,
+        "btn-info": true,
+        "btn-email": true,
+        hide: !this.props.outgoing
+      });
+
       return (
         <div className="call-window">
           <h2>{ this._getTitleMessage() }</h2>
 
-          <p className="btn-label">{mozL10n.get("generic_failure_with_reason2")}</p>
-
+          {this._renderMessage()}
           {this._renderError()}
 
           <div className="btn-group call-action-group">
             <button className="btn btn-cancel"
                     onClick={this.cancelCall}>
               {mozL10n.get("cancel_button")}
             </button>
-            <button className="btn btn-info btn-retry"
+            <button className={retryClasses}
                     onClick={this.retryCall}>
               {mozL10n.get("retry_call_button")}
             </button>
-            <button className="btn btn-info btn-email"
+            <button className={emailClasses}
                     onClick={this.emailLink}
                     disabled={this.state.emailLinkButtonDisabled}>
               {mozL10n.get("share_button2")}
             </button>
           </div>
         </div>
       );
     }
@@ -1014,16 +1037,17 @@ loop.conversationViews = (function(mozL1
         case CALL_STATES.CLOSE: {
           this._closeWindow();
           return null;
         }
         case CALL_STATES.TERMINATED: {
           return (<CallFailedView
             dispatcher={this.props.dispatcher}
             contact={this.state.contact}
+            outgoing={this.state.outgoing}
           />);
         }
         case CALL_STATES.ONGOING: {
           return (<OngoingConversationView
             dispatcher={this.props.dispatcher}
             video={{enabled: !this.state.videoMuted}}
             audio={{enabled: !this.state.audioMuted}}
             />