Mailspring/app/internal_packages_disabled/plugins/lib/package-set.jsx

43 lines
971 B
React
Raw Normal View History

import React from 'react';
2017-09-27 02:33:08 +08:00
import PropTypes from 'prop-types';
import Package from './package';
class PackageSet extends React.Component {
static propTypes = {
2017-09-27 02:33:08 +08:00
title: PropTypes.string.isRequired,
packages: PropTypes.array,
emptyText: PropTypes.element,
showVersions: PropTypes.bool,
};
render() {
if (!this.props.packages) return false;
2017-09-27 02:33:08 +08:00
const packages = this.props.packages.map(pkg => (
<Package key={pkg.name} package={pkg} showVersions={this.props.showVersions} />
2017-09-27 02:33:08 +08:00
));
let count = <span>({this.props.packages.length})</span>;
if (packages.length === 0) {
count = [];
packages.push(
2017-09-27 02:33:08 +08:00
<div key="empty" className="empty">
{this.props.emptyText || 'No plugins to display.'}
</div>
);
}
return (
<div className="package-set">
2017-09-27 02:33:08 +08:00
<h6>
{this.props.title} {count}
</h6>
{packages}
</div>
);
}
}
export default PackageSet;