tor-browser

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

TemporaryExtensionInstaller.js (1590B)


      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 /**
     20 * This component provides an installer for temporary extension.
     21 */
     22 class TemporaryExtensionInstaller extends PureComponent {
     23  static get propTypes() {
     24    return {
     25      className: PropTypes.string,
     26      dispatch: PropTypes.func.isRequired,
     27    };
     28  }
     29 
     30  install() {
     31    this.props.dispatch(Actions.installTemporaryExtension());
     32  }
     33 
     34  render() {
     35    const { className } = this.props;
     36 
     37    return Localized(
     38      {
     39        id: "about-debugging-tmp-extension-install-button",
     40      },
     41      dom.button(
     42        {
     43          className: `${className} default-button qa-temporary-extension-install-button`,
     44          onClick: () => this.install(),
     45          disabled: !Services.policies.isAllowed("installTemporaryAddon"),
     46        },
     47        "Load Temporary Add-on…"
     48      )
     49    );
     50  }
     51 }
     52 
     53 module.exports = TemporaryExtensionInstaller;