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 2015/11/20 14:56:03 UTC
[1/3] fauxton commit: updated refs/heads/master to f4ff1c5
Repository: couchdb-fauxton
Updated Branches:
refs/heads/master 915ca9463 -> f4ff1c5f6
cors: Fix timing issue for slow connections
If the conenction was slow you could enabble cors and change
options, but cors was not enabled yet in the backend
PR: #578
PR-URL: https://github.com/apache/couchdb-fauxton/pull/578
Reviewed-By: Michelle Phung <mi...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/f4ff1c5f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/f4ff1c5f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/f4ff1c5f
Branch: refs/heads/master
Commit: f4ff1c5f6a79c532e4d1479d50a21982c62aa0d0
Parents: 0500da8
Author: Robert Kowalski <ro...@apache.org>
Authored: Wed Nov 18 13:51:26 2015 +0100
Committer: Robert Kowalski <ro...@apache.org>
Committed: Fri Nov 20 14:55:46 2015 +0100
----------------------------------------------------------------------
app/addons/cors/actions.js | 16 ++++++++++++++--
app/addons/cors/actiontypes.js | 3 ++-
app/addons/cors/components.react.jsx | 13 ++++++++++---
app/addons/cors/stores.js | 14 ++++++++++++++
app/addons/cors/tests/componentsSpec.react.jsx | 18 +++++++++++++++++-
5 files changed, 57 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f4ff1c5f/app/addons/cors/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/actions.js b/app/addons/cors/actions.js
index 1a35f78..22e2188 100644
--- a/app/addons/cors/actions.js
+++ b/app/addons/cors/actions.js
@@ -140,7 +140,16 @@ define([
return origins.join(',');
},
+ toggleLoadingBarsToEnabled: function (state) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.CORS_SET_IS_LOADING,
+ isLoading: state
+ });
+ },
+
saveCors: function (options) {
+ this.toggleLoadingBarsToEnabled(true);
+
var promises = [];
promises.push(this.saveEnableCorsToHttpd(options.enableCors, options.node));
@@ -158,13 +167,16 @@ define([
clear: true
});
- }, function () {
+ this.toggleLoadingBarsToEnabled(false);
+
+ }.bind(this), function () {
FauxtonAPI.addNotification({
msg: 'Error! Could not save your CORS settings. Please try again.',
type: 'error',
clear: true
});
- });
+ this.toggleLoadingBarsToEnabled(false);
+ }.bind(this));
}
};
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f4ff1c5f/app/addons/cors/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/actiontypes.js b/app/addons/cors/actiontypes.js
index 7182624..215dbff 100644
--- a/app/addons/cors/actiontypes.js
+++ b/app/addons/cors/actiontypes.js
@@ -17,6 +17,7 @@ define([], function () {
CORS_IS_ALL_ORIGINS: 'CORS_IS_ALL_ORIGINS',
CORS_DELETE_ORIGIN: 'CORS_DELETE_ORIGIN',
CORS_UPDATE_ORIGIN: 'CORS_UPDATE_ORIGIN',
- CORS_METHOD_CHANGE: 'CORS_METHOD_CHANGE'
+ CORS_METHOD_CHANGE: 'CORS_METHOD_CHANGE',
+ CORS_SET_IS_LOADING: 'CORS_SET_IS_LOADING'
};
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f4ff1c5f/app/addons/cors/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/cors/components.react.jsx b/app/addons/cors/components.react.jsx
index 71f9382..6f6bf9f 100644
--- a/app/addons/cors/components.react.jsx
+++ b/app/addons/cors/components.react.jsx
@@ -16,8 +16,10 @@ define([
"react",
"addons/cors/stores",
"addons/cors/resources",
- "addons/cors/actions"
-], function (app, FauxtonAPI, React, Stores, Resources, Actions) {
+ "addons/cors/actions",
+ 'addons/components/react-components.react'
+
+], function (app, FauxtonAPI, React, Stores, Resources, Actions, ReactComponents) {
var corsStore = Stores.corsStore;
var validateOrigin = function (origin) {
@@ -232,7 +234,8 @@ define([
isAllOrigins: corsStore.isAllOrigins(),
configChanged: corsStore.hasConfigChanged(),
shouldSaveChange: corsStore.shouldSaveChange(),
- node: corsStore.getNode()
+ node: corsStore.getNode(),
+ isLoading: corsStore.getIsLoading()
};
},
@@ -304,6 +307,10 @@ define([
var isVisible = _.all([this.state.corsEnabled, !this.state.isAllOrigins]);
var className = this.state.corsEnabled ? 'collapsing-container' : '';
+ if (this.state.isLoading) {
+ return (<ReactComponents.LoadLines />);
+ }
+
return (
<div className="cors-page">
<header id="cors-header">
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f4ff1c5f/app/addons/cors/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/stores.js b/app/addons/cors/stores.js
index bd33447..0d083cc 100644
--- a/app/addons/cors/stores.js
+++ b/app/addons/cors/stores.js
@@ -23,6 +23,7 @@ define([
this._configChanged = false;
this._shouldSaveChange = false;
this._node = options.node;
+ this._isLoading = false;
},
shouldSaveChange: function () {
@@ -41,6 +42,15 @@ define([
this._configChanged = false;
},
+ setIsLoading: function (state) {
+ this._isLoading = state;
+ this._shouldSaveChange = false;
+ },
+
+ getIsLoading: function () {
+ return this._isLoading;
+ },
+
isEnabled: function () {
return this._isEnabled;
},
@@ -127,6 +137,10 @@ define([
this.setConfigChanged();
break;
+ case ActionTypes.CORS_SET_IS_LOADING:
+ this.setIsLoading(action.isLoading);
+ break;
+
default:
return;
}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/f4ff1c5f/app/addons/cors/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/cors/tests/componentsSpec.react.jsx b/app/addons/cors/tests/componentsSpec.react.jsx
index c2f3cdd..68dd301 100644
--- a/app/addons/cors/tests/componentsSpec.react.jsx
+++ b/app/addons/cors/tests/componentsSpec.react.jsx
@@ -42,7 +42,9 @@ define([
});
afterEach(function () {
- corsEl.save.restore();
+ utils.restore(Actions.toggleLoadingBarsToEnabled);
+ utils.restore(corsEl.save);
+
React.unmountComponentAtNode(container);
window.confirm.restore && window.confirm.restore();
});
@@ -58,6 +60,7 @@ define([
it('does not confirm for selected origins are emtpy for disabled cors change', function () {
var spy = sinon.stub(window, 'confirm');
+ sinon.stub(Actions, 'toggleLoadingBarsToEnabled');
spy.returns(false);
corsEl.state.corsEnabled = true;
corsEl.state.isAllOrigins = false;
@@ -77,13 +80,26 @@ define([
it('does not confirm all origins change if selected origins are emtpy', function () {
var spy = sinon.stub(window, 'confirm');
+ sinon.stub(Actions, 'toggleLoadingBarsToEnabled');
spy.returns(false);
corsEl.state.corsEnabled = true;
corsEl.state.isAllOrigins = false;
corsEl.state.origins = [];
corsEl.originChange(true);
+
assert.notOk(spy.calledOnce);
});
+
+ it('shows loading bars', function () {
+ Actions.toggleLoadingBarsToEnabled(true);
+ assert.ok($(corsEl.getDOMNode()).hasClass('loading-lines'));
+ });
+
+ it('hides loading bars', function () {
+ Actions.toggleLoadingBarsToEnabled(false);
+
+ assert.notOk($(corsEl.getDOMNode()).hasClass('loading-lines'));
+ });
});
describe('OriginInput', function () {
[2/3] fauxton commit: updated refs/heads/master to f4ff1c5
Posted by ro...@apache.org.
cors: remove dead code
PR: #578
PR-URL: https://github.com/apache/couchdb-fauxton/pull/578
Reviewed-By: Michelle Phung <mi...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/0500da8a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/0500da8a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/0500da8a
Branch: refs/heads/master
Commit: 0500da8ab2c0cd96d830d1419fc5d309d3e68d22
Parents: 270183b
Author: Robert Kowalski <ro...@apache.org>
Authored: Wed Nov 18 12:53:48 2015 +0100
Committer: Robert Kowalski <ro...@apache.org>
Committed: Fri Nov 20 14:55:46 2015 +0100
----------------------------------------------------------------------
app/addons/cors/actiontypes.js | 4 +---
app/addons/cors/stores.js | 19 ++-----------------
app/addons/cors/tests/actionsSpecs.js | 24 ------------------------
3 files changed, 3 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0500da8a/app/addons/cors/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/actiontypes.js b/app/addons/cors/actiontypes.js
index 7e4916b..7182624 100644
--- a/app/addons/cors/actiontypes.js
+++ b/app/addons/cors/actiontypes.js
@@ -17,8 +17,6 @@ define([], function () {
CORS_IS_ALL_ORIGINS: 'CORS_IS_ALL_ORIGINS',
CORS_DELETE_ORIGIN: 'CORS_DELETE_ORIGIN',
CORS_UPDATE_ORIGIN: 'CORS_UPDATE_ORIGIN',
- CORS_METHOD_CHANGE: 'CORS_METHOD_CHANGE',
- CORS_SAVING: 'CORS_SAVING',
- CORS_SAVED: 'CORS_SAVED'
+ CORS_METHOD_CHANGE: 'CORS_METHOD_CHANGE'
};
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0500da8a/app/addons/cors/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/stores.js b/app/addons/cors/stores.js
index bd36093..bd33447 100644
--- a/app/addons/cors/stores.js
+++ b/app/addons/cors/stores.js
@@ -100,53 +100,38 @@ define([
switch (action.type) {
case ActionTypes.EDIT_CORS:
this.editCors(action.options);
- this.triggerChange();
break;
case ActionTypes.TOGGLE_ENABLE_CORS:
this.toggleEnableCors();
this.setConfigChanged();
- this.triggerChange();
break;
case ActionTypes.CORS_ADD_ORIGIN:
this.addOrigin(action.origin);
this.setConfigChanged();
- this.triggerChange();
break;
case ActionTypes.CORS_IS_ALL_ORIGINS:
this.originChange(action.isAllOrigins);
this.setConfigChanged();
- this.triggerChange();
break;
case ActionTypes.CORS_DELETE_ORIGIN:
this.deleteOrigin(action.origin);
this.setConfigChanged();
- this.triggerChange();
break;
case ActionTypes.CORS_UPDATE_ORIGIN:
this.updateOrigin(action.updatedOrigin, action.originalOrigin);
this.setConfigChanged();
- this.triggerChange();
- break;
-
- case ActionTypes.CORS_SAVING:
- this.saving();
- this.triggerChange();
- break;
-
- case ActionTypes.CORS_SAVED:
- this.setConfigSaved();
- this.savingDone();
- this.triggerChange();
break;
default:
return;
}
+
+ this.triggerChange();
}
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0500da8a/app/addons/cors/tests/actionsSpecs.js
----------------------------------------------------------------------
diff --git a/app/addons/cors/tests/actionsSpecs.js b/app/addons/cors/tests/actionsSpecs.js
index 9b74634..43d4ba1 100644
--- a/app/addons/cors/tests/actionsSpecs.js
+++ b/app/addons/cors/tests/actionsSpecs.js
@@ -108,30 +108,6 @@ define([
FauxtonAPI.addNotification.restore();
});
- it('dispatches CORS_SAVED', function () {
- var stub = sinon.stub(FauxtonAPI, 'when');
- var called = false;
- var promise = FauxtonAPI.Deferred();
- promise.resolve();
- stub.returns(promise);
-
- FauxtonAPI.dispatcher.register(function (actions) {
-
- if (actions.type === 'CORS_SAVED') {
- called = true;
- }
-
- });
-
- Actions.saveCors({
- enableCors: true,
- origins: ['https://testdomain.com']
- });
-
- assert.ok(called);
- FauxtonAPI.when.restore();
- });
-
});
describe('Sanitize origins', function () {
[3/3] fauxton commit: updated refs/heads/master to f4ff1c5
Posted by ro...@apache.org.
cors: use i18n system for changeable strings
PR: #578
PR-URL: https://github.com/apache/couchdb-fauxton/pull/578
Reviewed-By: Michelle Phung <mi...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/270183b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/270183b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/270183b3
Branch: refs/heads/master
Commit: 270183b3e5e828eadcce512b2a265e6ae9ff547c
Parents: 915ca94
Author: Robert Kowalski <ro...@apache.org>
Authored: Tue Nov 17 15:14:00 2015 +0100
Committer: Robert Kowalski <ro...@apache.org>
Committed: Fri Nov 20 14:55:46 2015 +0100
----------------------------------------------------------------------
app/addons/cors/components.react.jsx | 23 ++++-------------------
i18n.json.default | 4 +++-
2 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/270183b3/app/addons/cors/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/cors/components.react.jsx b/app/addons/cors/components.react.jsx
index 13d20af..71f9382 100644
--- a/app/addons/cors/components.react.jsx
+++ b/app/addons/cors/components.react.jsx
@@ -11,12 +11,13 @@
// the License.
define([
+ "app",
"api",
"react",
"addons/cors/stores",
"addons/cors/resources",
"addons/cors/actions"
-], function (FauxtonAPI, React, Stores, Resources, Actions) {
+], function (app, FauxtonAPI, React, Stores, Resources, Actions) {
var corsStore = Stores.corsStore;
var validateOrigin = function (origin) {
@@ -259,14 +260,7 @@ define([
enableCorsChange: function (event) {
if (this.state.corsEnabled && !_.isEmpty(this.state.origins) ) {
- var msg = FauxtonAPI.getExtensions('cors:disableCorsPrompt');
- if (_.isUndefined(msg[0])) {
- msg = 'Are you sure? Disabling CORS will overwrite your specific origin domains.';
- } else {
- msg = msg[0];
- }
-
- var result = window.confirm(msg);
+ var result = window.confirm(app.i18n.en_US['cors-disable-cors-prompt']);
if (!result) { return; }
}
@@ -306,15 +300,6 @@ define([
Actions.methodChange(httpMethod);
},
- getCorsNotice: function () {
- var msg = FauxtonAPI.getExtensions('cors:notice');
- if (_.isUndefined(msg[0])) {
- return 'Cross-Origin Resource Sharing (CORS) lets you connect to remote servers directly from the browser, so you can host browser-based apps on static pages and talk directly with CouchDB to load your data.';
- }
-
- return msg[0];
- },
-
render: function () {
var isVisible = _.all([this.state.corsEnabled, !this.state.isAllOrigins]);
var className = this.state.corsEnabled ? 'collapsing-container' : '';
@@ -322,7 +307,7 @@ define([
return (
<div className="cors-page">
<header id="cors-header">
- <p>{this.getCorsNotice()}</p>
+ <p>{app.i18n.en_US['cors-notice']}</p>
</header>
<form id="corsForm" onSubmit={this.save}>
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/270183b3/i18n.json.default
----------------------------------------------------------------------
diff --git a/i18n.json.default b/i18n.json.default
index 13f08c9..2773f3f 100644
--- a/i18n.json.default
+++ b/i18n.json.default
@@ -8,6 +8,8 @@
"mango-descripton-index-editor": "Mango is an easy way to find documents on predefined indexes. <br/><br/>Create an Index to query it afterwards. The example in the editor shows how to create an index for the field '_id'. <br/><br/>The Indexes that you already created are listed on the right.",
"mango-additional-indexes-heading": "Your additional Indexes:",
"mango-indexeditor-title": "Mango",
- "couchdb-productname": "Apache CouchDB"
+ "couchdb-productname": "Apache CouchDB",
+ "cors-disable-cors-prompt": "Are you sure? Disabling CORS will overwrite your specific origin domains.",
+ "cors-notice": "Cross-Origin Resource Sharing (CORS) lets you connect to remote servers directly from the browser, so you can host browser-based apps on static pages and talk directly with CouchDB to load your data."
}
}