tor-browser

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

App.js (3448B)


      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  Component,
      9  createFactory,
     10 } = require("resource://devtools/client/shared/vendor/react.mjs");
     11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     12 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     13 const {
     14  connect,
     15 } = require("resource://devtools/client/shared/vendor/react-redux.js");
     16 
     17 // Components
     18 loader.lazyGetter(this, "AppErrorBoundary", function () {
     19  return createFactory(
     20    require("resource://devtools/client/shared/components/AppErrorBoundary.js")
     21  );
     22 });
     23 loader.lazyGetter(this, "MonitorPanel", function () {
     24  return createFactory(
     25    require("resource://devtools/client/netmonitor/src/components/MonitorPanel.js")
     26  );
     27 });
     28 loader.lazyGetter(this, "StatisticsPanel", function () {
     29  return createFactory(
     30    require("resource://devtools/client/netmonitor/src/components/StatisticsPanel.js")
     31  );
     32 });
     33 loader.lazyGetter(this, "DropHarHandler", function () {
     34  return createFactory(
     35    require("resource://devtools/client/netmonitor/src/components/DropHarHandler.js")
     36  );
     37 });
     38 
     39 // Localized strings for (devtools/client/locales/en-US/startup.properties)
     40 loader.lazyGetter(this, "L10N", function () {
     41  const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
     42  return new LocalizationHelper("devtools/client/locales/startup.properties");
     43 });
     44 
     45 const { div } = dom;
     46 
     47 /**
     48 * App component
     49 * The top level component for representing main panel
     50 */
     51 class App extends Component {
     52  static get propTypes() {
     53    return {
     54      // List of actions passed to HAR importer.
     55      actions: PropTypes.object.isRequired,
     56      // The backend connector object.
     57      connector: PropTypes.object.isRequired,
     58      // Callback for opening links in the UI
     59      openLink: PropTypes.func,
     60      // Callback for opening split console.
     61      openSplitConsole: PropTypes.func,
     62      // Service to enable the source map feature.
     63      sourceMapURLService: PropTypes.object,
     64      // True if the stats panel is opened.
     65      statisticsOpen: PropTypes.bool.isRequired,
     66      // Document which settings menu will be injected to
     67      toolboxDoc: PropTypes.object.isRequired,
     68      // Syncing blocked requests
     69      addBlockedUrl: PropTypes.func,
     70    };
     71  }
     72  // Rendering
     73 
     74  render() {
     75    const {
     76      actions,
     77      connector,
     78      openLink,
     79      openSplitConsole,
     80      sourceMapURLService,
     81      statisticsOpen,
     82      toolboxDoc,
     83    } = this.props;
     84 
     85    return div(
     86      { className: "network-monitor" },
     87      AppErrorBoundary(
     88        {
     89          componentName: "Netmonitor",
     90          panel: L10N.getStr("netmonitor.label"),
     91        },
     92        !statisticsOpen
     93          ? DropHarHandler(
     94              {
     95                actions,
     96                openSplitConsole,
     97              },
     98              MonitorPanel({
     99                actions,
    100                connector,
    101                openSplitConsole,
    102                sourceMapURLService,
    103                openLink,
    104                toolboxDoc,
    105              })
    106            )
    107          : StatisticsPanel({
    108              connector,
    109            })
    110      )
    111    );
    112  }
    113 }
    114 
    115 // Exports
    116 
    117 module.exports = connect(state => ({
    118  statisticsOpen: state.ui.statisticsOpen,
    119 }))(App);