couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowalski <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: CORS configuration
Date Tue, 27 Jan 2015 12:25:16 GMT
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/250#discussion_r23604054
  
    --- Diff: app/addons/cors/components.react.jsx ---
    @@ -0,0 +1,307 @@
    +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
    +// use this file except in compliance with the License. You may obtain a copy of
    +// the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    +// License for the specific language governing permissions and limitations under
    +// the License.
    +
    +define([
    +  "api",
    +  "react",
    +  "addons/cors/stores",
    +  "addons/cors/resources",
    +  "addons/cors/actions"
    +], function (FauxtonAPI, React, Stores, Resources, Actions) {
    +  var corsStore = Stores.corsStore;
    +
    +  var validateOrigin = function (origin) {
    +    if (!Resources.validateCORSDomain(origin)) {
    +      FauxtonAPI.addNotification({
    +        msg: 'Please enter a valid domain, starting with http/https and only containing
the domain (not a subfolder).',
    +        type: 'error',
    +        clear: true
    +      });
    +
    +      return false;
    +    }
    +
    +    return true;
    +  };
    +
    +  var OriginRow = React.createClass({
    +
    +    getInitialState: function () {
    +      return {
    +        edit: false,
    +        updatedOrigin: this.props.origin
    +      };
    +    },
    +
    +    editOrigin: function (event) {
    +      event.preventDefault();
    +      this.setState({edit: !this.state.edit});
    +    },
    +
    +    updateOrigin: function (event) {
    +      event.preventDefault();
    +      if (!validateOrigin(this.state.updatedOrigin)) {
    +        return;
    +      }
    +      this.props.updateOrigin(this.state.updatedOrigin, this.props.origin);
    +      this.setState({edit: false});
    +    },
    +
    +    deleteOrigin: function (event) {
    +      event.preventDefault();
    +      if (!window.confirm('Are you sure you want to delete ' + this.props.origin)) {
    +        return;
    +      }
    +
    +      this.props.deleteOrigin(this.props.origin);
    +    },
    +
    +    onInputChange: function (event) {
    +      this.setState({updatedOrigin: event.target.value});
    +    },
    +
    +    createOriginDisplay: function () {
    +      if (this.state.edit) {
    +        return (
    +          <div className="input-append edit-domain-section">
    +            <input type="text" className="span11" name="update_origin_domain" onChange={this.onInputChange}
value={this.state.updatedOrigin}/>
    +            <button onClick={this.updateOrigin} className="btn btn-primary update-origin">
Update </button>
    +          </div>
    +        );
    +      }
    +
    +      return <div className="js-url url-display">{this.props.origin}</div>;
    +    },
    +
    +    render: function () {
    +      var display = this.createOriginDisplay();
    +      return (
    +        <tr>
    +          <td>
    +            { display }
    +          </td>
    +          <td width="30">
    +            <span className="fonticon-pencil" onClick={this.editOrigin} title="Click
to edit"></span>
    +          </td>
    +          <td width="30">
    +            <span className="fonticon-trash" onClick={this.deleteOrigin} title="Click
to delete"></span>
    +          </td>
    +        </tr>
    +      );
    +    }
    +
    +  });
    +
    +  var OriginTable = React.createClass({
    +
    +    createRows: function () {
    +      return _.map(this.props.origins, function (origin, i) {
    +        return <OriginRow
    +          updateOrigin={this.props.updateOrigin}
    +          deleteOrigin={this.props.deleteOrigin}
    +          key={i} origin={origin}
    +        />;
    +      }, this);
    +    },
    +
    +    render: function () {
    +      if (!this.props.isVisible || this.props.origins.length === 0) {
    +        return null;
    +      }
    +
    +      var origins = this.createRows();
    +
    +      return (
    +        <table id="origin-domain-table" className="table table-striped">
    +          <tbody>
    +            {origins}
    +          </tbody>
    +        </table>
    +      );
    +    }
    +
    +  });
    +
    +  var OriginInput = React.createClass({
    +    getInitialState: function () {
    +      return {
    +        origin: ''
    +      };
    +    },
    +
    +    onInputChange: function (e) {
    +      this.setState({origin: e.target.value});
    +    },
    +
    +    addOrigin: function (event) {
    +      event.preventDefault();
    +      if (!validateOrigin(this.state.origin)) {
    +        return;
    +      }
    +
    +      this.props.addOrigin(this.state.origin);
    +      this.setState({origin: ''});
    +    },
    +
    +    render: function () {
    +      if (!this.props.isVisible) {
    +        return null;
    +      }
    +
    +      return (
    +        <div id= "origin-domains-container">
    +          <div className= "origin-domains">
    +            <div className="input-append">
    +              <input type="text" className="span12" name="new_origin_domain" onChange={this.onInputChange}
value={this.state.origin} placeholder="e.g., https://site.com"/>
    +              <button onClick={this.addOrigin} className="btn btn-primary add-domain">
Add </button>
    +            </div>
    +          </div>
    +        </div>
    +      );
    +    }
    +
    +  });
    +
    +  var Origins = React.createClass({
    +
    +    onOriginChange: function (event) {
    +      console.log('boom');
    --- End diff --
    
    debug output


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message