You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2015/11/27 19:50:25 UTC
[1/2] fauxton commit: updated refs/heads/master to b2195ac
Repository: couchdb-fauxton
Updated Branches:
refs/heads/master a0886ac95 -> b2195ac7d
Fix for logout link showing up twice in footer
An old bug is the Logout link in the footer showing up twice. It's
a little difficult to reproduce consistently, but I've found this
works the best (Mac, chrome):
1. open dev tools
2. Login to Fauxton, notice the single "logout" link in footer.
3. click on the browser URL bar and click <enter>
4. Repeat the above until you see two "logout" links in the footer.
What's happening is the change event on Auth.session is firing
twice, each of which adds a new footer link. Seems like with
some page loads it only fires once, sometimes twice.
This ensures the link is removed prior to adding it.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/8311d62f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/8311d62f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/8311d62f
Branch: refs/heads/master
Commit: 8311d62f47bd587a98bf385d7820998a5dfd40fc
Parents: a0886ac
Author: Ben Keen <be...@gmail.com>
Authored: Tue Oct 6 20:36:44 2015 -0700
Committer: Ben Keen <be...@gmail.com>
Committed: Fri Nov 27 10:10:19 2015 -0800
----------------------------------------------------------------------
app/addons/auth/base.js | 9 ++++--
app/addons/fauxton/navigation/stores.js | 3 +-
.../navigation/tests/componentsSpec.react.jsx | 31 +++++++++++++++++++-
3 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8311d62f/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/base.js b/app/addons/auth/base.js
index 0d3a04a..a0af863 100644
--- a/app/addons/auth/base.js
+++ b/app/addons/auth/base.js
@@ -29,7 +29,7 @@ function (app, FauxtonAPI, Auth) {
title: "Login",
href: "#login",
icon: "fonticon-user",
- bottomNav: true,
+ bottomNav: true
});
Auth.session.on('change', function () {
@@ -42,7 +42,7 @@ function (app, FauxtonAPI, Auth) {
title: "Admin Party!",
href: "#createAdmin",
icon: "fonticon-user",
- bottomNav: true,
+ bottomNav: true
};
} else if (session.isLoggedIn()) {
link = {
@@ -50,9 +50,12 @@ function (app, FauxtonAPI, Auth) {
title: session.user().name,
href: "#changePassword",
icon: "fonticon-user",
- bottomNav: true,
+ bottomNav: true
};
+ // ensure the footer link is removed before adding it
+ FauxtonAPI.removeHeaderLink({id: "logout", footerNav: true});
+
FauxtonAPI.addHeaderLink({
id: 'logout',
footerNav: true,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8311d62f/app/addons/fauxton/navigation/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/navigation/stores.js b/app/addons/fauxton/navigation/stores.js
index 8ec8d0f..248522b 100644
--- a/app/addons/fauxton/navigation/stores.js
+++ b/app/addons/fauxton/navigation/stores.js
@@ -171,13 +171,14 @@ function (app, FauxtonAPI, ActionTypes) {
dispatch: function (action) {
switch (action.type) {
-
case ActionTypes.ADD_NAVBAR_LINK:
this.addLink(action.link);
break;
+
case ActionTypes.TOGGLE_NAVBAR_MENU:
this.toggleMenu();
break;
+
case ActionTypes.UPDATE_NAVBAR_LINK:
this.updateLink(action.link);
break;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8311d62f/app/addons/fauxton/navigation/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/navigation/tests/componentsSpec.react.jsx b/app/addons/fauxton/navigation/tests/componentsSpec.react.jsx
index 60bb201..cb8d468 100644
--- a/app/addons/fauxton/navigation/tests/componentsSpec.react.jsx
+++ b/app/addons/fauxton/navigation/tests/componentsSpec.react.jsx
@@ -13,9 +13,11 @@ define([
'api',
'addons/fauxton/navigation/components.react',
'addons/fauxton/navigation/actions',
+ 'core/auth',
+ 'addons/auth/base',
'testUtils',
"react"
-], function (FauxtonAPI, Views, Actions, utils, React) {
+], function (FauxtonAPI, Views, Actions, Auth, BaseAuth, utils, React) {
var assert = utils.assert;
var TestUtils = React.addons.TestUtils;
@@ -42,6 +44,33 @@ define([
});
+ it('logout link only ever appears once', function () {
+ FauxtonAPI.auth = new Auth();
+ sinon.stub(FauxtonAPI.session, 'isLoggedIn').returns(true);
+ sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(false);
+ sinon.stub(FauxtonAPI.session, 'user').returns({ name: 'test-user' });
+ BaseAuth.initialize();
+
+ var container = document.createElement('div');
+ var el = TestUtils.renderIntoDocument(<Views.NavBar />, container);
+
+ FauxtonAPI.session.trigger('change');
+
+ // confirm the logout link is present
+ var matches = React.findDOMNode(el).outerHTML.match(/Logout/);
+ assert.equal(matches.length, 1);
+
+ // now confirm there's still only a single logout link after publishing multiple
+ FauxtonAPI.session.trigger('change');
+ FauxtonAPI.session.trigger('change');
+ matches = React.findDOMNode(el).outerHTML.match(/Logout/);
+ assert.equal(matches.length, 1);
+
+ FauxtonAPI.session.isLoggedIn.restore();
+ FauxtonAPI.session.user.restore();
+ FauxtonAPI.session.isAdminParty.restore();
+ });
+
describe('CSRF info', function () {
var container, el, server;
[2/2] fauxton commit: updated refs/heads/master to b2195ac
Posted by be...@apache.org.
whitespace, single quotes
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/b2195ac7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/b2195ac7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/b2195ac7
Branch: refs/heads/master
Commit: b2195ac7de0954e0095e6cd957db58a1f1f7e8e7
Parents: 8311d62
Author: Ben Keen <be...@gmail.com>
Authored: Fri Nov 27 10:13:26 2015 -0800
Committer: Ben Keen <be...@gmail.com>
Committed: Fri Nov 27 10:13:26 2015 -0800
----------------------------------------------------------------------
app/addons/auth/base.js | 54 +++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/b2195ac7/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/base.js b/app/addons/auth/base.js
index a0af863..b8ab540 100644
--- a/app/addons/auth/base.js
+++ b/app/addons/auth/base.js
@@ -11,9 +11,9 @@
// the License.
define([
- "app",
- "api",
- "addons/auth/routes"
+ 'app',
+ 'api',
+ 'addons/auth/routes'
],
function (app, FauxtonAPI, Auth) {
@@ -25,10 +25,10 @@ function (app, FauxtonAPI, Auth) {
Auth.initialize = function () {
FauxtonAPI.addHeaderLink({
- id: "auth",
- title: "Login",
- href: "#login",
- icon: "fonticon-user",
+ id: 'auth',
+ title: 'Login',
+ href: '#login',
+ icon: 'fonticon-user',
bottomNav: true
});
@@ -38,44 +38,42 @@ function (app, FauxtonAPI, Auth) {
if (session.isAdminParty()) {
link = {
- id: "auth",
- title: "Admin Party!",
- href: "#createAdmin",
- icon: "fonticon-user",
+ id: 'auth',
+ title: 'Admin Party!',
+ href: '#createAdmin',
+ icon: 'fonticon-user',
bottomNav: true
};
} else if (session.isLoggedIn()) {
link = {
- id: "auth",
+ id: 'auth',
title: session.user().name,
- href: "#changePassword",
- icon: "fonticon-user",
+ href: '#changePassword',
+ icon: 'fonticon-user',
bottomNav: true
};
// ensure the footer link is removed before adding it
- FauxtonAPI.removeHeaderLink({id: "logout", footerNav: true});
-
+ FauxtonAPI.removeHeaderLink({ id: 'logout', footerNav: true });
FauxtonAPI.addHeaderLink({
id: 'logout',
footerNav: true,
- href: "#logout",
- title: "Logout",
- icon: "",
+ href: '#logout',
+ title: 'Logout',
+ icon: '',
className: 'logout'
});
} else {
link = {
- id: "auth",
+ id: 'auth',
title: 'Login',
- href: "#login",
- icon: "fonticon-user",
- bottomNav: true,
+ href: '#login',
+ icon: 'fonticon-user',
+ bottomNav: true
};
- FauxtonAPI.removeHeaderLink({id: "logout", footerNav: true});
+ FauxtonAPI.removeHeaderLink({ id: 'logout', footerNav: true });
}
FauxtonAPI.updateHeaderLink(link);
-
});
Auth.session.fetchUser().then(function () {
@@ -86,10 +84,10 @@ function (app, FauxtonAPI, Auth) {
var deferred = $.Deferred();
if (session.isAdminParty()) {
- session.trigger("authenticated");
+ session.trigger('authenticated');
deferred.resolve();
} else if (session.matchesRoles(roles)) {
- session.trigger("authenticated");
+ session.trigger('authenticated');
deferred.resolve();
} else {
deferred.reject();
@@ -105,7 +103,7 @@ function (app, FauxtonAPI, Auth) {
if (pattern.test(url)) {
url = url.replace('login?urlback=', '');
}
- FauxtonAPI.navigate('/login?urlback=' + url, {replace: true});
+ FauxtonAPI.navigate('/login?urlback=' + url, { replace: true });
};
FauxtonAPI.auth.registerAuth(auth);