How to use the devtools/client/shared/vendor/react.createClass function in devtools

To help you get started, we’ve selected a few devtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joewalker / devtools.html / client / aboutdebugging / components / target.js View on Github external
Toolbox */

"use strict";

const React = require("devtools/client/shared/vendor/react");
const { TargetFactory } = require("devtools/client/framework/target");
const { Toolbox } = require("devtools/client/framework/toolbox");
const { Services } = require("devtools/sham/services");

const { BrowserToolboxProcess } = require("devtools/client/framework/ToolboxProcess");
const { gDevTools } = require("devtools/client/framework/gDevTools");

const Strings = Services.strings.createBundle(
  require("l10n/aboutdebugging.properties"));

exports.TargetComponent = React.createClass({
  displayName: "TargetComponent",

  debug() {
    let client = this.props.client;
    let target = this.props.target;
    switch (target.type) {
      case "extension":
        BrowserToolboxProcess.init({ addonID: target.addonID });
        break;
      case "serviceworker":
        // Fall through.
      case "sharedworker":
        // Fall through.
      case "worker":
        let workerActor = this.props.target.actorID;
        client.attachWorker(workerActor, (response, workerClient) => {
github firefox-devtools / debugger / packages / devtools-modules / client / shared / components / reps / window.js View on Github external
define(function (require, exports, module) {
  // ReactJS
  const React = require("devtools/client/shared/vendor/react");

  // Reps
  const { isGrip, getURLDisplayString } = require("./rep-utils");

  // Shortcuts
  const DOM = React.DOM;

  /**
   * Renders a grip representing a window.
   */
  let Window = React.createClass({
    displayName: "Window",

    propTypes: {
      object: React.PropTypes.object.isRequired,
      mode: React.PropTypes.string
    },

    getTitle: function (grip) {
      if (this.props.objectLink) {
        return DOM.span({className: "objectBox"},
          this.props.objectLink({
            object: grip
          }, grip.class + " ")
        );
      }
      return "";
github firefox-devtools / debugger / packages / devtools-modules / client / shared / components / reps / string.js View on Github external
define(function (require, exports, module) {
  // Dependencies
  const React = require("devtools/client/shared/vendor/react");
  const { cropMultipleLines } = require("./rep-utils");

  // Shortcuts
  const { span } = React.DOM;

  /**
   * Renders a string. String value is enclosed within quotes.
   */
  const StringRep = React.createClass({
    displayName: "StringRep",

    propTypes: {
      useQuotes: React.PropTypes.bool,
    },

    getDefaultProps: function () {
      return {
        useQuotes: true,
      };
    },

    render: function () {
      let text = this.props.object;
      let member = this.props.member;
      if (member && member.open) {
github firefox-devtools / debugger / public / js / lib / devtools / client / shared / components / reps / object-link.js View on Github external
define(function (require, exports, module) {
  // Dependencies
  const React = require("devtools/client/shared/vendor/react");
  const DOM = React.DOM;

  /**
   * Renders a link for given object.
   */
  const ObjectLink = React.createClass({
    displayName: "ObjectLink",

    render: function () {
      let className = this.props.className;
      let objectClassName = className ? " objectLink-" + className : "";
      let linkClassName = "objectLink" + objectClassName + " a11yFocus";

      return (
        DOM.a({className: linkClassName, _repObject: this.props.object},
          this.props.children
        )
      );
    }
  });

  // Exports from this module
github firefox-devtools / debugger / packages / devtools-modules / client / shared / components / reps / prop-rep.js View on Github external
define(function (require, exports, module) {
  const React = require("devtools/client/shared/vendor/react");
  const { createFactories } = require("./rep-utils");
  const { span } = React.DOM;

  /**
   * Property for Obj (local JS objects), Grip (remote JS objects)
   * and GripMap (remote JS maps and weakmaps) reps.
   * It's used to render object properties.
   */
  let PropRep = React.createFactory(React.createClass({
    displayName: "PropRep",

    propTypes: {
      // Property name.
      name: React.PropTypes.oneOfType([
        React.PropTypes.string,
        React.PropTypes.object,
      ]).isRequired,
      // Equal character rendered between property name and value.
      equal: React.PropTypes.string,
      // Delimiter character used to separate individual properties.
      delim: React.PropTypes.string,
      mode: React.PropTypes.string,
    },

    render: function () {
github firefox-devtools / debugger / packages / devtools-modules / client / shared / components / splitter / Draggable.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require("devtools/client/shared/vendor/react");
const ReactDOM = require("devtools/client/shared/vendor/react-dom");
const { DOM: dom, PropTypes } = React;

const Draggable = React.createClass({
  displayName: "Draggable",

  propTypes: {
    onMove: PropTypes.func.isRequired,
    onStart: PropTypes.func,
    onStop: PropTypes.func,
    style: PropTypes.object,
    className: PropTypes.string
  },

  startDragging(ev) {
    ev.preventDefault();
    const doc = ReactDOM.findDOMNode(this).ownerDocument;
    doc.addEventListener("mousemove", this.onMove);
    doc.addEventListener("mouseup", this.onUp);
    this.props.onStart && this.props.onStart();
github firefox-devtools / debugger / packages / devtools-modules / client / shared / components / reps / grip-array.js View on Github external
define(function (require, exports, module) {
  // Dependencies
  const React = require("devtools/client/shared/vendor/react");
  const { createFactories, isGrip } = require("./rep-utils");
  const { Caption } = createFactories(require("./caption"));

  // Shortcuts
  const { span } = React.DOM;

  /**
   * Renders an array. The array is enclosed by left and right bracket
   * and the max number of rendered items depends on the current mode.
   */
  let GripArray = React.createClass({
    displayName: "GripArray",

    propTypes: {
      object: React.PropTypes.object.isRequired,
      mode: React.PropTypes.string,
      provider: React.PropTypes.object,
    },

    getLength: function (grip) {
      return grip.preview ? grip.preview.length : 0;
    },

    getTitle: function (object, context) {
      let objectLink = this.props.objectLink || span;
      if (this.props.mode != "tiny") {
        return objectLink({
github firefox-devtools / devtools-core / packages / devtools-modules / client / shared / components / reps / grip.js View on Github external
define(function (require, exports, module) {
  // ReactJS
  const React = require("devtools/client/shared/vendor/react");
  // Dependencies
  const { createFactories, isGrip } = require("./rep-utils");
  const { Caption } = createFactories(require("./caption"));
  const { PropRep } = createFactories(require("./prop-rep"));
  // Shortcuts
  const { span } = React.DOM;

  /**
   * Renders generic grip. Grip is client representation
   * of remote JS object and is used as an input object
   * for this rep component.
   */
  const GripRep = React.createClass({
    displayName: "Grip",

    propTypes: {
      object: React.PropTypes.object.isRequired,
      mode: React.PropTypes.string,
      isInterestingProp: React.PropTypes.func
    },

    getTitle: function (object) {
      if (this.props.objectLink) {
        return this.props.objectLink({
          object: object
        }, object.class);
      }
      return object.class || "Object";
    },
github joewalker / devtools.html / client / aboutdebugging / components / addons.js View on Github external
/* global AddonManager, React, TargetListComponent */

"use strict";

const React = require("devtools/client/shared/vendor/react");
const { TargetListComponent } = require("devtools/client/aboutdebugging/components/target-list");
const { Services } = require("devtools/sham/services");

const { AddonManager } = require("devtools/sham/addonmanager");

const ExtensionIcon = "/devtools/client/chrome/mozapps/skin/extensions/extensionGeneric.svg";
const Strings = Services.strings.createBundle(
  require("l10n/aboutdebugging.properties"));

exports.AddonsComponent = React.createClass({
  displayName: "AddonsComponent",

  getInitialState() {
    return {
      extensions: []
    };
  },

  componentDidMount() {
    AddonManager.addAddonListener(this);
    this.update();
  },

  componentWillUnmount() {
    AddonManager.removeAddonListener(this);
  },
github firefox-devtools / debugger / public / js / lib / devtools / client / shared / components / reps / named-node-map.js View on Github external
),
          items,
          span({
            className: "arrayRightBracket",
            role: "presentation"},
            "]"
          )
        )
      );
    },
  });

  /**
   * Property for a grip object.
   */
  let PropRep = React.createFactory(React.createClass({
    displayName: "PropRep",

    propTypes: {
      equal: React.PropTypes.string,
      delim: React.PropTypes.string,
    },

    render: function () {
      const { Rep } = createFactories(require("./rep"));

      return (
        span({},
          span({
            className: "nodeName"},
            "$prop.name"
          ),