tor-browser

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

DetailsLog.js (1777B)


      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 {
     18  MESSAGE_LEVEL,
     19 } = require("resource://devtools/client/aboutdebugging/src/constants.js");
     20 
     21 /**
     22 * This component is designed to wrap a warning / error log message
     23 * in the details tag to hide long texts and make the message expendable
     24 * out of the box.
     25 */
     26 class DetailsLog extends PureComponent {
     27  static get propTypes() {
     28    return {
     29      children: PropTypes.node.isRequired,
     30      type: PropTypes.string,
     31    };
     32  }
     33  getLocalizationString() {
     34    const { type } = this.props;
     35 
     36    switch (type) {
     37      case MESSAGE_LEVEL.WARNING:
     38        return "about-debugging-message-details-label-warning";
     39      case MESSAGE_LEVEL.ERROR:
     40        return "about-debugging-message-details-label-error";
     41      default:
     42        return "about-debugging-message-details-label";
     43    }
     44  }
     45 
     46  render() {
     47    const { children } = this.props;
     48 
     49    return dom.details(
     50      {
     51        className: "details--log",
     52      },
     53      Localized(
     54        {
     55          id: this.getLocalizationString(),
     56        },
     57        dom.summary({}, this.getLocalizationString())
     58      ),
     59      children
     60    );
     61  }
     62 }
     63 
     64 module.exports = DetailsLog;