Bug 1483497 - Rename connect/disconnect actions to watch/unwatch;r=daisuke,ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 06 Sep 2018 11:06:52 +0200
changeset 485004 4b2013edb3c836aca2395e8d2e44e80cdbc66d86
parent 485003 4538d62973ac999a225034849c311913d042fa9b
child 485005 0d62d337ff34f1ef8d21c85722d4272ac302ad2f
push id241
push userfmarier@mozilla.com
push dateMon, 24 Sep 2018 21:48:02 +0000
reviewersdaisuke, ladybenko
bugs1483497
milestone64.0a1
Bug 1483497 - Rename connect/disconnect actions to watch/unwatch;r=daisuke,ladybenko
devtools/client/aboutdebugging-new/aboutdebugging.js
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/actions/ui.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
devtools/client/aboutdebugging-new/src/reducers/debug-targets-state.js
devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
--- a/devtools/client/aboutdebugging-new/aboutdebugging.js
+++ b/devtools/client/aboutdebugging-new/aboutdebugging.js
@@ -89,20 +89,20 @@ const AboutDebugging = {
   },
 
   onNetworkLocationsUpdated() {
     this.actions.updateNetworkLocations(getNetworkLocations());
   },
 
   async destroy() {
     L10nRegistry.removeSource("aboutdebugging");
-    // Call removeNetworkLocationsObserver before disconnectRuntime,
+    // Call removeNetworkLocationsObserver before unwatchRuntime,
     // follow up in Bug 1490950.
     removeNetworkLocationsObserver(this.onNetworkLocationsUpdated);
-    await this.actions.disconnectRuntime();
+    await this.actions.unwatchRuntime();
     setDebugTargetCollapsibilities(this.store.getState().ui.debugTargetCollapsibilities);
     unmountComponentAtNode(this.mount);
   },
 
   get mount() {
     return document.getElementById("mount");
   },
 };
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -9,58 +9,58 @@ const { DebuggerServer } = require("devt
 
 const Actions = require("./index");
 
 const {
   getCurrentClient
 } = require("devtools/client/aboutdebugging-new/src/modules/runtimes-state-helper");
 
 const {
-  CONNECT_RUNTIME_FAILURE,
-  CONNECT_RUNTIME_START,
-  CONNECT_RUNTIME_SUCCESS,
-  DISCONNECT_RUNTIME_FAILURE,
-  DISCONNECT_RUNTIME_START,
-  DISCONNECT_RUNTIME_SUCCESS,
+  UNWATCH_RUNTIME_FAILURE,
+  UNWATCH_RUNTIME_START,
+  UNWATCH_RUNTIME_SUCCESS,
+  WATCH_RUNTIME_FAILURE,
+  WATCH_RUNTIME_START,
+  WATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 
-function connectRuntime() {
+function watchRuntime() {
   return async (dispatch, getState) => {
-    dispatch({ type: CONNECT_RUNTIME_START });
+    dispatch({ type: WATCH_RUNTIME_START });
 
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     const client = new DebuggerClient(DebuggerServer.connectPipe());
 
     try {
       await client.connect();
 
-      dispatch({ type: CONNECT_RUNTIME_SUCCESS, client });
+      dispatch({ type: WATCH_RUNTIME_SUCCESS, client });
       dispatch(Actions.requestExtensions());
       dispatch(Actions.requestTabs());
       dispatch(Actions.requestWorkers());
     } catch (e) {
-      dispatch({ type: CONNECT_RUNTIME_FAILURE, error: e.message });
+      dispatch({ type: WATCH_RUNTIME_FAILURE, error: e.message });
     }
   };
 }
 
-function disconnectRuntime() {
+function unwatchRuntime() {
   return async (dispatch, getState) => {
     const client = getCurrentClient(getState());
 
-    dispatch({ type: DISCONNECT_RUNTIME_START, client });
+    dispatch({ type: UNWATCH_RUNTIME_START, client });
 
     try {
       await client.close();
       DebuggerServer.destroy();
 
-      dispatch({ type: DISCONNECT_RUNTIME_SUCCESS });
+      dispatch({ type: UNWATCH_RUNTIME_SUCCESS });
     } catch (e) {
-      dispatch({ type: DISCONNECT_RUNTIME_FAILURE, error: e.message });
+      dispatch({ type: UNWATCH_RUNTIME_FAILURE, error: e.message });
     }
   };
 }
 
 module.exports = {
-  connectRuntime,
-  disconnectRuntime,
+  watchRuntime,
+  unwatchRuntime,
 };
--- a/devtools/client/aboutdebugging-new/src/actions/ui.js
+++ b/devtools/client/aboutdebugging-new/src/actions/ui.js
@@ -19,19 +19,19 @@ function selectPage(page) {
   return async (dispatch, getState) => {
     const currentPage = getState().ui.selectedPage;
     if (page === currentPage) {
       // Nothing to dispatch if the page is the same as the current page.
       return;
     }
 
     if (page === PAGES.THIS_FIREFOX) {
-      await dispatch(Actions.connectRuntime());
+      await dispatch(Actions.watchRuntime());
     } else {
-      await dispatch(Actions.disconnectRuntime());
+      await dispatch(Actions.unwatchRuntime());
     }
 
     dispatch({ type: PAGE_SELECTED, page });
   };
 }
 
 function updateDebugTargetCollapsibility(key, isCollapsed) {
   return { type: DEBUG_TARGET_COLLAPSIBILITY_UPDATED, key, isCollapsed };
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ b/devtools/client/aboutdebugging-new/src/constants.js
@@ -1,33 +1,33 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const actionTypes = {
-  CONNECT_RUNTIME_FAILURE: "CONNECT_RUNTIME_FAILURE",
-  CONNECT_RUNTIME_START: "CONNECT_RUNTIME_START",
-  CONNECT_RUNTIME_SUCCESS: "CONNECT_RUNTIME_SUCCESS",
   DEBUG_TARGET_COLLAPSIBILITY_UPDATED: "DEBUG_TARGET_COLLAPSIBILITY_UPDATED",
-  DISCONNECT_RUNTIME_FAILURE: "DISCONNECT_RUNTIME_FAILURE",
-  DISCONNECT_RUNTIME_START: "DISCONNECT_RUNTIME_START",
-  DISCONNECT_RUNTIME_SUCCESS: "DISCONNECT_RUNTIME_SUCCESS",
   NETWORK_LOCATIONS_UPDATED: "NETWORK_LOCATIONS_UPDATED",
   PAGE_SELECTED: "PAGE_SELECTED",
   REQUEST_EXTENSIONS_FAILURE: "REQUEST_EXTENSIONS_FAILURE",
   REQUEST_EXTENSIONS_START: "REQUEST_EXTENSIONS_START",
   REQUEST_EXTENSIONS_SUCCESS: "REQUEST_EXTENSIONS_SUCCESS",
   REQUEST_TABS_FAILURE: "REQUEST_TABS_FAILURE",
   REQUEST_TABS_START: "REQUEST_TABS_START",
   REQUEST_TABS_SUCCESS: "REQUEST_TABS_SUCCESS",
   REQUEST_WORKERS_FAILURE: "REQUEST_WORKERS_FAILURE",
   REQUEST_WORKERS_START: "REQUEST_WORKERS_START",
   REQUEST_WORKERS_SUCCESS: "REQUEST_WORKERS_SUCCESS",
+  UNWATCH_RUNTIME_FAILURE: "UNWATCH_RUNTIME_FAILURE",
+  UNWATCH_RUNTIME_START: "UNWATCH_RUNTIME_START",
+  UNWATCH_RUNTIME_SUCCESS: "UNWATCH_RUNTIME_SUCCESS",
+  WATCH_RUNTIME_FAILURE: "WATCH_RUNTIME_FAILURE",
+  WATCH_RUNTIME_START: "WATCH_RUNTIME_START",
+  WATCH_RUNTIME_SUCCESS: "WATCH_RUNTIME_SUCCESS",
 };
 
 const DEBUG_TARGETS = {
   EXTENSION: "EXTENSION",
   TAB: "TAB",
   WORKER: "WORKER",
 };
 
--- a/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
+++ b/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
@@ -2,18 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
 
 const {
-  CONNECT_RUNTIME_SUCCESS,
-  DISCONNECT_RUNTIME_START,
+  UNWATCH_RUNTIME_START,
+  WATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 const Actions = require("../actions/index");
 
 function debugTargetListenerMiddleware(store) {
   const onExtensionsUpdated = () => {
     store.dispatch(Actions.requestExtensions());
   };
 
@@ -48,28 +48,28 @@ function debugTargetListenerMiddleware(s
   };
 
   const onWorkersUpdated = () => {
     store.dispatch(Actions.requestWorkers());
   };
 
   return next => action => {
     switch (action.type) {
-      case CONNECT_RUNTIME_SUCCESS: {
+      case WATCH_RUNTIME_SUCCESS: {
         const { client } = action;
         client.addListener("tabListChanged", onTabsUpdated);
         AddonManager.addAddonListener(extensionsListener);
         client.addListener("workerListChanged", onWorkersUpdated);
         client.addListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
         client.addListener("processListChanged", onWorkersUpdated);
         client.addListener("registration-changed", onWorkersUpdated);
         client.addListener("push-subscription-modified", onWorkersUpdated);
         break;
       }
-      case DISCONNECT_RUNTIME_START: {
+      case UNWATCH_RUNTIME_START: {
         const { client } = action;
         client.removeListener("tabListChanged", onTabsUpdated);
         AddonManager.removeAddonListener(extensionsListener);
         client.removeListener("workerListChanged", onWorkersUpdated);
         client.removeListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
         client.removeListener("processListChanged", onWorkersUpdated);
         client.removeListener("registration-changed", onWorkersUpdated);
         client.removeListener("push-subscription-modified", onWorkersUpdated);
--- a/devtools/client/aboutdebugging-new/src/reducers/debug-targets-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/debug-targets-state.js
@@ -1,35 +1,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {
-  DISCONNECT_RUNTIME_SUCCESS,
   REQUEST_EXTENSIONS_SUCCESS,
   REQUEST_TABS_SUCCESS,
   REQUEST_WORKERS_SUCCESS,
+  UNWATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 
 function DebugTargetsState() {
   return {
     installedExtensions: [],
     otherWorkers: [],
     serviceWorkers: [],
     sharedWorkers: [],
     tabs: [],
     temporaryExtensions: [],
   };
 }
 
 function debugTargetsReducer(state = DebugTargetsState(), action) {
   switch (action.type) {
-    case DISCONNECT_RUNTIME_SUCCESS: {
+    case UNWATCH_RUNTIME_SUCCESS: {
       return DebugTargetsState();
     }
     case REQUEST_EXTENSIONS_SUCCESS: {
       const { installedExtensions, temporaryExtensions } = action;
       return Object.assign({}, state, { installedExtensions, temporaryExtensions });
     }
     case REQUEST_TABS_SUCCESS: {
       const { tabs } = action;
--- a/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
@@ -1,44 +1,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {
-  CONNECT_RUNTIME_SUCCESS,
-  DISCONNECT_RUNTIME_SUCCESS,
   NETWORK_LOCATIONS_UPDATED,
   RUNTIMES,
+  WATCH_RUNTIME_SUCCESS,
+  UNWATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 
 function RuntimesState(networkRuntimes = []) {
   return {
     networkRuntimes,
     thisFirefoxRuntimes: [{
       id: RUNTIMES.THIS_FIREFOX,
       type: RUNTIMES.THIS_FIREFOX,
     }]
   };
 }
 
 function runtimesReducer(state = RuntimesState(), action) {
   switch (action.type) {
-    case CONNECT_RUNTIME_SUCCESS: {
+    case WATCH_RUNTIME_SUCCESS: {
       const { client } = action;
       const thisFirefoxRuntimes = [{
         id: RUNTIMES.THIS_FIREFOX,
         type: RUNTIMES.THIS_FIREFOX,
         client,
       }];
       return Object.assign({}, state, { thisFirefoxRuntimes });
     }
 
-    case DISCONNECT_RUNTIME_SUCCESS: {
+    case UNWATCH_RUNTIME_SUCCESS: {
       const thisFirefoxRuntimes = [{
         id: RUNTIMES.THIS_FIREFOX,
         type: RUNTIMES.THIS_FIREFOX
       }];
       return Object.assign({}, state, { thisFirefoxRuntimes });
     }
 
     case NETWORK_LOCATIONS_UPDATED: {