garrensmith commented on a change in pull request #947: WIP: Refactor CORS addon
URL: https://github.com/apache/couchdb-fauxton/pull/947#discussion_r131643038
 
 

 ##########
 File path: app/addons/cors/components/OriginInput.js
 ##########
 @@ -0,0 +1,61 @@
+import React, { Component } from "react";
+import { validateDomain, normalizeUrls } from "../helpers";
+// import Resources from "../resources";
+
+export default class OriginInput extends Component {
+
+  constructor (props) {
+    super(props);
+    this.state = {
+      origin: ''
+    };
+  }
+
+  onInputChange (e) {
+    this.setState({origin: e.target.value});
+  }
+
+  addOrigin (event) {
+    event.preventDefault();
+    console.log('>>> OriginInput.addOrigin ');
+    if (!validateDomain(this.state.origin)) {
+      return false;
+    }
+
+    // const url = Resources.normalizeUrls(this.state.origin);
+    const url = normalizeUrls(this.state.origin);
+
+    this.props.addOrigin(url);
+    this.setState({origin: ''});
+  }
+
+  onKeyUp (e) {
+    if (e.keyCode == 13) {   //enter key
+      console.log('>>> OriginInput.onKeyUp ');
+      return this.addOrigin(e);
+    }
+  }
+
+  render () {
+    if (!this.props.isVisible) {
+      return null;
+    }
+
+    return (
+      <div id="origin-domains-container">
+        <div className="origin-domains">
+          <div className="input-append">
+            <input type="text" name="new_origin_domain" 
onChange={this.onInputChange.bind(this)}  value={this.state.origin} 
placeholder="https://example.com"/>
 
 Review comment:
   This line is a little long. Could you split it up a bit.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to