var React = require('react');
var AppItem = require('./app-item.jsx');

module.exports = React.createClass({

  propTypes: {
    items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
    parentPath: React.PropTypes.oneOfType([
      React.PropTypes.string,
      React.PropTypes.arrayOf(React.PropTypes.number)
    ]).isRequired,
    onItemClick: React.PropTypes.func.isRequired,
  },

  render: function() {

    var parentPath = this.props.parentPath;
    var items = (this.props.items).map(function(item, i) {
      var path = parentPath+'.'+i;
      return (
        <AppItem key={path} itemPath={path} item={item} onItemClick={this.props.onItemClick} />
      );
    }.bind(this));

    return (
      <ul key={parentPath} className="apps-list">
        {items}
      </ul>
    );

  }

});
