You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/08/13 15:13:55 UTC

[1/3] git commit: updated refs/heads/move-auth-sidebar to 0b7da27

Updated Branches:
  refs/heads/move-auth-sidebar 4fa26dcca -> 0b7da27af


fixing failing test


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

Branch: refs/heads/move-auth-sidebar
Commit: b43bf99307397063341bd9cefa8d17d5fa2b9a9d
Parents: 4fa26dc
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Aug 13 10:50:50 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Aug 13 10:55:20 2013 +0200

----------------------------------------------------------------------
 .gitignore                               |  1 +
 src/fauxton/test/core/routeObjectSpec.js | 15 +++++-
 src/fauxton/test/test.config.js          | 71 ---------------------------
 3 files changed, 14 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b43bf993/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 43d4773..a022b14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -122,3 +122,4 @@ test/javascript/run_js_tests.sh
 test/local.ini
 tmp
 utils/run
+src/fauxton/test/test.config.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b43bf993/src/fauxton/test/core/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js
index 45d95ac..d043d63 100644
--- a/src/fauxton/test/core/routeObjectSpec.js
+++ b/src/fauxton/test/core/routeObjectSpec.js
@@ -1,3 +1,14 @@
+// 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([
        'api',
       'testUtils'
@@ -65,7 +76,7 @@ define([
             getViewsSpy = sinon.stub(testRouteObject,"getViews"),
             viewSpy = sinon.stub(view, "establish");
         
-        sinon.stub(view, "hasRendered").returns(false);
+        view.hasRendered = false;
         getViewsSpy.returns({'#view': view});
 
         testRouteObject.renderWith('the-route', mockLayout, 'args');
@@ -77,7 +88,7 @@ define([
             getViewsSpy = sinon.stub(testRouteObject,"getViews"),
             viewSpy = sinon.stub(view, "establish");
         
-        sinon.stub(view, "hasRendered").returns(true);
+        view.hasRendered = true;
         getViewsSpy.returns({'#view': view});
 
         testRouteObject.renderWith('the-route', mockLayout, 'args');

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b43bf993/src/fauxton/test/test.config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.js b/src/fauxton/test/test.config.js
deleted file mode 100644
index f876bb3..0000000
--- a/src/fauxton/test/test.config.js
+++ /dev/null
@@ -1,71 +0,0 @@
-// vim: set ft=javascript:
-// Set the require.js configuration for your test setup.
-require.config(
-{
-	"paths": {
-		"libs": "../assets/js/libs",
-		"plugins": "../assets/js/plugins",
-		"jquery": "../assets/js/libs/jquery",
-		"lodash": "../assets/js/libs/lodash",
-		"backbone": "../assets/js/libs/backbone",
-		"bootstrap": "../assets/js/libs/bootstrap",
-		"codemirror": "../assets/js/libs/codemirror",
-		"jshint": "../assets/js/libs/jshint",
-		"d3": "../assets/js/libs/d3",
-		"nv.d3": "../assets/js/libs/nv.d3",
-		"chai": "../test/mocha/chai",
-		"sinon-chai": "../test/mocha/sinon-chai",
-		"testUtils": "../test/mocha/testUtils"
-	},
-	"baseUrl": "../app",
-	"shim": {
-		"backbone": {
-			"deps": [
-				"lodash",
-				"jquery"
-			],
-			"exports": "Backbone"
-		},
-		"bootstrap": {
-			"deps": [
-				"jquery"
-			],
-			"exports": "Bootstrap"
-		},
-		"codemirror": {
-			"deps": [
-				"jquery"
-			],
-			"exports": "CodeMirror"
-		},
-		"jshint": {
-			"deps": [
-				"jquery"
-			],
-			"exports": "JSHINT"
-		},
-		"plugins/backbone.layoutmanager": [
-			"backbone"
-		],
-		"plugins/codemirror-javascript": [
-			"codemirror"
-		],
-		"plugins/prettify": [],
-		"plugins/jquery.form": [
-			"jquery"
-		]
-	}
-}
-);
-
-require([
-        
-           '.././test/core/routeObjectSpec.js',
-        
-           '.././app/addons/logs/tests/logSpec.js',
-        
-], function() {
-  if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
-  else { mocha.run(); }
-});
-


[2/3] git commit: updated refs/heads/move-auth-sidebar to 0b7da27

Posted by ga...@apache.org.
Fauxton: Move logout to footer bar


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

Branch: refs/heads/move-auth-sidebar
Commit: 924233e5ae6d971b774747984fb4cce8208d4a05
Parents: b43bf99
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Aug 13 14:23:14 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Aug 13 14:23:14 2013 +0200

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js                        |   6 +-
 src/fauxton/app/addons/auth/base.js             |  10 ++
 src/fauxton/app/addons/auth/resources.js        |  15 ++-
 .../app/addons/auth/templates/nav_dropdown.html |   1 -
 src/fauxton/app/api.js                          |   4 +
 src/fauxton/app/modules/fauxton/base.js         |  35 +++++-
 src/fauxton/app/templates/fauxton/nav_bar.html  |  10 ++
 src/fauxton/test/core/navbarSpec.js             | 107 +++++++++++++++++++
 8 files changed, 177 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 9cb7e2e..e9cb13c 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -214,9 +214,9 @@ module.exports = function(grunt) {
       port: 8000,
       proxy: {
         target: {
-          host: 'localhost',
-          port: 5984,
-          https: false
+          host: 'garrensmith.cloudant.com',
+          port: 443,
+          https: true
         },
         // This sets the Host header in the proxy so that you can use external
         // CouchDB instances and not have the Host set to 'localhost'

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/base.js b/src/fauxton/app/addons/auth/base.js
index 78f95e0..3502edd 100644
--- a/src/fauxton/app/addons/auth/base.js
+++ b/src/fauxton/app/addons/auth/base.js
@@ -32,6 +32,7 @@ function(app, FauxtonAPI, Auth) {
       bottomNav: true,
       establish: [FauxtonAPI.session.fetchUser()]
     });
+      
 
     var auth = function (session, roles) {
       var deferred = $.Deferred();
@@ -54,7 +55,16 @@ function(app, FauxtonAPI, Auth) {
 
     FauxtonAPI.auth.registerAuth(auth);
     FauxtonAPI.auth.registerAuthDenied(authDenied);
+
+    FauxtonAPI.session.on('change', function () {
+      if (FauxtonAPI.session.isLoggedIn()) {
+        FauxtonAPI.addHeaderLink({footerNav: true, href:"#logout", title:"Logout", icon: "", className: 'logout'});
+      } else {
+        FauxtonAPI.removeHeaderLink({title: "Logout", footerNav: true});
+      }
+    });
   };
 
+
   return Auth;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index da3acb2..dd900c5 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -72,6 +72,16 @@ function (app, FauxtonAPI) {
       return false;
     },
 
+    isLoggedIn: function () {
+      var userCtx = this.get('userCtx');
+
+      if (userCtx.name) {
+        return true;
+      }
+
+      return false;
+    },
+
     userRoles: function () {
       var user = this.user();
 
@@ -237,7 +247,7 @@ function (app, FauxtonAPI) {
       "submit #login": "login"
     },
 
-    login: function () {
+    login: function (event) {
       event.preventDefault();
 
       var that = this,
@@ -251,7 +261,7 @@ function (app, FauxtonAPI) {
       });
 
       promise.fail(function (xhr, type, msg) {
-        if (arguments.length === 3 && msg === 'Unauthorized') {
+        if (arguments.length === 3) {
           msg = FauxtonAPI.session.messages.incorrectCredentials;
         } else {
           msg = xhr;
@@ -349,6 +359,5 @@ function (app, FauxtonAPI) {
     template: "addons/auth/templates/noAccess"
   });
 
-
   return Auth;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/addons/auth/templates/nav_dropdown.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_dropdown.html b/src/fauxton/app/addons/auth/templates/nav_dropdown.html
index 880a7c1..d61c24a 100644
--- a/src/fauxton/app/addons/auth/templates/nav_dropdown.html
+++ b/src/fauxton/app/addons/auth/templates/nav_dropdown.html
@@ -20,7 +20,6 @@ the License.
 <ul class="nav nav-list">
   <li class="active" ><a data-select="change-password" id="user-change-password" href="#changePassword"> Change Password </a></li>
   <li ><a data-select="add-admin" href="#addAdmin"> Create Admins </a></li>
-  <li ><a data-select"user-logout" href="#logout"> Logout </a> </li> 
 </ul>
 </nav>
 </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 5e8e424..0a2351d 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -65,6 +65,10 @@ function(app, Fauxton) {
     app.masterLayout.navBar.addLink(link);
   };
 
+  FauxtonAPI.removeHeaderLink = function(link) {
+    app.masterLayout.navBar.removeLink(link);
+  };
+
   FauxtonAPI.Deferred = function() {
     return $.Deferred();
   };

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/modules/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index ea5f3ec..2715ab2 100644
--- a/src/fauxton/app/modules/fauxton/base.js
+++ b/src/fauxton/app/modules/fauxton/base.js
@@ -77,23 +77,28 @@ function(app, Backbone, resizeColumns) {
     ],
 
     bottomNavLinks: [],
-
-    initialize: function() {
-    },
+    footerNavLinks: [],
 
     serialize: function() {
-      return {navLinks: this.navLinks, bottomNavLinks: this.bottomNavLinks};
+      return {
+        navLinks: this.navLinks,
+        bottomNavLinks: this.bottomNavLinks,
+        footerNavLinks: this.footerNavLinks
+      };
     },
 
     addLink: function(link) {
       // link.top means it gets pushed to the top of the array,
       // link.bottomNav means it goes to the additional bottom nav
+      // link.footerNav means goes to the footer nav
       if (link.top && !link.bottomNav){
         this.navLinks.unshift(link);
       } else if (link.top && link.bottomNav){
         this.bottomNavLinks.unshift(link);
       } else if (link.bottomNav) {
         this.bottomNavLinks.push(link);
+      } else if (link.footerNav) {
+        this.footerNavLinks.push(link);
       } else {
         this.navLinks.push(link);
       }
@@ -103,6 +108,28 @@ function(app, Backbone, resizeColumns) {
       //this.render();
     },
 
+    removeLink: function (removeLink) {
+      var links = this.navlinks;
+
+      if (removeLink.bottomNav) {
+        links = this.bottomNavLinks;
+      } else if (removeLink.footerNav) {
+        links = this.footerNavLinks;
+      }
+
+      var foundIndex = -1;
+
+      _.each(links, function (link, index) {
+        if (link.title === removeLink.title) {
+          foundIndex = index;
+        }
+      });
+
+      if (foundIndex === -1) {return;}
+      links.splice(foundIndex, 1);
+      this.render();
+    },
+
     afterRender: function(){
 
       $('#primary-navbar li[data-nav-name="' + app.selectedHeader + '"]').addClass('active');

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/app/templates/fauxton/nav_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/nav_bar.html b/src/fauxton/app/templates/fauxton/nav_bar.html
index 3733775..636d176 100644
--- a/src/fauxton/app/templates/fauxton/nav_bar.html
+++ b/src/fauxton/app/templates/fauxton/nav_bar.html
@@ -39,6 +39,16 @@ the License.
       </li>
     <% }); %>
   </ul>
+  <ul id="footer-nav-links" class="nav">
+    <% _.each(footerNavLinks, function(link) { %>
+    <% if (link.view) {return;}  %>
+      <li data-nav-name= "<%= link.title %>">
+          <a class="<%= link.icon %> fonticon" href="<%= link.href %>">
+              <%= link.title %>
+          </a>
+      </li>
+    <% }); %>
+  </ul>
 </nav>
 
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/924233e5/src/fauxton/test/core/navbarSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/navbarSpec.js b/src/fauxton/test/core/navbarSpec.js
new file mode 100644
index 0000000..ec3e71f
--- /dev/null
+++ b/src/fauxton/test/core/navbarSpec.js
@@ -0,0 +1,107 @@
+// 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([
+       'modules/fauxton/base',
+      'testUtils'
+], function (Fauxton, testUtils) {
+  var assert = testUtils.assert,
+      NavBar = Fauxton.NavBar;
+
+  describe('NavBar', function () {
+
+    describe('adding links', function () {
+      var navBar;
+
+      beforeEach(function () {
+        navBar = new NavBar();
+        navBar.navLinks = [];
+        navBar.bottomNavLinks = [];
+        navBar.footerNavLinks = [];
+      });
+
+      it('Should add link to navlinks', function () {
+        navBar.addLink({href: '#/test', title: 'Test Title'});
+
+        assert.equal(navBar.navLinks.length, 1);
+        assert.equal(navBar.footerNavLinks.length, 0);
+        assert.equal(navBar.bottomNavLinks.length, 0);
+      });
+
+      it('Should add link to bottom links', function () {
+        navBar.addLink({href: '#/test', bottomNav: true, title: 'Test Title'});
+
+        assert.equal(navBar.bottomNavLinks.length, 1);
+        assert.equal(navBar.navLinks.length, 0);
+        assert.equal(navBar.footerNavLinks.length, 0);
+      });
+
+      it('Should add link to footer links', function () {
+        navBar.addLink({href: '#/test', footerNav: true, title: 'Test Title'});
+
+        assert.equal(navBar.footerNavLinks.length, 1);
+        assert.equal(navBar.bottomNavLinks.length, 0);
+        assert.equal(navBar.navLinks.length, 0);
+      });
+    });
+
+    describe('removing links', function () {
+      var navBar;
+
+      beforeEach(function () {
+        navBar = new NavBar();
+        navBar.navLinks = [];
+        navBar.bottomNavLinks = [];
+        navBar.footerNavLinks = [];
+        navBar.addLink({
+          href: '#/test', 
+          footerNav: true, 
+          title: 'Test Title Footer'
+        });
+
+        navBar.addLink({
+          href: '#/test', 
+          bottomNav: true, 
+          title: 'Test Title Bottom'
+        });
+
+        navBar.addLink({
+          href: '#/test', 
+          title: 'Test Title'
+        });
+      });
+
+      it("should remove links from list", function () {
+        navBar.removeLink({
+          title: 'Test Title Footer',
+          footerNav: true
+        });
+
+        assert.equal(navBar.footerNavLinks.length, 0);
+        assert.equal(navBar.bottomNavLinks.length, 1);
+        assert.equal(navBar.navLinks.length, 1);
+      });
+
+      it("Should call render after removing links", function () {
+        var renderSpy = sinon.stub(navBar,'render');
+
+        navBar.removeLink({
+          title: 'Test Title Footer',
+          footerNav: true
+        });
+
+        assert.ok(renderSpy.calledOnce);
+      });
+
+    });
+  });
+
+});


[3/3] git commit: updated refs/heads/move-auth-sidebar to 0b7da27

Posted by ga...@apache.org.
Fauxton: bug fix on view editor


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

Branch: refs/heads/move-auth-sidebar
Commit: 0b7da27afa06f131ce3d4422d3163a3dc7867881
Parents: 924233e
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Aug 13 15:13:36 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Aug 13 15:13:36 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/modules/documents/resources.js       | 4 ++++
 src/fauxton/app/templates/documents/view_editor.html | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/0b7da27a/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index 826b44a..0a80ad8 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -22,6 +22,10 @@ function(app, FauxtonAPI) {
   Documents.Doc = Backbone.Model.extend({
     idAttribute: "_id",
 
+    defaults: {
+      views: {}
+    },
+
     url: function(context) {
       if (context === "app") {
         return this.getDatabase().url("app") + "/" + this.safeID();

http://git-wip-us.apache.org/repos/asf/couchdb/blob/0b7da27a/src/fauxton/app/templates/documents/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html
index ed61903..98b2f6c 100644
--- a/src/fauxton/app/templates/documents/view_editor.html
+++ b/src/fauxton/app/templates/documents/view_editor.html
@@ -48,7 +48,7 @@ the License.
                         </select>
                       </div>
                     </div>
-                    <div id="new-ddoc-section" class="span5" style="display:none">
+                    <div id="new-ddoc-section" class="span5 offset1" style="display:none">
                       <label class="control-label" for="new-ddoc"> _design/ </label>
                       <div class="controls">
                         <input type="text" id="new-ddoc" placeholder="newDesignDoc">