net-info-group-list.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. "use strict";
  5. const React = require("devtools/client/shared/vendor/react");
  6. const NetInfoGroup = React.createFactory(require("./net-info-group"));
  7. // Shortcuts
  8. const DOM = React.DOM;
  9. const PropTypes = React.PropTypes;
  10. /**
  11. * This template is responsible for rendering sections/groups inside tabs.
  12. * It's used e.g to display Response and Request headers as separate groups.
  13. */
  14. var NetInfoGroupList = React.createClass({
  15. propTypes: {
  16. groups: PropTypes.array.isRequired,
  17. },
  18. displayName: "NetInfoGroupList",
  19. render() {
  20. let groups = this.props.groups;
  21. // Filter out empty groups.
  22. groups = groups.filter(group => {
  23. return group && ((group.params && group.params.length) || group.content);
  24. });
  25. // Render groups
  26. groups = groups.map(group => {
  27. group.type = group.key;
  28. return NetInfoGroup(group);
  29. });
  30. return (
  31. DOM.div({className: "netInfoGroupList"},
  32. groups
  33. )
  34. );
  35. }
  36. });
  37. // Exports from this module
  38. module.exports = NetInfoGroupList;