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 0e1333b
Date Mon, 26 Oct 2015 20:31:50 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 437219f90 -> 0e1333bf9


Sidebar automatically updates after design doc deleted

After deleting a design doc, the sidebar didn't refresh, so you'd
see the old data until the next repaint. This explicitly updates
the sidebar after all document deletes (React will handle the
nasty diffing for us, so it'll be performant).


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

Branch: refs/heads/master
Commit: 0e1333bf919641266cb68fb370ebae9def6e30dd
Parents: 437219f
Author: Ben Keen <ben.keen@gmail.com>
Authored: Tue Oct 13 14:37:43 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Mon Oct 26 12:59:37 2015 -0700

----------------------------------------------------------------------
 app/addons/documents/index-results/actions.js   |  7 +--
 .../tests/index-results.actionsSpec.js          | 10 +++-
 app/addons/documents/sidebar/actions.js         |  4 ++
 app/addons/documents/sidebar/actiontypes.js     |  5 +-
 app/addons/documents/sidebar/stores.js          |  4 ++
 .../tests/nightwatch/deletesDocuments.js        | 49 ++++++++++++++++++++
 6 files changed, 72 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/index-results/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-results/actions.js b/app/addons/documents/index-results/actions.js
index ea22f9a..4fab529 100644
--- a/app/addons/documents/index-results/actions.js
+++ b/app/addons/documents/index-results/actions.js
@@ -15,10 +15,10 @@ define([
   'api',
   'addons/documents/index-results/actiontypes',
   'addons/documents/index-results/stores',
-  'addons/documents/header/header.actions',
-  'addons/documents/resources'
+  'addons/documents/resources',
+  'addons/documents/sidebar/actions'
 ],
-function (app, FauxtonAPI, ActionTypes, Stores, HeaderActions, Documents) {
+function (app, FauxtonAPI, ActionTypes, Stores, Documents, SidebarActions) {
   var indexResultsStore = Stores.indexResultsStore;
 
   var errorMessage = function (ids) {
@@ -198,6 +198,7 @@ function (app, FauxtonAPI, ActionTypes, Stores, HeaderActions, Documents)
{
       .always(function () {
         reloadResultsList().then(function () {
           selectListOfDocs(selectedIds);
+          SidebarActions.refresh();
         });
       });
     }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/index-results/tests/index-results.actionsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-results/tests/index-results.actionsSpec.js b/app/addons/documents/index-results/tests/index-results.actionsSpec.js
index 97b892a..719cfb9 100644
--- a/app/addons/documents/index-results/tests/index-results.actionsSpec.js
+++ b/app/addons/documents/index-results/tests/index-results.actionsSpec.js
@@ -15,8 +15,9 @@ define([
   'addons/documents/index-results/actions',
   'addons/documents/index-results/stores',
   'addons/documents/resources',
-  'testUtils',
-], function (FauxtonAPI, Actions, Stores, Documents, testUtils) {
+  'addons/documents/sidebar/actions',
+  'testUtils'
+], function (FauxtonAPI, Actions, Stores, Documents, SidebarActions, testUtils) {
   var assert = testUtils.assert;
   var restore = testUtils.restore;
   var store = Stores.indexResultsStore;
@@ -75,6 +76,7 @@ define([
       restore(FauxtonAPI.addNotification);
       restore(Actions.reloadResultsList);
       restore(Actions.selectListOfDocs);
+      restore(SidebarActions.refresh);
     });
 
     it('doesn\'t delete if user denies confirmation', function () {
@@ -100,6 +102,7 @@ define([
 
     it('on success notifies all deleted', function () {
       var spy = sinon.spy(FauxtonAPI, 'addNotification');
+      var sidebarSpy = sinon.spy(SidebarActions, 'refresh');
       var promise = FauxtonAPI.Deferred();
       var ids = {
           errorIds: []
@@ -120,10 +123,12 @@ define([
       Actions.deleteSelected();
 
       assert.ok(spy.calledOnce);
+      assert.ok(sidebarSpy.calledOnce);
     });
 
     it('on success with some failed ids, re-selects failed', function () {
       var spy = sinon.spy(Actions, 'selectListOfDocs');
+      var sidebarSpy = sinon.spy(SidebarActions, 'refresh');
 
       var reloadResultsListStub = sinon.stub(Actions, 'reloadResultsList');
       var stubPromise = FauxtonAPI.Deferred();
@@ -146,6 +151,7 @@ define([
 
       Actions.deleteSelected();
       assert.ok(spy.calledWith(ids.errorIds));
+      assert.ok(sidebarSpy.calledOnce);
     });
 
     it('on failure notifies failed', function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/sidebar/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/sidebar/actions.js b/app/addons/documents/sidebar/actions.js
index ca84585..4dbd83f 100644
--- a/app/addons/documents/sidebar/actions.js
+++ b/app/addons/documents/sidebar/actions.js
@@ -47,6 +47,10 @@ function (app, FauxtonAPI, ActionTypes, Stores) {
         type: ActionTypes.SIDEBAR_SET_SELECTED_TAB,
         tab: tab
       });
+    },
+
+    refresh: function () {
+      FauxtonAPI.dispatch({ type: ActionTypes.SIDEBAR_REFRESH });
     }
   };
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/sidebar/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/sidebar/actiontypes.js b/app/addons/documents/sidebar/actiontypes.js
index c1d6af5..157c3fa 100644
--- a/app/addons/documents/sidebar/actiontypes.js
+++ b/app/addons/documents/sidebar/actiontypes.js
@@ -14,7 +14,8 @@ define([], function () {
   return {
     SIDEBAR_SET_SELECTED_TAB: 'SIDEBAR_SET_SELECTED_TAB',
     SIDEBAR_NEW_OPTIONS: 'SIDEBAR_NEW_OPTIONS',
-    SIDEBAR_TOGGLE_DESIGN_DOC: 'SIDEBAR_TOGGLE_CONTENT',
-    SIDEBAR_FETCHING: 'SIDEBAR_FETCHING'
+    SIDEBAR_TOGGLE_CONTENT: 'SIDEBAR_TOGGLE_CONTENT',
+    SIDEBAR_FETCHING: 'SIDEBAR_FETCHING',
+    SIDEBAR_REFRESH: 'SIDEBAR_REFRESH'
   };
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/sidebar/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/sidebar/stores.js b/app/addons/documents/sidebar/stores.js
index 0208257..8fdbefd 100644
--- a/app/addons/documents/sidebar/stores.js
+++ b/app/addons/documents/sidebar/stores.js
@@ -136,6 +136,10 @@ function (app, FauxtonAPI, ActionTypes) {
           this._loading = true;
           this.triggerChange();
         break;
+        case ActionTypes.SIDEBAR_REFRESH:
+          this.triggerChange();
+        break;
+
         default:
         return;
         // do nothing

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0e1333bf/app/addons/documents/tests/nightwatch/deletesDocuments.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/deletesDocuments.js b/app/addons/documents/tests/nightwatch/deletesDocuments.js
index 2da8b26..edee01c 100644
--- a/app/addons/documents/tests/nightwatch/deletesDocuments.js
+++ b/app/addons/documents/tests/nightwatch/deletesDocuments.js
@@ -50,5 +50,54 @@ module.exports = {
           'Checking if new documents no longer shows up in _all_docs.');
       })
     .end();
+  },
+
+  'Deleting a new Design Doc automatically removes it from the sidebar': function (client)
{
+    var waitTime = client.globals.maxWaitTime;
+    var newDatabaseName = client.globals.testDatabaseName;
+    var baseUrl = client.globals.test_settings.launch_url;
+
+    /*jshint multistr: true */
+    client
+      .loginToGUI()
+      .populateDatabase(newDatabaseName)
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementPresent('#header-dropdown-menu', waitTime, false)
+      .waitForElementPresent('#header-dropdown-menu a', waitTime, false)
+      .clickWhenVisible('#header-dropdown-menu a', waitTime, false)
+      .waitForElementPresent('#header-dropdown-menu  a[href*="new_view"]', waitTime, false)
+      .clickWhenVisible('#header-dropdown-menu a[href*="new_view"]', waitTime, false)
+      .waitForElementPresent('.editor-wrapper', waitTime, false)
+      .waitForElementPresent('#new-ddoc', waitTime, false)
+      .setValue('#new-ddoc', 'sidebar-update')
+      .clearValue('#index-name')
+      .setValue('#index-name', 'sidebar-update-index')
+      .execute('\
+        var editor = ace.edit("map-function");\
+        editor.getSession().setValue("function (doc) { emit(\'1\'); }");\
+      ')
+      .execute('$("#save-view")[0].scrollIntoView();')
+      .waitForElementPresent('#save-view', waitTime, false)
+      .clickWhenVisible('#save-view', waitTime, false)
+      .waitForElementVisible('#global-notifications .alert.alert-success', waitTime, false)
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementPresent('.prettyprint', waitTime, false)
+      .waitForElementNotPresent('.loading-lines', waitTime, false)
+
+      // confirm the design doc appears in the sidebar
+      .waitForElementPresent('#sidebar-content span[title="_design/sidebar-update"]', waitTime,
false)
+      .waitForElementPresent('label[for="checkbox-_design/sidebar-update"]', waitTime, false)
+      .execute('$("label[for=\'checkbox-_design/sidebar-update\']")[0].scrollIntoView();')
+      .clickWhenVisible('label[for="checkbox-_design/sidebar-update"]', waitTime, false)
+
+      .waitForElementPresent('.bulk-action-component-selector-group .fonticon-trash', waitTime,
false)
+      .execute('$(".bulk-action-component-selector-group .fonticon-trash")[0].scrollIntoView();')
+      .clickWhenVisible('.bulk-action-component-selector-group .fonticon-trash')
+      .acceptAlert()
+
+      // now confirm it's gone
+      .waitForElementNotPresent('#sidebar-content span[title="_design/sidebar-update"]',
waitTime, false)
+      .end();
   }
+
 };


Mime
View raw message