tor-browser

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

TextPanel.mjs (1715B)


      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 import { Component } from "resource://devtools/client/shared/vendor/react.mjs";
      6 import PropTypes from "resource://devtools/client/shared/vendor/react-prop-types.mjs";
      7 import * as dom from "resource://devtools/client/shared/vendor/react-dom-factories.mjs";
      8 import { createFactories } from "resource://devtools/client/shared/react-utils.mjs";
      9 
     10 import TextToolbarClass from "resource://devtools/client/jsonview/components/TextToolbar.mjs";
     11 
     12 const { TextToolbar } = createFactories(TextToolbarClass);
     13 import LiveTextClass from "resource://devtools/client/jsonview/components/LiveText.mjs";
     14 
     15 const { LiveText } = createFactories(LiveTextClass);
     16 const { div } = dom;
     17 
     18 /**
     19 * This template represents the 'Raw Data' panel displaying
     20 * JSON as a text received from the server.
     21 */
     22 class TextPanel extends Component {
     23  static get propTypes() {
     24    return {
     25      isValidJson: PropTypes.bool,
     26      actions: PropTypes.object,
     27      errorMessage: PropTypes.string,
     28      data: PropTypes.instanceOf(Text),
     29    };
     30  }
     31 
     32  constructor(props) {
     33    super(props);
     34    this.state = {};
     35  }
     36 
     37  render() {
     38    return div(
     39      { className: "textPanelBox tab-panel-inner" },
     40      TextToolbar({
     41        actions: this.props.actions,
     42        isValidJson: this.props.isValidJson,
     43      }),
     44      this.props.errorMessage
     45        ? div({ className: "jsonParseError" }, this.props.errorMessage)
     46        : null,
     47      div({ className: "panelContent" }, LiveText({ data: this.props.data }))
     48    );
     49  }
     50 }
     51 
     52 export default { TextPanel };