Bug 1500005 - Add types file for aboutdebugging debug-target;r=ladybenko,daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 21 Nov 2018 07:24:00 +0000
changeset 503880 20aac72d781ba237d8419c752a009d689b93889b
parent 503879 43d0beacc72798ba89b122edf8b6cba0ebb3c7ec
child 503881 b362f996a039cd46e06787cacc5b395a4491633b
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko, daisuke
bugs1500005
milestone65.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 1500005 - Add types file for aboutdebugging debug-target;r=ladybenko,daisuke Depends on D11780 Differential Revision: https://phabricator.services.mozilla.com/D11781
devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetItem.js
devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetList.js
devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetPane.js
devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
devtools/client/aboutdebugging-new/src/components/debugtarget/InspectAction.js
devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAction.js
devtools/client/aboutdebugging-new/src/components/debugtarget/TabDetail.js
devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
devtools/client/aboutdebugging-new/src/components/debugtarget/WorkerDetail.js
devtools/client/aboutdebugging-new/src/types/debug-target.js
devtools/client/aboutdebugging-new/src/types/index.js
devtools/client/aboutdebugging-new/src/types/moz.build
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetItem.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetItem.js
@@ -3,26 +3,28 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { 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 Types = require("../../types/index");
+
 /**
  * This component displays debug target.
  */
 class DebugTargetItem extends PureComponent {
   static get propTypes() {
     return {
       actionComponent: PropTypes.any.isRequired,
       detailComponent: PropTypes.any.isRequired,
       dispatch: PropTypes.func.isRequired,
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   renderAction() {
     const { actionComponent, dispatch, target } = this.props;
     return dom.div(
       {
         className: "debug-target-item__action",
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetList.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetList.js
@@ -9,27 +9,29 @@ const { createFactory, createRef, PureCo
 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 DebugTargetItem = createFactory(require("./DebugTargetItem"));
 
+const Types = require("../../types/index");
+
 /**
  * This component displays list of debug target.
  */
 class DebugTargetList extends PureComponent {
   static get propTypes() {
     return {
       actionComponent: PropTypes.any.isRequired,
       detailComponent: PropTypes.any.isRequired,
       dispatch: PropTypes.func.isRequired,
       isCollapsed: PropTypes.bool.isRequired,
-      targets: PropTypes.arrayOf(PropTypes.object).isRequired,
+      targets: PropTypes.arrayOf(Types.debugTarget).isRequired,
     };
   }
 
   constructor(props) {
     super(props);
     this.listRef = createRef();
   }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetPane.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/DebugTargetPane.js
@@ -6,30 +6,31 @@
 
 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 DebugTargetList = createFactory(require("./DebugTargetList"));
 
 const Actions = require("../../actions/index");
+const Types = require("../../types/index");
 
 /**
  * This component provides list for debug target and name area.
  */
 class DebugTargetPane extends PureComponent {
   static get propTypes() {
     return {
       actionComponent: PropTypes.any.isRequired,
       collapsibilityKey: PropTypes.string.isRequired,
       detailComponent: PropTypes.any.isRequired,
       dispatch: PropTypes.func.isRequired,
       isCollapsed: PropTypes.bool.isRequired,
       name: PropTypes.string.isRequired,
-      targets: PropTypes.arrayOf(PropTypes.object).isRequired,
+      targets: PropTypes.arrayOf(Types.debugTarget).isRequired,
     };
   }
 
   toggleCollapsibility() {
     const { collapsibilityKey, dispatch, isCollapsed } = this.props;
     dispatch(Actions.updateDebugTargetCollapsibility(collapsibilityKey, !isCollapsed));
   }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
@@ -8,25 +8,27 @@ const { createFactory, PureComponent } =
 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 FieldPair = createFactory(require("./FieldPair"));
 
+const Types = require("../../types/index");
+
 /**
  * This component displays detail information for extension.
  */
 class ExtensionDetail extends PureComponent {
   static get propTypes() {
     return {
       // Provided by wrapping the component with FluentReact.withLocalization.
       getString: PropTypes.func.isRequired,
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   renderUUID() {
     const { target } = this.props;
     const { manifestURL, uuid } = target.details;
 
     const value = [
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/InspectAction.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/InspectAction.js
@@ -7,25 +7,26 @@
 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 Actions = require("../../actions/index");
+const Types = require("../../types/index");
 
 /**
  * This component provides inspect button.
  */
 class InspectAction extends PureComponent {
   static get propTypes() {
     return {
       dispatch: PropTypes.func.isRequired,
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   inspect() {
     const { dispatch, target } = this.props;
     dispatch(Actions.inspectDebugTarget(target.type, target.id));
   }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAction.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ServiceWorkerAction.js
@@ -8,27 +8,28 @@ const { createFactory, PureComponent } =
 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 InspectAction = createFactory(require("./InspectAction"));
 
 const Actions = require("../../actions/index");
+const Types = require("../../types/index");
 
 /**
  * This component displays buttons for service worker.
  */
 class ServiceWorkerAction extends PureComponent {
   static get propTypes() {
     return {
       dispatch: PropTypes.func.isRequired,
       // Provided by wrapping the component with FluentReact.withLocalization.
       getString: PropTypes.func.isRequired,
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   push() {
     const { dispatch, target } = this.props;
     dispatch(Actions.pushServiceWorker(target.id));
   }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/TabDetail.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/TabDetail.js
@@ -1,25 +1,25 @@
 /* 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 { 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 Types = require("../../types/index");
 
 /**
  * This component displays detail information for tab.
  */
 class TabDetail extends PureComponent {
   static get propTypes() {
     return {
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   render() {
     return dom.div({ className: "ellipsis-text" }, this.props.target.details.url);
   }
 }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAction.js
@@ -9,25 +9,26 @@ 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 InspectAction = createFactory(require("./InspectAction"));
 
 const Actions = require("../../actions/index");
+const Types = require("../../types/index");
 
 /**
  * This component provides components that inspect/reload/remove temporary extension.
  */
 class TemporaryExtensionAction extends PureComponent {
   static get propTypes() {
     return {
       dispatch: PropTypes.func.isRequired,
-      target: PropTypes.object.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   reload() {
     const { dispatch, target } = this.props;
     dispatch(Actions.reloadTemporaryExtension(target.details.actor));
   }
 
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/WorkerDetail.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/WorkerDetail.js
@@ -12,25 +12,27 @@ const FluentReact = require("devtools/cl
 const Localized = createFactory(FluentReact.Localized);
 
 const {
   SERVICE_WORKER_FETCH_STATES,
 } = require("../../constants");
 
 const FieldPair = createFactory(require("./FieldPair"));
 
+const Types = require("../../types/index");
+
 /**
  * This component displays detail information for worker.
  */
 class WorkerDetail extends PureComponent {
   static get propTypes() {
     return {
-      target: PropTypes.object.isRequired,
       // Provided by wrapping the component with FluentReact.withLocalization.
       getString: PropTypes.func.isRequired,
+      target: Types.debugTarget.isRequired,
     };
   }
 
   renderFetch() {
     const { fetch } = this.props.target.details;
     const status = fetch === SERVICE_WORKER_FETCH_STATES.LISTENING
                     ? "listening"
                     : "not-listening";
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/src/types/debug-target.js
@@ -0,0 +1,60 @@
+/* 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 PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+
+const extensionTargetDetails = {
+  // actor ID for this extention.
+  actor: PropTypes.string.isRequired,
+  location: PropTypes.string.isRequired,
+  // manifestURL points to the manifest.json file. This URL is only valid when debugging
+  // local extensions so it might be null.
+  manifestURL: PropTypes.string,
+  // unique extension id.
+  uuid: PropTypes.string.isRequired,
+};
+
+const tabTargetDetails = {
+  // the url of the tab.
+  url: PropTypes.string.isRequired,
+};
+
+const workerTargetDetails = {
+  // (service worker specific) one of "LISTENING", "NOT_LISTENING". undefined otherwise.
+  fetch: PropTypes.string,
+  // (service worker specific) true if they reached the activated state.
+  isActive: PropTypes.bool,
+  // (service worker specific) true if they are currently running.
+  isRunning: PropTypes.bool,
+  // actor id for the ServiceWorkerRegistration related to this service worker.
+  registrationActor: PropTypes.string,
+  // (service worker specific) scope of the service worker registration.
+  scope: PropTypes.string,
+  // (service worker specific) one of "RUNNING", "REGISTERING", "STOPPED".
+  status: PropTypes.string,
+};
+
+const debugTarget = {
+  // details property will contain a type-specific object.
+  details: PropTypes.oneOfType([
+    PropTypes.shape(extensionTargetDetails),
+    PropTypes.shape(tabTargetDetails),
+    PropTypes.shape(workerTargetDetails),
+  ]).isRequired,
+  // icon to display for the debug target.
+  icon: PropTypes.string.isRequired,
+  // unique id for the target (unique in the scope of the application lifecycle).
+  // - extensions: {String} extension id (for instance "someextension@mozilla.org")
+  // - tabs: {Number} outerWindowID
+  // - workers: {String} id for the WorkerTargetActor corresponding to the worker
+  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
+  // display name for the debug target.
+  name: PropTypes.string.isRequired,
+  // one of "EXTENSION", "TAB", "WORKER".
+  type: PropTypes.string.isRequired,
+};
+
+exports.debugTarget = PropTypes.shape(debugTarget);
--- a/devtools/client/aboutdebugging-new/src/types/index.js
+++ b/devtools/client/aboutdebugging-new/src/types/index.js
@@ -1,11 +1,13 @@
 /* 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 { debugTarget } = require("./debug-target");
 const { runtime } = require("./runtime");
 
 module.exports = Object.assign({}, {
+  debugTarget,
   runtime,
 });
--- a/devtools/client/aboutdebugging-new/src/types/moz.build
+++ b/devtools/client/aboutdebugging-new/src/types/moz.build
@@ -1,8 +1,9 @@
 # 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/.
 
 DevToolsModules(
+    'debug-target.js',
     'index.js',
     'runtime.js',
 )
\ No newline at end of file