summaryrefslogtreecommitdiffstats
path: root/devtools/client/application/src/components/manifest/ManifestSection.js
blob: 4aa92c6a1558d85fd2e61ba14b274aaa834dc1e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* 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/. */

"use strict";

const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js");
const {
  PureComponent,
} = require("resource://devtools/client/shared/vendor/react.js");
const {
  h2,
  section,
} = require("resource://devtools/client/shared/vendor/react-dom-factories.js");

/**
 * A section of a manifest in the form of a captioned table.
 */
class ManifestSection extends PureComponent {
  static get propTypes() {
    return {
      children: PropTypes.node,
      title: PropTypes.string.isRequired,
    };
  }

  render() {
    const { children, title } = this.props;
    const isEmpty = !children || children.length === 0;

    return section(
      {
        className: `manifest-section ${
          isEmpty ? "manifest-section--empty" : ""
        }`,
      },
      h2({ className: "manifest-section__title" }, title),
      children
    );
  }
}

// Exports
module.exports = ManifestSection;