Bug 1500350: Disable 'Inspect' button for extension when extension debug setting was disabled. r=jdescottes,ladybenko
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Tue, 19 Feb 2019 01:13:48 +0000
changeset 459837 ef94872bfd127ed6111236df825af9cb5479aedb
parent 459836 b10932876150bc73be47f0b332028d3b8bcaa6f3
child 459838 dd4aa59c6a1271cbf6ca10813d73f62e7cb072d5
push id35576
push userbtara@mozilla.com
push dateTue, 19 Feb 2019 09:46:27 +0000
treeherdermozilla-central@dd4aa59c6a12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, ladybenko
bugs1500350
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1500350: Disable 'Inspect' button for extension when extension debug setting was disabled. r=jdescottes,ladybenko Depends on D18198 Differential Revision: https://phabricator.services.mozilla.com/D18806
devtools/client/aboutdebugging-new/src/components/RuntimePage.js
devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionAction.js
devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
devtools/client/aboutdebugging-new/src/components/debugtarget/moz.build
--- a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
+++ b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
@@ -10,16 +10,17 @@ const dom = require("devtools/client/sha
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 
 const FluentReact = require("devtools/client/shared/vendor/fluent-react");
 const Localized = createFactory(FluentReact.Localized);
 
 const CompatibilityWarning = createFactory(require("./CompatibilityWarning"));
 const ConnectionPromptSetting = createFactory(require("./ConnectionPromptSetting"));
 const DebugTargetPane = createFactory(require("./debugtarget/DebugTargetPane"));
+const ExtensionAction = createFactory(require("./debugtarget/ExtensionAction"));
 const ExtensionDebugSetting = createFactory(require("./ExtensionDebugSetting"));
 const ExtensionDetail = createFactory(require("./debugtarget/ExtensionDetail"));
 const InspectAction = createFactory(require("./debugtarget/InspectAction"));
 const Message = createFactory(require("./shared/Message"));
 const ProfilerDialog = createFactory(require("./ProfilerDialog"));
 const RuntimeInfo = createFactory(require("./RuntimeInfo"));
 const ServiceWorkerAction = createFactory(require("./debugtarget/ServiceWorkerAction"));
 const ServiceWorkersWarning = createFactory(require("./ServiceWorkersWarning"));
@@ -227,17 +228,17 @@ class RuntimePage extends PureComponent 
       this.renderDebugTargetPane("Temporary Extensions",
                                  temporaryExtensions,
                                  TemporaryExtensionAction,
                                  TemporaryExtensionDetail,
                                  DEBUG_TARGET_PANE.TEMPORARY_EXTENSION,
                                  "about-debugging-runtime-temporary-extensions"),
       this.renderDebugTargetPane("Extensions",
                                  installedExtensions,
-                                 InspectAction,
+                                 ExtensionAction,
                                  ExtensionDetail,
                                  DEBUG_TARGET_PANE.INSTALLED_EXTENSION,
                                  "about-debugging-runtime-extensions"),
       this.renderDebugTargetPane("Tabs",
                                  tabs,
                                  InspectAction,
                                  TabDetail,
                                  DEBUG_TARGET_PANE.TAB,
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionAction.js
@@ -0,0 +1,45 @@
+/* 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 } = require("devtools/client/shared/vendor/react-redux");
+const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
+const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+
+const InspectAction = createFactory(require("./InspectAction"));
+
+const Types = require("../../types/index");
+
+const { getCurrentRuntimeDetails } = require("../../modules/runtimes-state-helper");
+
+/**
+ * This component provides components that inspect extension.
+ */
+class ExtensionAction extends PureComponent {
+  static get propTypes() {
+    return {
+      dispatch: PropTypes.func.isRequired,
+      runtimeDetails: Types.runtimeDetails.isRequired,
+      target: Types.debugTarget.isRequired,
+    };
+  }
+
+  render() {
+    const { dispatch, runtimeDetails, target } = this.props;
+    const { extensionDebugEnabled } = runtimeDetails;
+    return InspectAction({
+      disabled: !extensionDebugEnabled,
+      dispatch,
+      target,
+    });
+  }
+}
+
+const mapStateToProps = state => {
+  return {
+    runtimeDetails: getCurrentRuntimeDetails(state.runtimes),
+  };
+};
+module.exports = connect(mapStateToProps)(ExtensionAction);
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
@@ -6,17 +6,17 @@
 
 const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 
 const FluentReact = require("devtools/client/shared/vendor/fluent-react");
 const Localized = createFactory(FluentReact.Localized);
 
-const InspectAction = createFactory(require("./InspectAction"));
+const ExtensionAction = createFactory(require("./ExtensionAction"));
 
 const Actions = require("../../actions/index");
 const Types = require("../../types/index");
 
 /**
  * This component provides components that inspect/reload/remove temporary extension.
  */
 class TemporaryExtensionAction extends PureComponent {
@@ -39,17 +39,17 @@ class TemporaryExtensionAction extends P
 
   render() {
     const { dispatch, target } = this.props;
 
     return dom.div(
       {
         className: "toolbar",
       },
-      InspectAction({ dispatch, target }),
+      ExtensionAction({ dispatch, target }),
       Localized(
         {
           id: "about-debugging-tmp-extension-reload-button",
         },
         dom.button(
           {
             className: "default-button js-temporary-extension-reload-button",
             onClick: e => this.reload(),
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/moz.build
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/moz.build
@@ -4,16 +4,17 @@
 
 DevToolsModules(
     'DebugTargetItem.css',
     'DebugTargetItem.js',
     'DebugTargetList.css',
     'DebugTargetList.js',
     'DebugTargetPane.css',
     'DebugTargetPane.js',
+    'ExtensionAction.js',
     'ExtensionDetail.css',
     'ExtensionDetail.js',
     'FieldPair.js',
     'InspectAction.js',
     'ServiceWorkerAction.js',
     'TabDetail.js',
     'TemporaryExtensionAction.js',
     'TemporaryExtensionDetail.css',