2015-06-03 10:04:21 +08:00
|
|
|
React = require 'react'
|
|
|
|
Package = require './package'
|
|
|
|
|
|
|
|
class PackageSet extends React.Component
|
|
|
|
@propTypes:
|
|
|
|
'title': React.PropTypes.string.isRequired
|
|
|
|
'packages': React.PropTypes.array.isRequired
|
|
|
|
'emptyText': React.PropTypes.string
|
|
|
|
|
|
|
|
render: ->
|
2015-10-04 09:11:29 +08:00
|
|
|
return false unless @props.packages
|
2015-06-03 10:04:21 +08:00
|
|
|
packages = @props.packages.map (pkg) -> <Package package={pkg} />
|
|
|
|
count = <span>({@props.packages.length})</span>
|
|
|
|
|
|
|
|
if packages.length is 0
|
|
|
|
count = []
|
|
|
|
packages.push(
|
2016-01-08 06:56:34 +08:00
|
|
|
<div 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
|