couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [3/3] fauxton commit: updated refs/heads/master to 3610716
Date Sat, 15 Aug 2015 17:11:53 GMT
fix removeHeaderLink function

`_.first` returns the first element of an array.

PR: #497
PR-URL: https://github.com/apache/couchdb-fauxton/pull/497
Reviewed-By: garren smith <garren.smith@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/4abcbe42
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/4abcbe42
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/4abcbe42

Branch: refs/heads/master
Commit: 4abcbe420d1564c42372ee55db1c4828b4e67ed5
Parents: 438dd32
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Wed Aug 12 19:34:03 2015 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Sat Aug 15 19:11:39 2015 +0200

----------------------------------------------------------------------
 app/addons/fauxton/navigation/stores.js         |  5 +--
 .../fauxton/navigation/tests/storeSpec.js       | 32 +++++++++++++++++++-
 2 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4abcbe42/app/addons/fauxton/navigation/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/navigation/stores.js b/app/addons/fauxton/navigation/stores.js
index 3b7fb7b..a5949b7 100644
--- a/app/addons/fauxton/navigation/stores.js
+++ b/app/addons/fauxton/navigation/stores.js
@@ -58,7 +58,8 @@ function (app, FauxtonAPI, ActionTypes) {
       var links = this.getLinkSection(removeLink);
       var indexOf = 0;
 
-      var res = _.first(links, function (link) {
+      var res = _.filter(links, function (link) {
+
         if (link.id === removeLink.id) {
           return true;
         }
@@ -67,7 +68,7 @@ function (app, FauxtonAPI, ActionTypes) {
         return false;
       });
 
-      if (!res) { return; }
+      if (!res.length) { return; }
 
       links.splice(indexOf, 1);
     },

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4abcbe42/app/addons/fauxton/navigation/tests/storeSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/navigation/tests/storeSpec.js b/app/addons/fauxton/navigation/tests/storeSpec.js
index e4637ec..7823367 100644
--- a/app/addons/fauxton/navigation/tests/storeSpec.js
+++ b/app/addons/fauxton/navigation/tests/storeSpec.js
@@ -122,6 +122,36 @@ define([
         assert.equal(navBarStore.getNavLinks().length, 0);
       });
 
+      it('remove link from list', function () {
+        function addLink (id) {
+          FauxtonAPI.dispatch({
+            type: 'ADD_NAVBAR_LINK',
+            link: {
+              id: id,
+              footerNav: true
+            }
+          });
+        }
+        function removeLink () {
+          FauxtonAPI.dispatch({
+            type: 'REMOVE_NAVBAR_LINK',
+            link: {
+              id: 'remove_link3',
+              footerNav: true
+            }
+          });
+        }
+        addLink('remove_link1');
+        addLink('remove_link2');
+        addLink('remove_link3');
+
+        removeLink();
+        removeLink();
+        removeLink();
+
+        assert.equal(navBarStore.getFooterNavLinks().length, 2);
+      });
+
       it('from bottom nav links', function () {
         var link = {
           id: 'remove_link',
@@ -140,7 +170,7 @@ define([
         assert.equal(navBarStore.getBottomNavLinks().length, 1);
       });
 
-      it('from bottom nav links', function () {
+      it('from footer nav links', function () {
         var link = {
           id: 'remove_link',
           footerNav: true


Mime
View raw message