tor-browser

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

RuntimeActions.js (2496B)


      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 ConnectionPromptSetting = createFactory(
     18  require("resource://devtools/client/aboutdebugging/src/components/ConnectionPromptSetting.js")
     19 );
     20 
     21 const Actions = require("resource://devtools/client/aboutdebugging/src/actions/index.js");
     22 const {
     23  RUNTIMES,
     24 } = require("resource://devtools/client/aboutdebugging/src/constants.js");
     25 const Types = require("resource://devtools/client/aboutdebugging/src/types/index.js");
     26 
     27 class RuntimeActions extends PureComponent {
     28  static get propTypes() {
     29    return {
     30      dispatch: PropTypes.func.isRequired,
     31      runtimeDetails: Types.runtimeDetails,
     32      runtimeId: PropTypes.string.isRequired,
     33    };
     34  }
     35 
     36  onProfilerButtonClick() {
     37    this.props.dispatch(Actions.showProfilerDialog());
     38  }
     39 
     40  renderConnectionPromptSetting() {
     41    const { dispatch, runtimeDetails, runtimeId } = this.props;
     42    const { connectionPromptEnabled } = runtimeDetails;
     43    // do not show the connection prompt setting in 'This Firefox'
     44    return runtimeId !== RUNTIMES.THIS_FIREFOX
     45      ? ConnectionPromptSetting({
     46          connectionPromptEnabled,
     47          dispatch,
     48        })
     49      : null;
     50  }
     51 
     52  renderProfileButton() {
     53    const { runtimeId } = this.props;
     54 
     55    return runtimeId !== RUNTIMES.THIS_FIREFOX
     56      ? Localized(
     57          {
     58            id: "about-debugging-runtime-profile-button2",
     59          },
     60          dom.button(
     61            {
     62              className: "default-button qa-profile-runtime-button",
     63              onClick: () => this.onProfilerButtonClick(),
     64            },
     65            "about-debugging-runtime-profile-button2"
     66          )
     67        )
     68      : null;
     69  }
     70 
     71  render() {
     72    return dom.div(
     73      {
     74        className: "runtime-actions__toolbar",
     75      },
     76      this.renderProfileButton(),
     77      this.renderConnectionPromptSetting()
     78    );
     79  }
     80 }
     81 
     82 module.exports = RuntimeActions;