var DomainStore = require('../stores').Domains; var React = require('react'); var CloudActive = React.createClass({ render: function() { var record = this.props.record; var type = record.type.val(); if(type === 'A' || type === 'AAAA' || type === 'CNAME') { var active = record.service_mode.val() === '1'; 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() }; this.finishSave(DomainStore.add(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.remove(record.zone_name.val(), record.rec_id.val()); }, commitEdit: function() { this.setState({saving: true}); var record = this.props.record; var newRecord = { id: record.rec_id.val(), type: record.type.val(), name: this.refs.name.getDOMNode().value.trim(), content: this.refs.value.getDOMNode().value.trim() }; if(record.service_mode.val()) { newRecord.service_mode = record.service_mode.val(); } DomainStore.edit(record.zone_name.val(), newRecord); }, toggleProxy: function() { this.setState({saving: true}); var record = this.props.record; var newRecord = { id: record.rec_id.val(), type: record.type.val(), name: record.name.val(), content: record.content.val(), service_mode: record.service_mode.val() === "1" ? "0" : "1" }; DomainStore.edit(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; if(this.state.state === 'edit') { return ( {record.type.val()} Cancel ); } else if(this.state.state === 'delete') { return ( {record.type.val()} {record.display_name.val()} {record.display_content.val()} Cancel ); } else { return ( {record.type.val()} {record.display_name.val()} {record.display_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;