tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DebugTargetList.js (2185B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  createFactory,
      9  PureComponent,
     10 } = require("resource://devtools/client/shared/vendor/react.mjs");
     11 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     12 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     13 
     14 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js");
     15 const Localized = createFactory(FluentReact.Localized);
     16 
     17 const DebugTargetItem = createFactory(
     18  require("resource://devtools/client/aboutdebugging/src/components/debugtarget/DebugTargetItem.js")
     19 );
     20 
     21 const Types = require("resource://devtools/client/aboutdebugging/src/types/index.js");
     22 
     23 /**
     24 * This component displays list of debug target.
     25 */
     26 class DebugTargetList extends PureComponent {
     27  static get propTypes() {
     28    return {
     29      actionComponent: PropTypes.any.isRequired,
     30      additionalActionsComponent: PropTypes.any,
     31      detailComponent: PropTypes.any.isRequired,
     32      dispatch: PropTypes.func.isRequired,
     33      targets: PropTypes.arrayOf(Types.debugTarget).isRequired,
     34    };
     35  }
     36 
     37  renderEmptyList() {
     38    return Localized(
     39      {
     40        id: "about-debugging-debug-target-list-empty",
     41      },
     42      dom.p(
     43        {
     44          className: "qa-debug-target-list-empty",
     45        },
     46        "Nothing yet."
     47      )
     48    );
     49  }
     50 
     51  render() {
     52    const {
     53      actionComponent,
     54      additionalActionsComponent,
     55      detailComponent,
     56      dispatch,
     57      targets,
     58    } = this.props;
     59 
     60    return targets.length === 0
     61      ? this.renderEmptyList()
     62      : dom.ul(
     63          {
     64            className: "debug-target-list qa-debug-target-list",
     65          },
     66          targets.map((target, key) =>
     67            DebugTargetItem({
     68              actionComponent,
     69              additionalActionsComponent,
     70              detailComponent,
     71              dispatch,
     72              key,
     73              target,
     74            })
     75          )
     76        );
     77  }
     78 }
     79 
     80 module.exports = DebugTargetList;