You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2016/04/21 19:38:46 UTC

[2/2] fauxton commit: updated refs/heads/master to 3f46050

show conflicts / conflict-count in table-view

display a small indicator in table view, given a doc has conflicts

PR: #670
PR-URL: https://github.com/apache/couchdb-fauxton/pull/670
Reviewed-By: Benjamin Keen <be...@gmail.com>


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

Branch: refs/heads/master
Commit: 319ce9924f60adad6f9e61af363a43f51ad70171
Parents: 978ae69
Author: Robert Kowalski <ro...@apache.org>
Authored: Tue Mar 15 14:37:37 2016 +0000
Committer: Robert Kowalski <ro...@apache.org>
Committed: Thu Apr 21 19:38:38 2016 +0200

----------------------------------------------------------------------
 .../documents/assets/less/index-results.less    |  5 +-
 app/addons/documents/header/header.actions.js   |  2 +
 .../index-results.components.react.jsx          | 37 +++++++---
 .../tests/nightwatch/tableViewConflicts.js      | 37 ++++++++++
 .../populateDatabaseWithConflicts.js            | 73 ++++++++++++++++++++
 5 files changed, 144 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/319ce992/app/addons/documents/assets/less/index-results.less
----------------------------------------------------------------------
diff --git a/app/addons/documents/assets/less/index-results.less b/app/addons/documents/assets/less/index-results.less
index dc46c6d..df11f72 100644
--- a/app/addons/documents/assets/less/index-results.less
+++ b/app/addons/documents/assets/less/index-results.less
@@ -102,8 +102,11 @@
   .tableview-checkbox-cell input {
     margin: 0 0 0 8px;
   }
+  .tableview-conflict {
+    color: #FF0000;
+  }
   .tableview-el-last {
-    width: 50px;
+    width: 75px;
   }
   .tableview-el-copy {
     width: 35px;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/319ce992/app/addons/documents/header/header.actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/header/header.actions.js b/app/addons/documents/header/header.actions.js
index fcc7e7f..282d20b 100644
--- a/app/addons/documents/header/header.actions.js
+++ b/app/addons/documents/header/header.actions.js
@@ -26,8 +26,10 @@ function (app, FauxtonAPI, ActionTypes, ActionsQueryOptions) {
 
       if (state) {
         delete params.include_docs;
+        delete params.conflicts;
       } else {
         params.include_docs = true;
+        params.conflicts = true;
       }
 
       app.utils.localStorageSet('include_docs_bulkdocs', bulkDocsCollection.toJSON());

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/319ce992/app/addons/documents/index-results/index-results.components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-results/index-results.components.react.jsx b/app/addons/documents/index-results/index-results.components.react.jsx
index 612eeb4..6a88da3 100644
--- a/app/addons/documents/index-results/index-results.components.react.jsx
+++ b/app/addons/documents/index-results/index-results.components.react.jsx
@@ -132,21 +132,40 @@ function (app, FauxtonAPI, React, Stores, Actions, Components, Documents, Fauxto
       );
     },
 
-    getAttachmentRow: function (el) {
+    getAdditionalInfoRow: function (el) {
       var attachmentCount = Object.keys(el._attachments || {}).length;
-      var paperClip = null;
-      var text = null;
+      var attachmentIndicator = null;
+      var textAttachments = null;
+
+      var conflictCount = Object.keys(el._conflicts || {}).length;
+      var conflictIndicator = null;
+      var textConflicts = null;
+
 
       if (attachmentCount) {
-        text = attachmentCount === 1 ? attachmentCount + ' Attachment' : attachmentCount + ' Attachments';
-        paperClip = (
-          <div><i className="icon fonticon-paperclip"></i> {attachmentCount}</div>
+        textAttachments = attachmentCount === 1 ? attachmentCount + ' Attachment' : attachmentCount + ' Attachments';
+        attachmentIndicator = (
+          <div style={{display: 'inline', marginLeft: '5px'}} title={textAttachments}>
+            <i className="icon fonticon-paperclip"></i>{attachmentCount}
+          </div>
+        );
+      }
+
+      if (conflictCount) {
+        textConflicts = conflictCount === 1 ? conflictCount + ' Conflict' : conflictCount + ' Conflicts';
+        conflictIndicator = (
+          <div className="tableview-conflict" data-conflicts-indicator style={{display: 'inline'}} title={textConflicts}>
+            <i
+              style={{fontSize: '17px'}}
+              className="icon icon-code-fork"></i>{conflictCount}
+          </div>
         );
       }
 
       return (
-        <td title={text} className="tableview-el-last">
-          {paperClip}
+        <td className="tableview-el-last">
+          {conflictIndicator}
+          {attachmentIndicator}
         </td>
       );
     },
@@ -182,7 +201,7 @@ function (app, FauxtonAPI, React, Stores, Actions, Components, Documents, Fauxto
           {this.getCopyButton(docContent)}
           {this.maybeGetSpecialField(el, i)}
           {this.getRowContents(el, i)}
-          {this.getAttachmentRow(docContent)}
+          {this.getAdditionalInfoRow(docContent)}
         </tr>
       );
     }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/319ce992/app/addons/documents/tests/nightwatch/tableViewConflicts.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/tableViewConflicts.js b/app/addons/documents/tests/nightwatch/tableViewConflicts.js
new file mode 100644
index 0000000..c0be7c3
--- /dev/null
+++ b/app/addons/documents/tests/nightwatch/tableViewConflicts.js
@@ -0,0 +1,37 @@
+// 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 = {
+
+  'Shows how many conflicts have appeared': function (client) {
+    var waitTime = client.globals.maxWaitTime,
+        newDatabaseName = client.globals.testDatabaseName,
+        baseUrl = client.globals.test_settings.launch_url;
+
+    client
+      .populateDatabaseWithConflicts(newDatabaseName)
+      .checkForDocumentCreated('outfit1')
+      .loginToGUI()
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+
+      .clickWhenVisible('.alternative-header .two-sides-toggle-button button:last-child')
+      .waitForElementVisible('.table', client.globals.maxWaitTime, false)
+
+      .clickWhenVisible('.control-toggle-include-docs')
+
+      .waitForElementVisible('.table-container-autocomplete', client.globals.maxWaitTime, false)
+
+      .assert.visible('.table [data-conflicts-indicator="true"]')
+
+      .end();
+  }
+};

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/319ce992/test/nightwatch_tests/custom-commands/populateDatabaseWithConflicts.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/populateDatabaseWithConflicts.js b/test/nightwatch_tests/custom-commands/populateDatabaseWithConflicts.js
new file mode 100644
index 0000000..b252d14
--- /dev/null
+++ b/test/nightwatch_tests/custom-commands/populateDatabaseWithConflicts.js
@@ -0,0 +1,73 @@
+// 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.
+
+var util = require('util'),
+    events = require('events'),
+    helpers = require('../helpers/helpers.js'),
+    request = require('request');
+
+function PopulateDatabaseWithConflicts () {
+  events.EventEmitter.call(this);
+}
+
+util.inherits(PopulateDatabaseWithConflicts, events.EventEmitter);
+
+PopulateDatabaseWithConflicts.prototype.command = function (databaseName) {
+  var nano = helpers.getNanoInstance(),
+      database = nano.use(databaseName);
+
+  database.insert({
+    hat: 'flamingo'
+  }, 'outfit1', function () {
+    createConflictingDoc(null, function () {
+      this.emit('complete');
+    }.bind(this));
+  }.bind(this));
+
+  function createConflictingDoc (err, cb) {
+    request({
+      uri: helpers.test_settings.db_url + '/' + databaseName + '/conflictingdoc',
+      method: 'PUT',
+      json: true,
+      body: {
+        id: 'conflictingdoc',
+        rocko: 'dances'
+      }
+    }, function (err, res, body) {
+      if (err) {
+        console.log(
+          'Error in nano populateDatabase Function: ' + err.message
+        );
+      }
+      request({
+        uri: helpers.test_settings.db_url + '/' + databaseName + '/conflictingdoc?new_edits=false',
+        method: 'PUT',
+        json: true,
+        body: {
+          _rev: '4-afae890a0310210db079b0f49fb2569d',
+          rocko: 'jumps'
+        }
+      }, function (err, res, body) {
+        if (err) {
+          console.log('Error in nano populateDatabase Function: ' +
+            err.message);
+        }
+
+        cb && cb();
+      });
+    });
+  }
+
+  return this;
+};
+
+module.exports = PopulateDatabaseWithConflicts;