main-frame.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. "use strict";
  6. // React & Redux
  7. const React = require("devtools/client/shared/vendor/react");
  8. const { connect } = require("devtools/client/shared/vendor/react-redux");
  9. // DOM Panel
  10. const DomTree = React.createFactory(require("./dom-tree"));
  11. const MainToolbar = React.createFactory(require("./main-toolbar"));
  12. // Shortcuts
  13. const { div } = React.DOM;
  14. const PropTypes = React.PropTypes;
  15. /**
  16. * Renders basic layout of the DOM panel. The DOM panel cotent consists
  17. * from two main parts: toolbar and tree.
  18. */
  19. var MainFrame = React.createClass({
  20. displayName: "MainFrame",
  21. propTypes: {
  22. object: PropTypes.any,
  23. filter: PropTypes.string,
  24. dispatch: PropTypes.func.isRequired,
  25. },
  26. /**
  27. * Render DOM panel content
  28. */
  29. render: function () {
  30. return (
  31. div({className: "mainFrame"},
  32. MainToolbar({
  33. dispatch: this.props.dispatch,
  34. object: this.props.object
  35. }),
  36. div({className: "treeTableBox"},
  37. DomTree({
  38. object: this.props.object,
  39. filter: this.props.filter,
  40. })
  41. )
  42. )
  43. );
  44. }
  45. });
  46. // Transform state into props
  47. // Note: use https://github.com/faassen/reselect for better performance.
  48. const mapStateToProps = (state) => {
  49. return {
  50. filter: state.filter
  51. };
  52. };
  53. // Exports from this module
  54. module.exports = connect(mapStateToProps)(MainFrame);