tor-browser

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

NetworkLocationsList.js (2029B)


      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 Actions = require("resource://devtools/client/aboutdebugging/src/actions/index.js");
     18 const Types = require("resource://devtools/client/aboutdebugging/src/types/index.js");
     19 
     20 class NetworkLocationsList extends PureComponent {
     21  static get propTypes() {
     22    return {
     23      dispatch: PropTypes.func.isRequired,
     24      networkLocations: PropTypes.arrayOf(Types.location).isRequired,
     25    };
     26  }
     27 
     28  renderList() {
     29    return dom.ul(
     30      {},
     31      this.props.networkLocations.map(location =>
     32        dom.li(
     33          {
     34            className: "network-location qa-network-location",
     35            key: location,
     36          },
     37          dom.span(
     38            {
     39              className: "ellipsis-text qa-network-location-value",
     40            },
     41            location
     42          ),
     43          Localized(
     44            {
     45              id: "about-debugging-network-locations-remove-button",
     46            },
     47            dom.button(
     48              {
     49                className: "default-button qa-network-location-remove-button",
     50                onClick: () => {
     51                  this.props.dispatch(Actions.removeNetworkLocation(location));
     52                },
     53              },
     54              "Remove"
     55            )
     56          )
     57        )
     58      )
     59    );
     60  }
     61 
     62  render() {
     63    return this.props.networkLocations.length ? this.renderList() : null;
     64  }
     65 }
     66 
     67 module.exports = NetworkLocationsList;