Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A01C610F77 for ; Tue, 27 Jan 2015 12:25:17 +0000 (UTC) Received: (qmail 39694 invoked by uid 500); 27 Jan 2015 12:25:17 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 39629 invoked by uid 500); 27 Jan 2015 12:25:17 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 39563 invoked by uid 99); 27 Jan 2015 12:25:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Jan 2015 12:25:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CA88AE03F8; Tue, 27 Jan 2015 12:25:16 +0000 (UTC) From: robertkowalski To: dev@couchdb.apache.org Reply-To: dev@couchdb.apache.org References: In-Reply-To: Subject: [GitHub] couchdb-fauxton pull request: CORS configuration Content-Type: text/plain Message-Id: <20150127122516.CA88AE03F8@git1-us-west.apache.org> Date: Tue, 27 Jan 2015 12:25:16 +0000 (UTC) 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 ( +
+ + +
+ ); + } + + return
{this.props.origin}
; + }, + + render: function () { + var display = this.createOriginDisplay(); + return ( + + + { display } + + + + + + + + + ); + } + + }); + + var OriginTable = React.createClass({ + + createRows: function () { + return _.map(this.props.origins, function (origin, i) { + return ; + }, this); + }, + + render: function () { + if (!this.props.isVisible || this.props.origins.length === 0) { + return null; + } + + var origins = this.createRows(); + + return ( + + + {origins} + +
+ ); + } + + }); + + 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 ( +
+
+
+ + +
+
+
+ ); + } + + }); + + 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. ---