DomainList.jsx 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. var React = require('react');
  2. var Domain = React.createClass({
  3. render: function() {
  4. var className = this.props.active ? 'active' : '';
  5. return (
  6. <li role="presentation" className={className}>
  7. <a href={'/'+this.props.data.name.val()}>{this.props.data.name.val()}</a>
  8. </li>
  9. );
  10. }
  11. });
  12. var DomainList = React.createClass({
  13. render: function() {
  14. var currDomain = this.props.currentDomain;
  15. var domains = this.props.domains.map(function(domain) {
  16. var active = currDomain === domain.name.val();
  17. return <Domain key={domain.id.val()} data={domain} active={active} />
  18. });
  19. return (
  20. <div>
  21. <h1>Domains</h1>
  22. { domains.length === 0 &&
  23. <div className="alert alert-info">Loading...</div>
  24. }
  25. { domains.length > 0 &&
  26. <ul className="nav nav-pills nav-stacked">
  27. {domains}
  28. </ul>
  29. }
  30. </div>
  31. );
  32. }
  33. });
  34. module.exports = DomainList;