var DomainStore = require('../stores').Domains; var React = require('react'); var CloudActive = React.createClass({ render: function() { var record = this.props.record; if(record.proxiable.val()) { var active = record.proxied.val(); if(active) { return } else { return } } else { return ; } } }); var RecordCreate = React.createClass({ getInitialState: function() { return {saving: false}; }, types: ['A', 'AAAA', 'CNAME', 'LOC', 'NS', 'SPF', 'TXT'], finishSave: function(promise) { promise.then(function() { this.setState({saving: false}); this.reset(); }.bind(this)); }, reset: function() { this.refs.type.getDOMNode().value = this.types[0]; this.refs.name.getDOMNode().value = ""; this.refs.value.getDOMNode().value = ""; }, commitAdd: function() { this.setState({saving: true}); var newRecord = { type: this.refs.type.getDOMNode().value, name: this.refs.name.getDOMNode().value.trim(), content: this.refs.value.getDOMNode().value.trim(), ttl: 1 // automatic }; this.finishSave(DomainStore.recordAdd(this.props.domain, newRecord)); }, render: function() { var className = this.state.saving ? 'saving' : ''; var options = this.types.map(function(type) { return }); return ( ) } }); var Record = React.createClass({ getInitialState: function() { return {state: 'view', saving: false}; }, componentWillReceiveProps: function() { this.setState({state: 'view', saving: false}); }, setDeleting: function() { this.setState({state: 'delete'}); }, setEditing: function() { this.setState({state: 'edit'}); }, cancelEdit: function() { this.setState({state: 'view'}); }, commitDelete: function() { this.setState({saving: true}); var record = this.props.record; DomainStore.recordDelete(record.zone_name.val(), record.id.val()); }, commitEdit: function() { this.setState({saving: true}); var record = this.props.record; var newRecord = { id: record.id.val(), type: record.type.val(), name: this.refs.name.getDOMNode().value.trim(), content: this.refs.value.getDOMNode().value.trim(), ttl: 1 // automatic }; if(record.proxied.val()) { newRecord.proxied = record.proxied.val(); } DomainStore.recordEdit(record.zone_name.val(), newRecord); }, toggleProxy: function() { this.setState({saving: true}); var record = this.props.record; var newRecord = { id: record.id.val(), type: record.type.val(), name: record.name.val(), content: record.content.val(), proxied: !record.proxied.val(), ttl: 1 }; DomainStore.recordEdit(record.zone_name.val(), newRecord); }, render: function() { var record = this.props.record; var className = this.state.saving ? 'saving' : ''; var editDisabled = ['MX', 'SRV'].indexOf(record.type.val()) >= 0; var displayName = record.name.val(); var zoneName = '.'+record.zone_name.val(); var limit = displayName.length - zoneName.length; if(limit > 0 && displayName.substring(limit) === zoneName) { displayName = displayName.substring(0, limit); } if(this.state.state === 'edit') { return ( {record.type.val()} Cancel ); } else if(this.state.state === 'delete') { return ( {record.type.val()} {displayName} {record.content.val()} Cancel ); } else { return ( {record.type.val()} {displayName} {record.content.val()} ); } } }); var RecordList = React.createClass({ render: function() { var records = this.props.records.map(function(record) { return }.bind(this)); var body; if(records.length === 0) { body = ( Loading... ); } else { body = ( {records} ); } return (
{body}
Type Name Value Proxy Actions
); } }); module.exports = RecordList;