couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 825bbfc
Date Tue, 25 Aug 2015 14:18:31 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 79ab3b68c -> 825bbfc42


Query Options fixes

This fixes a few issues with the query options:
- the supplying a startkey/endkey now returns results
- default msg shown when no results updated to work for all scenarios
- tray hides after performing a search

Mocha + NW tests included


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/825bbfc4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/825bbfc4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/825bbfc4

Branch: refs/heads/master
Commit: 825bbfc420e2a21151d7725a642614e0bf17d1d6
Parents: 79ab3b6
Author: Ben Keen <ben.keen@gmail.com>
Authored: Mon Aug 24 11:08:27 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Tue Aug 25 07:19:07 2015 -0700

----------------------------------------------------------------------
 .../components/react-components.react.jsx       |  8 +-
 .../documents/queryoptions/actiontypes.js       |  1 +
 .../queryoptions/queryoptions.react.jsx         | 82 ++++++++++----------
 app/addons/documents/queryoptions/stores.js     | 32 ++++----
 .../tests/queryoptions.storesSpec.js            |  4 +-
 app/addons/documents/routes-documents.js        |  2 +-
 .../documents/tests/nightwatch/queryOptions.js  | 36 +++++++++
 7 files changed, 104 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/components/react-components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/react-components.react.jsx b/app/addons/components/react-components.react.jsx
index b712e72..c64bd3d 100644
--- a/app/addons/components/react-components.react.jsx
+++ b/app/addons/components/react-components.react.jsx
@@ -771,7 +771,7 @@ function (app, FauxtonAPI, React, Components, ace, beautifyHelper) {
 
     render: function () {
       return (
-        <ReactCSSTransitionGroup transitionName="tray" transitionAppear={true}>
+        <ReactCSSTransitionGroup transitionName="tray" transitionAppear={true} component="div">
           {this.getChildren()}
         </ReactCSSTransitionGroup>
       );
@@ -811,6 +811,10 @@ function (app, FauxtonAPI, React, Components, ace, beautifyHelper) {
       this.setState({trayVisible: !this.state.trayVisible});
     },
 
+    hideTray: function () {
+      this.setState({ trayVisible: false });
+    },
+
     renderChildren: function () {
       return React.Children.map(this.props.children, function (child, key) {
         return React.addons.cloneWithProps(child, {
@@ -836,7 +840,7 @@ function (app, FauxtonAPI, React, Components, ace, beautifyHelper) {
       if (!trayEl.is(e.target) && trayEl.has(e.target).length === 0) {
         this.toggleTray();
       }
-    },
+    }
 
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/queryoptions/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/queryoptions/actiontypes.js b/app/addons/documents/queryoptions/actiontypes.js
index 23e1fce..22545e5 100644
--- a/app/addons/documents/queryoptions/actiontypes.js
+++ b/app/addons/documents/queryoptions/actiontypes.js
@@ -19,6 +19,7 @@ define([], function () {
     QUERY_UPDATE_BY_KEYS: 'QUERY_UPDATE_BY_KEYS',
     QUERY_TOGGLE_UPDATE_SEQ: 'QUERY_TOGGLE_UPDATE_SEQ',
     QUERY_TOGGLE_DESCENDING: 'QUERY_TOGGLE_DESCENDING',
+    QUERY_TOGGLE_REDUCE: 'QUERY_TOGGLE_REDUCE',
     QUERY_UPDATE_SKIP: 'QUERY_UPDATE_SKIP',
     QUERY_UPDATE_LIMIT: 'QUERY_UPDATE_LIMIT',
     QUERY_RESET: 'QUERY_RESET',

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/queryoptions/queryoptions.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/queryoptions/queryoptions.react.jsx b/app/addons/documents/queryoptions/queryoptions.react.jsx
index 6d16364..0f17383 100644
--- a/app/addons/documents/queryoptions/queryoptions.react.jsx
+++ b/app/addons/documents/queryoptions/queryoptions.react.jsx
@@ -333,58 +333,58 @@ A key value is the first parameter emitted in a map function. For example
emit("
     runQuery: function (e) {
       e.preventDefault();
 
+      this.refs.tray.hideTray();
       Actions.runQuery(store.getQueryParams());
     },
 
     render: function () {
       return (
-        <Tray id="query-options-tray">
+        <Tray id="query-options-tray" ref="tray">
           <TrayLink
             id="toggle-query"
             className="btn btn-primary pull-right query-options-btn"
             text="Query Options"
             icon="icon header-icon fonticon-gears"
           />
-
-        <TrayContents
-          className="query-options"
-          id="query-options-tray">
-
-          <form onSubmit={this.runQuery} className="js-view-query-update custom-inputs">
-            <MainFieldsView
-              includeDocs={this.state.includeDocs}
-              toggleIncludeDocs={Actions.toggleIncludeDocs}
-              showReduce={this.state.showReduce}
-              reduce={this.state.reduce}
-              toggleReduce={Actions.toggleReduce}
-              groupLevel={this.state.groupLevel}
-              updateGroupLevel={Actions.updateGroupLevel}
-            />
-            <KeySearchFields
-              key={1}
-              showByKeys={this.state.showByKeys}
-              showBetweenKeys={this.state.showBetweenKeys}
-              toggleByKeys={Actions.toggleByKeys}
-              toggleBetweenKeys={Actions.toggleBetweenKeys}
-              betweenKeys={this.state.betweenKeys}
-              updateBetweenKeys={Actions.updateBetweenKeys}
-              byKeys={this.state.byKeys}
-              updateByKeys={Actions.updateByKeys}
-             />
-            <AdditionalParams
-              updateSeq={this.state.updateSeq}
-              toggleUpdateSeq={Actions.toggleUpdateSeq}
-              descending={this.state.descending}
-              toggleDescending={Actions.toggleDescending}
-              skip={this.state.skip}
-              updateSkip={Actions.updateSkip}
-              updateLimit={Actions.updateLimit}
-              limit={this.state.limit}
-            />
-            <QueryButtons />
-          </form>
-
-        </TrayContents>
+          <TrayContents
+            className="query-options"
+            id="query-options-tray">
+
+            <form onSubmit={this.runQuery} className="js-view-query-update custom-inputs">
+              <MainFieldsView
+                includeDocs={this.state.includeDocs}
+                toggleIncludeDocs={Actions.toggleIncludeDocs}
+                showReduce={this.state.showReduce}
+                reduce={this.state.reduce}
+                toggleReduce={Actions.toggleReduce}
+                groupLevel={this.state.groupLevel}
+                updateGroupLevel={Actions.updateGroupLevel}
+              />
+              <KeySearchFields
+                key={1}
+                showByKeys={this.state.showByKeys}
+                showBetweenKeys={this.state.showBetweenKeys}
+                toggleByKeys={Actions.toggleByKeys}
+                toggleBetweenKeys={Actions.toggleBetweenKeys}
+                betweenKeys={this.state.betweenKeys}
+                updateBetweenKeys={Actions.updateBetweenKeys}
+                byKeys={this.state.byKeys}
+                updateByKeys={Actions.updateByKeys}
+               />
+              <AdditionalParams
+                updateSeq={this.state.updateSeq}
+                toggleUpdateSeq={Actions.toggleUpdateSeq}
+                descending={this.state.descending}
+                toggleDescending={Actions.toggleDescending}
+                skip={this.state.skip}
+                updateSkip={Actions.updateSkip}
+                updateLimit={Actions.updateLimit}
+                limit={this.state.limit}
+              />
+              <QueryButtons />
+            </form>
+
+          </TrayContents>
         </Tray>
       );
     }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/queryoptions/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/queryoptions/stores.js b/app/addons/documents/queryoptions/stores.js
index 71ca62d..114b707 100644
--- a/app/addons/documents/queryoptions/stores.js
+++ b/app/addons/documents/queryoptions/stores.js
@@ -148,20 +148,21 @@ function (app, FauxtonAPI, ActionTypes) {
         this._includeDocs = true;
       }
 
-      if (params.start_key) {
+      if (params.start_key || params.end_key) {
         var include = true;
 
         if (params.inclusive_end) {
-          include = params.inclusive_end === "true" ? true : false;
+          include = params.inclusive_end === 'true';
+        }
+        this._betweenKeys = { include: include };
+        if (params.start_key) {
+          this._betweenKeys.startkey = params.start_key;
+        }
+        if (params.end_key) {
+          this._betweenKeys.endkey = params.end_key;
         }
-
-        this._betweenKeys = {
-          startkey: JSON.parse(params.start_key),
-          endkey: JSON.parse(params.end_key),
-          include: include
-        };
-
         this._showBetweenKeys = true;
+
       } else if (params.keys) {
         this._byKeys = params.keys;
         this._showByKeys = true;
@@ -202,12 +203,13 @@ function (app, FauxtonAPI, ActionTypes) {
 
       if (this._showBetweenKeys) {
         var betweenKeys = this._betweenKeys;
-        _.extend(params, {
-          inclusive_end: betweenKeys.include,
-          start_key: JSON.stringify(betweenKeys.startkey),
-          end_key: JSON.stringify(betweenKeys.endkey)
-        });
-
+        params.inclusive_end = betweenKeys.include;
+        if (betweenKeys.startkey && betweenKeys.startkey !== '') {
+          params.start_key = betweenKeys.startkey;
+        }
+        if (betweenKeys.endkey && betweenKeys.endkey !== '') {
+          params.end_key = betweenKeys.endkey;
+        }
       } else if (this._showByKeys) {
         params.keys = this._byKeys;
       }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/queryoptions/tests/queryoptions.storesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/queryoptions/tests/queryoptions.storesSpec.js b/app/addons/documents/queryoptions/tests/queryoptions.storesSpec.js
index 38e5700..2a884ab 100644
--- a/app/addons/documents/queryoptions/tests/queryoptions.storesSpec.js
+++ b/app/addons/documents/queryoptions/tests/queryoptions.storesSpec.js
@@ -75,8 +75,8 @@ define([
 
         assert.deepEqual(store.getQueryParams(), {
           inclusive_end: true,
-          start_key: JSON.stringify("a"),
-          end_key: JSON.stringify("z")
+          start_key: 'a',
+          end_key: 'z'
         });
       });
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/routes-documents.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-documents.js b/app/addons/documents/routes-documents.js
index 4d78aed..09621c3 100644
--- a/app/addons/documents/routes-documents.js
+++ b/app/addons/documents/routes-documents.js
@@ -143,7 +143,7 @@ function (app, FauxtonAPI, BaseRoute, Documents, Changes, ChangesActions,
DocEdi
         IndexResultsActions.newResultsList({
           collection: collection,
           isListDeletable: true,
-          textEmptyIndex: 'No Document Created Yet!',
+          textEmptyIndex: 'No Documents Found',
           bulkCollection: Documents.BulkDeleteDocCollection
         });
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/825bbfc4/app/addons/documents/tests/nightwatch/queryOptions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/queryOptions.js b/app/addons/documents/tests/nightwatch/queryOptions.js
new file mode 100644
index 0000000..f7562dd
--- /dev/null
+++ b/app/addons/documents/tests/nightwatch/queryOptions.js
@@ -0,0 +1,36 @@
+// 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.
+
+module.exports = {
+
+  'Query Options: check startkey filters properly': function (client) {
+    /*jshint multistr: true */
+    var waitTime = client.globals.maxWaitTime,
+        newDatabaseName = client.globals.testDatabaseName,
+        baseUrl = client.globals.test_settings.launch_url;
+
+    client
+      .populateDatabase(newDatabaseName, 3)
+      .loginToGUI()
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .clickWhenVisible('#toggle-query', waitTime, false)
+      .clickWhenVisible('#betweenKeys', waitTime, false)
+      .setValue('#startkey', '"document_2"')
+      .clickWhenVisible('#query-options .btn-success')
+      .waitForElementNotPresent('#doc-list [data-id="document_1"]', waitTime, false)
+      .waitForElementPresent('#doc-list [data-id="document_2"]', waitTime, false)
+      .assert.elementPresent('#doc-list [data-id="document_2"]')
+      .waitForElementPresent('#doc-list [data-id="document_3"]', waitTime, false)
+      .assert.elementPresent('#doc-list [data-id="document_3"]')
+    .end();
+  }
+};


Mime
View raw message