MozReview: Trigger an event on commit message file related action (Bug 1248008) r?smacleod draft
authorPiotr Zalewa <pzalewa@mozilla.com>
Wed, 14 Sep 2016 08:56:20 +0200
changeset 203 45a84be705a6b80239f9e762c49f9b35b3a406b4
parent 202 f6df9220709edbdc875f3ed559535464974e4a51
child 204 79e0a0912247a1eb4a51a68546b1902e242bfeda
push idunknown
push userunknown
push dateunknown
reviewerssmacleod
bugs1248008
MozReview: Trigger an event on commit message file related action (Bug 1248008) r?smacleod Two events are triggered on `RB::page`: mr:fileDiffRendered and mr:revisionSelected To modify the looks of commit message filediff DOM element front-end needs to react as soon as it's loaded from API and rendered to DOM. mr:fileDiffRendered is responsible for that. It also delivers filediff's ID to the listener so it can be compared with commit message one. Current commit message filediff ID is needed to compare it with the loaded one. There is a need to create an event when user switches revisions as different fildiff might be loaded. mr:selectedRevision is triggered. It provides two revisions (base and tip) as any of these might be used. MozReview-Commit-ID: 5TGxbZV54zS
reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
--- a/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
@@ -408,16 +408,18 @@ RB.DiffViewerPageView = RB.ReviewablePag
             }
 
             if ($anchor.length !== 0) {
                 this.selectAnchor($anchor);
                 this._startAtAnchorName = null;
             }
         }
 
+        // Emit a fileDiffRenderedEvent
+        this.trigger('mr:fileDiffRendered', diffReviewable.get('fileDiffID'));
         $.funcQueue('diff_files').next();
     },
 
     /*
      * Selects the anchor at a specified location.
      *
      * By default, this will scroll the page to position the anchor near
      * the top of the view.
@@ -672,16 +674,17 @@ RB.DiffViewerPageView = RB.ReviewablePag
         var base = revisions[0],
             tip = revisions[1];
 
         if (base === 0) {
             this.router.navigate(tip + '/', {trigger: true});
         } else {
             this.router.navigate(base + '-' + tip + '/', {trigger: true});
         }
+        this.trigger('mr:revisionSelected', revisions);
     },
 
     /*
      * Get the current URL.
      *
      * This will compute and return the current page's URL (relative to the
      * router root), not including query parameters or hash locations.
      */