DomainList.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var cloudflare = require('../cloudflare');
  2. var React = require('react');
  3. var Domain = React.createClass({
  4. render: function() {
  5. var className = this.props.active ? 'active' : '';
  6. return (
  7. <li role="presentation" className={className}>
  8. <a href={'/'+this.props.data.zone_name}>{this.props.data.zone_name}</a>
  9. </li>
  10. );
  11. }
  12. });
  13. var DomainList = React.createClass({
  14. getInitialState: function() {
  15. return {domains: []};
  16. },
  17. componentDidMount: function() {
  18. cloudflare.domains().then(function(data) {
  19. this.setState({domains: data.response.zones.objs});
  20. }.bind(this));
  21. },
  22. render: function() {
  23. var currDomain = this.props.currentDomain;
  24. var domains = this.state.domains.map(function(domain) {
  25. var active = currDomain === domain.zone_name;
  26. return <Domain key={domain.zone_id} data={domain} active={active} />
  27. });
  28. return (
  29. <div>
  30. <h1>Domains</h1>
  31. <ul className="nav nav-pills nav-stacked">
  32. {domains}
  33. </ul>
  34. </div>
  35. );
  36. }
  37. });
  38. module.exports = DomainList;