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 CCB6A1786E for ; Mon, 13 Apr 2015 09:28:08 +0000 (UTC) Received: (qmail 10440 invoked by uid 500); 13 Apr 2015 09:28:08 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 10378 invoked by uid 500); 13 Apr 2015 09:28:08 -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 10335 invoked by uid 99); 13 Apr 2015 09:28:08 -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; Mon, 13 Apr 2015 09:28:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2F319DFF73; Mon, 13 Apr 2015 09:28:08 +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: Databases view in react Content-Type: text/plain Message-Id: <20150413092808.2F319DFF73@git1-us-west.apache.org> Date: Mon, 13 Apr 2015 09:28:08 +0000 (UTC) Github user robertkowalski commented on a diff in the pull request: https://github.com/apache/couchdb-fauxton/pull/370#discussion_r28224794 --- Diff: app/addons/databases/components.react.jsx --- @@ -0,0 +1,271 @@ +// 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([ + 'app', + 'api', + 'react', + 'addons/fauxton/components.react', + 'addons/databases/stores', + 'addons/databases/resources', + 'addons/databases/actions', + 'helpers' +], function (app, FauxtonAPI, React, ComponentsReact, Stores, Resources, Actions, Helpers) { + + var databasesStore = Stores.databasesStore; + + var DatabasesController = React.createClass({ + + getStoreState: function () { + return { + collection: databasesStore.getCollection() + }; + }, + + getInitialState: function () { + return this.getStoreState(); + }, + + render: function () { + return ( + + ); + } + }); + + var DatabaseTable = React.createClass({ + + createRows: function () { + return _.map(this.props.body, function (item, iteration) { + return ( + + ); + }); + }, + + render: function () { + var rows = this.createRows(); + return ( +
+ + + + + + + + + + {rows} + +
NameSize# of DocsUpdate SeqActions
+
+ ); + } + }); + + var DatabaseRow = React.createClass({ + + renderGraveyard : function (row) { + if (row.status.isGraveYard()) { + return ( + + ); + } else { + return null; + } + }, + + render: function () { + var row = this.props.row; + var name = row.get("name"); + var encoded = app.utils.safeURLName(name); + var size = Helpers.formatSize(row.status.dataSize()); + return ( + + + {name} + + {size} + {row.status.numDocs()} {this.renderGraveyard(row)} + {row.status.updateSeq()} + +   + + + + ); + } + }); + + var GraveyardInfo = React.createClass({ + + componentDidMount : function () { + $(this.refs.myself.getDOMNode()).tooltip(); + }, + + render : function () { + var row = this.props.row; + return ( + + ); + } + }); + + var RightDatabasesHeader = React.createClass({ + + render : function () { + return ( +
+ + +
+ ); + } + }); + + var AddDatabaseWidget = React.createClass({ + + onTrayToggle : function () { + var that = this; + this.refs.newDbTray.toggle(function (shown) { + if (shown) { + that.refs.newDbName.getDOMNode().focus(); + } + }); + }, + + onKeyUpInInput : function (e) { + if (e.which === 13) { + this.onAddDatabase(); + } + }, + + onAddDatabase : function () { + var databaseName = $(this.refs.newDbName.getDOMNode()).val(); --- End diff -- that is how we would do it in jquery, take a look at https://github.com/apache/couchdb-fauxton/blob/master/app/addons/cors/components.react.jsx#L69 for how to solve that in react components without jquery --- 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. ---