Bug 1497944 - Hide wifi section in ConnectPage behind pref;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 24 Oct 2018 09:35:06 +0000
changeset 491118 6b8d7dcfe0e76208d6ddd3c79b94648d60ca95eb
parent 491117 399c3dbac7e2cb48a317268cf3593236fa826e64
child 491119 fc43dc9c58ef134764b0f21fea149438d14895ea
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdaisuke
bugs1497944
milestone65.0a1
Bug 1497944 - Hide wifi section in ConnectPage behind pref;r=daisuke Depends on D9222 . Differential Revision: https://phabricator.services.mozilla.com/D9223
devtools/client/aboutdebugging-new/src/components/App.js
devtools/client/aboutdebugging-new/src/components/connect/ConnectPage.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/create-store.js
devtools/client/aboutdebugging-new/src/reducers/ui-state.js
--- a/devtools/client/aboutdebugging-new/src/components/App.js
+++ b/devtools/client/aboutdebugging-new/src/components/App.js
@@ -28,40 +28,43 @@ class App extends PureComponent {
       // property to all components who need to dispatch actions.
       dispatch: PropTypes.func.isRequired,
       fluentBundles: PropTypes.arrayOf(PropTypes.object).isRequired,
       networkEnabled: PropTypes.bool.isRequired,
       networkLocations: PropTypes.arrayOf(PropTypes.string).isRequired,
       networkRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
       selectedPage: PropTypes.string,
       usbRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
+      wifiEnabled: PropTypes.bool.isRequired,
     };
   }
 
   getSelectedPageComponent() {
     const {
       adbAddonStatus,
       dispatch,
       networkEnabled,
       networkLocations,
       selectedPage,
+      wifiEnabled,
     } = this.props;
 
     if (!selectedPage) {
       // No page selected.
       return null;
     }
 
     switch (selectedPage) {
       case PAGES.CONNECT:
         return ConnectPage({
           adbAddonStatus,
           dispatch,
           networkEnabled,
           networkLocations,
+          wifiEnabled,
         });
       default:
         // All pages except for the CONNECT page are RUNTIME pages.
         return RuntimePage({ dispatch });
     }
   }
 
   render() {
@@ -100,16 +103,17 @@ class App extends PureComponent {
 const mapStateToProps = state => {
   return {
     adbAddonStatus: state.ui.adbAddonStatus,
     networkEnabled: state.ui.networkEnabled,
     networkLocations: state.ui.networkLocations,
     networkRuntimes: state.runtimes.networkRuntimes,
     selectedPage: state.ui.selectedPage,
     usbRuntimes: state.runtimes.usbRuntimes,
+    wifiEnabled: state.ui.wifiEnabled,
   };
 };
 
 const mapDispatchToProps = dispatch => ({
   dispatch,
 });
 
 module.exports = connect(mapStateToProps, mapDispatchToProps)(App);
--- a/devtools/client/aboutdebugging-new/src/components/connect/ConnectPage.js
+++ b/devtools/client/aboutdebugging-new/src/components/connect/ConnectPage.js
@@ -34,21 +34,26 @@ class ConnectPage extends PureComponent 
   static get propTypes() {
     return {
       adbAddonStatus: PropTypes.string,
       dispatch: PropTypes.func.isRequired,
       // Provided by wrapping the component with FluentReact.withLocalization.
       getString: PropTypes.func.isRequired,
       networkEnabled: PropTypes.bool.isRequired,
       networkLocations: PropTypes.arrayOf(PropTypes.string).isRequired,
+      wifiEnabled: PropTypes.bool.isRequired,
     };
   }
 
   renderWifi() {
-    const { getString } = this.props;
+    const { getString, wifiEnabled } = this.props;
+    if (!wifiEnabled) {
+      return null;
+    }
+
     return Localized(
       {
         id: "about-debugging-connect-wifi",
         attrs: { title: true },
       },
       ConnectSection(
         {
           icon: WIFI_ICON_SRC,
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ b/devtools/client/aboutdebugging-new/src/constants.js
@@ -60,16 +60,18 @@ const DEBUG_TARGET_PANE = {
 const PAGES = {
   THIS_FIREFOX: "this-firefox",
   CONNECT: "connect",
 };
 
 const PREFERENCES = {
   // Temporary preference without any default value until network locations are enabled.
   NETWORK_ENABLED: "devtools.aboutdebugging.network",
+  // Temporary preference without any default value until wifi is enabled.
+  WIFI_ENABLED: "devtools.aboutdebugging.wifi",
 };
 
 const RUNTIME_PREFERENCE = {
   CONNECTION_PROMPT: "devtools.debugger.prompt-connection",
 };
 
 const RUNTIMES = {
   NETWORK: "network",
--- a/devtools/client/aboutdebugging-new/src/create-store.js
+++ b/devtools/client/aboutdebugging-new/src/create-store.js
@@ -37,12 +37,13 @@ function configureStore() {
 
   return createStore(rootReducer, initialState, middleware);
 }
 
 function getUiState() {
   const collapsibilities = getDebugTargetCollapsibilities();
   const locations = getNetworkLocations();
   const networkEnabled = Services.prefs.getBoolPref(PREFERENCES.NETWORK_ENABLED, false);
-  return new UiState(locations, collapsibilities, networkEnabled);
+  const wifiEnabled = Services.prefs.getBoolPref(PREFERENCES.WIFI_ENABLED, false);
+  return new UiState(locations, collapsibilities, networkEnabled, wifiEnabled);
 }
 
 exports.configureStore = configureStore;
--- a/devtools/client/aboutdebugging-new/src/reducers/ui-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/ui-state.js
@@ -7,23 +7,24 @@
 const {
   ADB_ADDON_STATUS_UPDATED,
   DEBUG_TARGET_COLLAPSIBILITY_UPDATED,
   NETWORK_LOCATIONS_UPDATED,
   PAGE_SELECTED,
 } = require("../constants");
 
 function UiState(locations = [], debugTargetCollapsibilities = {},
-                 networkEnabled = false) {
+                 networkEnabled = false, wifiEnabled = false) {
   return {
     adbAddonStatus: null,
     debugTargetCollapsibilities,
     networkEnabled,
     networkLocations: locations,
     selectedPage: null,
+    wifiEnabled,
   };
 }
 
 function uiReducer(state = UiState(), action) {
   switch (action.type) {
     case ADB_ADDON_STATUS_UPDATED: {
       const { adbAddonStatus } = action;
       return Object.assign({}, state, { adbAddonStatus });