Bug 1554095 - Fix Block URL action. r=Honza a=jcristau
authortanhengyeow <E0032242@u.nus.edu>
Mon, 27 May 2019 06:47:10 +0000
changeset 536702 f6b2a8d526cdeff38133e8048d3d9a8796d46080
parent 536701 e8341f537323e62da5a165e1fd914367ff0576ec
child 536703 d2388f832a7d352a8e97b1474518521b1e3c6523
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, jcristau
bugs1554095
milestone68.0
Bug 1554095 - Fix Block URL action. r=Honza a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D32522
devtools/client/netmonitor/src/actions/requests.js
devtools/client/netmonitor/src/components/RequestListContent.js
devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
--- a/devtools/client/netmonitor/src/actions/requests.js
+++ b/devtools/client/netmonitor/src/actions/requests.js
@@ -103,41 +103,37 @@ function sendCustomRequest(connector, re
       });
     });
   };
 }
 
 /**
  * Tell the backend to block future requests that match the URL of the selected one.
  */
-function blockSelectedRequestURL(connector) {
-  return (dispatch, getState) => {
-    const selected = getSelectedRequest(getState());
-
-    if (!selected) {
+function blockSelectedRequestURL(connector, clickedRequest) {
+  return () => {
+    if (!clickedRequest) {
       return;
     }
 
-    const { url } = selected;
+    const { url } = clickedRequest;
     connector.blockRequest({ url });
   };
 }
 
 /**
  * Tell the backend to unblock future requests that match the URL of the selected one.
  */
-function unblockSelectedRequestURL(connector) {
-  return (dispatch, getState) => {
-    const selected = getSelectedRequest(getState());
-
-    if (!selected) {
+function unblockSelectedRequestURL(connector, clickedRequest) {
+  return () => {
+    if (!clickedRequest) {
       return;
     }
 
-    const { url } = selected;
+    const { url } = clickedRequest;
     connector.unblockRequest({ url });
   };
 }
 
 /**
  * Remove a request from the list. Supports removing only cloned requests with a
  * "isCustom" attribute. Other requests never need to be removed.
  */
--- a/devtools/client/netmonitor/src/components/RequestListContent.js
+++ b/devtools/client/netmonitor/src/components/RequestListContent.js
@@ -389,25 +389,25 @@ module.exports = connect(
     clickedRequest: state.requests.clickedRequest,
     displayedRequests: getDisplayedRequests(state),
     firstRequestStartedMillis: state.requests.firstStartedMillis,
     selectedRequest: getSelectedRequest(state),
     scale: getWaterfallScale(state),
     requestFilterTypes: state.filters.requestFilterTypes,
   }),
   (dispatch, props) => ({
-    blockSelectedRequestURL: () => {
-      dispatch(Actions.blockSelectedRequestURL(props.connector));
+    blockSelectedRequestURL: (clickedRequest) => {
+      dispatch(Actions.blockSelectedRequestURL(props.connector, clickedRequest));
     },
     cloneRequest: (id) => dispatch(Actions.cloneRequest(id)),
     openDetailsPanelTab: () => dispatch(Actions.openNetworkDetails(true)),
     sendCustomRequest: () => dispatch(Actions.sendCustomRequest(props.connector)),
     openStatistics: (open) => dispatch(Actions.openStatistics(props.connector, open)),
-    unblockSelectedRequestURL: () => {
-      dispatch(Actions.unblockSelectedRequestURL(props.connector));
+    unblockSelectedRequestURL: (clickedRequest) => {
+      dispatch(Actions.unblockSelectedRequestURL(props.connector, clickedRequest));
     },
     /**
      * A handler that opens the stack trace tab when a stack trace is available
      */
     onCauseBadgeMouseDown: (cause) => {
       if (cause.stacktrace && cause.stacktrace.length > 0) {
         dispatch(Actions.selectDetailsPanelTab("stack-trace"));
       }
--- a/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
+++ b/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
@@ -212,24 +212,28 @@ class RequestListContextMenu {
         });
       },
     });
 
     menu.push({
       id: "request-list-context-block-url",
       label: L10N.getStr("netmonitor.context.blockURL"),
       visible: !!(clickedRequest && !blockedReason),
-      click: blockSelectedRequestURL,
+      click: () => {
+        blockSelectedRequestURL(clickedRequest);
+      },
     });
 
     menu.push({
       id: "request-list-context-unblock-url",
       label: L10N.getStr("netmonitor.context.unblockURL"),
       visible: !!(clickedRequest && blockedReason),
-      click: unblockSelectedRequestURL,
+      click: () => {
+        unblockSelectedRequestURL(clickedRequest);
+      },
     });
 
     menu.push({
       type: "separator",
       visible: copySubmenu.slice(15, 16).some((subMenu) => subMenu.visible),
     });
 
     menu.push({