app.jsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var cloudflare = require('./cloudflare');
  2. var React = require('react');
  3. var ReactMiniRouter = require('react-mini-router');
  4. var DomainList = require('./ui/DomainList');
  5. var RecordList = require('./ui/RecordList');
  6. var Settings = require('./ui/Settings');
  7. var App = React.createClass({
  8. mixins: [ReactMiniRouter.RouterMixin],
  9. routes: {
  10. '/': 'home',
  11. '/:domain': 'domain',
  12. '/:domain/settings': 'settings'
  13. },
  14. render: function() {
  15. return this.renderCurrentRoute();
  16. },
  17. main: function(domain, settings) {
  18. var title;
  19. var content = [];
  20. if(domain) {
  21. title = domain;
  22. content.push(
  23. <ul key="nav" className="nav nav-tabs">
  24. <li role="presentation" className={!settings ? 'active' : ''}><a href={'/'+domain}>DNS</a></li>
  25. <li role="presentation" className={settings ? 'active' : ''}><a href={'/'+domain+'/settings'}>Settings</a></li>
  26. </ul>
  27. );
  28. if(settings) {
  29. content.push(<Settings key="settings" domain={domain} />);
  30. }
  31. else {
  32. content.push(<RecordList key="records" domain={domain} />);
  33. }
  34. }
  35. else {
  36. title = "CloudFlare WebUI";
  37. content.push(<p key="content">Select a domain from the sidebar</p>);
  38. }
  39. return (
  40. <div className="row">
  41. <div id="domains" className="col-md-3">
  42. <DomainList currentDomain={domain} />
  43. </div>
  44. <div className="col-md-9">
  45. <h1>{title}</h1>
  46. {content}
  47. </div>
  48. </div>
  49. );
  50. },
  51. home: function() {
  52. return this.main();
  53. },
  54. domain: function(domain) {
  55. return this.main(domain, false);
  56. },
  57. settings: function(domain) {
  58. return this.main(domain, true);
  59. }
  60. });
  61. module.exports = App;