tor-browser

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

ConnectionPromptSetting.js (1731B)


      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 
     19 class ConnectionPromptSetting extends PureComponent {
     20  static get propTypes() {
     21    return {
     22      className: PropTypes.string,
     23      connectionPromptEnabled: PropTypes.bool.isRequired,
     24      dispatch: PropTypes.func.isRequired,
     25    };
     26  }
     27 
     28  onToggleClick() {
     29    const { connectionPromptEnabled, dispatch } = this.props;
     30    dispatch(Actions.updateConnectionPromptSetting(!connectionPromptEnabled));
     31  }
     32 
     33  render() {
     34    const { className, connectionPromptEnabled } = this.props;
     35 
     36    const localizedState = connectionPromptEnabled
     37      ? "about-debugging-connection-prompt-disable-button"
     38      : "about-debugging-connection-prompt-enable-button";
     39 
     40    return Localized(
     41      {
     42        id: localizedState,
     43      },
     44      dom.button(
     45        {
     46          className: `${className} default-button qa-connection-prompt-toggle-button`,
     47          onClick: () => this.onToggleClick(),
     48        },
     49        localizedState
     50      )
     51    );
     52  }
     53 }
     54 
     55 module.exports = ConnectionPromptSetting;