2015-06-03 10:04:21 +08:00
|
|
|
React = require 'react'
|
|
|
|
Package = require './package'
|
|
|
|
|
|
|
|
class PackageSet extends React.Component
|
|
|
|
@propTypes:
|
2016-02-09 10:35:23 +08:00
|
|
|
title: React.PropTypes.string.isRequired
|
|
|
|
packages: React.PropTypes.array.isRequired
|
2016-02-24 17:04:57 +08:00
|
|
|
emptyText: React.PropTypes.element
|
2015-06-03 10:04:21 +08:00
|
|
|
|
|
|
|
render: ->
|
2015-10-04 09:11:29 +08:00
|
|
|
return false unless @props.packages
|
2016-02-09 10:35:23 +08:00
|
|
|
packages = @props.packages.map (pkg) -> <Package key={pkg.name} package={pkg} />
|
2015-06-03 10:04:21 +08:00
|
|
|
count = <span>({@props.packages.length})</span>
|
|
|
|
|
|
|
|
if packages.length is 0
|
|
|
|
count = []
|
|
|
|
packages.push(
|
2016-02-09 10:35:23 +08:00
|
|
|
<div key="empty" className="empty">{@props.emptyText ? "No plugins to display."}</div>
|
2015-06-03 10:04:21 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
<div className="package-set">
|
|
|
|
<h2>{@props.title} {count}</h2>
|
|
|
|
{ packages }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
module.exports = PackageSet
|