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 2016/05/31 07:58:48 UTC
[20/27] fauxton commit: updated refs/heads/master to 0ca35da
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/actionsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/actionsSpec.js b/app/addons/databases/tests/actionsSpec.js
index e656f8c..3dbe0c2 100644
--- a/app/addons/databases/tests/actionsSpec.js
+++ b/app/addons/databases/tests/actionsSpec.js
@@ -10,242 +10,238 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- '../../../../test/mocha/testUtils',
- '../base',
- '../stores',
- '../actions',
- '../actiontypes',
- '../resources',
- '../../documents/base'
-], function (app, FauxtonAPI, utils, Base, Stores, Actions, ActionTypes, Resources) {
-
- var assert = utils.assert;
-
- describe('Databases Actions', function () {
-
- describe('Initialization', function () {
-
- var oldDispatch, oldWhen, oldGetParams;
- var dispatchEvents, thenCallback, alwaysCallback;
- var databasesMock;
-
- beforeEach(function () {
- oldDispatch = FauxtonAPI.dispatch;
- dispatchEvents = [];
- FauxtonAPI.dispatch = function (what) {
- dispatchEvents.push(what);
- };
- oldWhen = FauxtonAPI.when;
- FauxtonAPI.when = function () {
- return {
- then: function (callback) {
- thenCallback = callback;
- callback();
- },
- always: function (callback) {
- alwaysCallback = callback;
- callback();
- }
- };
- };
- // (replace on demand)
- oldGetParams = app.getParams;
- databasesMock = {
- fetch: function () {
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import utils from "../../../../test/mocha/testUtils";
+import Base from "../base";
+import Stores from "../stores";
+import Actions from "../actions";
+import ActionTypes from "../actiontypes";
+import Resources from "../resources";
+import "../../documents/base";
+
+var assert = utils.assert;
+
+describe('Databases Actions', function () {
+
+ describe('Initialization', function () {
+
+ var oldDispatch, oldWhen, oldGetParams;
+ var dispatchEvents, thenCallback, alwaysCallback;
+ var databasesMock;
+
+ beforeEach(function () {
+ oldDispatch = FauxtonAPI.dispatch;
+ dispatchEvents = [];
+ FauxtonAPI.dispatch = function (what) {
+ dispatchEvents.push(what);
+ };
+ oldWhen = FauxtonAPI.when;
+ FauxtonAPI.when = function () {
+ return {
+ then: function (callback) {
+ thenCallback = callback;
+ callback();
},
- paginated: function () {
- return [];
+ always: function (callback) {
+ alwaysCallback = callback;
+ callback();
}
};
- });
-
- afterEach(function () {
- FauxtonAPI.dispatch = oldDispatch;
- FauxtonAPI.when = oldWhen;
- app.getParams = oldGetParams;
- });
+ };
+ // (replace on demand)
+ oldGetParams = app.getParams;
+ databasesMock = {
+ fetch: function () {
+ },
+ paginated: function () {
+ return [];
+ }
+ };
+ });
- it('Starts loading first', function () {
- app.getParams = function () {
- return {};
- };
- Actions.init(databasesMock);
- assert(!!thenCallback || !!alwaysCallback);
- // now we should have resolved it all
- assert.equal(2, dispatchEvents.length);
- assert.equal(ActionTypes.DATABASES_STARTLOADING, dispatchEvents[0].type);
- assert.equal(ActionTypes.DATABASES_INIT, dispatchEvents[1].type);
- assert.equal(1, dispatchEvents[1].options.page);
- });
-
- it('Accepts page params', function () {
- app.getParams = function () {
- return {
- page: 33
- };
- };
- Actions.init(databasesMock);
- // now we should have resolved it all
- assert.equal(2, dispatchEvents.length);
- assert.equal(ActionTypes.DATABASES_INIT, dispatchEvents[1].type);
- assert.equal(33, dispatchEvents[1].options.page);
- });
+ afterEach(function () {
+ FauxtonAPI.dispatch = oldDispatch;
+ FauxtonAPI.when = oldWhen;
+ app.getParams = oldGetParams;
+ });
+ it('Starts loading first', function () {
+ app.getParams = function () {
+ return {};
+ };
+ Actions.init(databasesMock);
+ assert(!!thenCallback || !!alwaysCallback);
+ // now we should have resolved it all
+ assert.equal(2, dispatchEvents.length);
+ assert.equal(ActionTypes.DATABASES_STARTLOADING, dispatchEvents[0].type);
+ assert.equal(ActionTypes.DATABASES_INIT, dispatchEvents[1].type);
+ assert.equal(1, dispatchEvents[1].options.page);
});
- describe('Add database', function () {
-
- var oldColl, oldBackbone, oldRouter, oldNotification, oldDispatch;
- var passedId, doneCallback, errorCallback, navigationTarget, notificationText, dispatchEvents;
-
- beforeEach(function () {
- oldColl = Stores.databasesStore._collection;
- oldBackbone = Stores.databasesStore._backboneCollection;
- passedId = null;
- Stores.databasesStore._backboneCollection = {};
- Stores.databasesStore._backboneCollection.model = function (options) {
- passedId = options.id;
- return {
- "save": function () {
- var res = {
- "done": function (callback) {
- doneCallback = callback;
- return res;
- },
- "error": function (callback) {
- errorCallback = callback;
- return res;
- }
- };
- return res;
- }
- };
+ it('Accepts page params', function () {
+ app.getParams = function () {
+ return {
+ page: 33
};
- oldRouter = app.router;
- navigationTarget = null;
- app.router = {
- navigate: function (target) {
- navigationTarget = target;
+ };
+ Actions.init(databasesMock);
+ // now we should have resolved it all
+ assert.equal(2, dispatchEvents.length);
+ assert.equal(ActionTypes.DATABASES_INIT, dispatchEvents[1].type);
+ assert.equal(33, dispatchEvents[1].options.page);
+ });
+
+ });
+
+ describe('Add database', function () {
+
+ var oldColl, oldBackbone, oldRouter, oldNotification, oldDispatch;
+ var passedId, doneCallback, errorCallback, navigationTarget, notificationText, dispatchEvents;
+
+ beforeEach(function () {
+ oldColl = Stores.databasesStore._collection;
+ oldBackbone = Stores.databasesStore._backboneCollection;
+ passedId = null;
+ Stores.databasesStore._backboneCollection = {};
+ Stores.databasesStore._backboneCollection.model = function (options) {
+ passedId = options.id;
+ return {
+ "save": function () {
+ var res = {
+ "done": function (callback) {
+ doneCallback = callback;
+ return res;
+ },
+ "error": function (callback) {
+ errorCallback = callback;
+ return res;
+ }
+ };
+ return res;
}
};
- oldNotification = FauxtonAPI.addNotification;
- notificationText = [];
- FauxtonAPI.addNotification = function (options) {
- notificationText.push(options.msg);
- };
- oldDispatch = FauxtonAPI.dispatch;
- dispatchEvents = [];
- FauxtonAPI.dispatch = function (what) {
- dispatchEvents.push(what);
- };
- });
-
- afterEach(function () {
- Stores.databasesStore._collection = oldColl;
- Stores.databasesStore._backboneCollection = oldBackbone;
- app.router = oldRouter;
- FauxtonAPI.addNotification = oldNotification;
- FauxtonAPI.dispatch = oldDispatch;
- });
-
- it("Creates database in backend", function () {
- Actions.createNewDatabase("testdb");
- doneCallback();
- assert.equal("testdb", passedId);
- assert.equal(1, _.map(dispatchEvents, function (item) {
- if (item.type === ActionTypes.DATABASES_SET_PROMPT_VISIBLE) {
- return item;
- }
- }).length);
- assert.equal(2, notificationText.length);
- assert(notificationText[0].indexOf("Creating") >= 0);
- assert(notificationText[1].indexOf("success") >= 0);
- assert.ok(navigationTarget.indexOf("testdb") >= 0);
- });
-
- it("Creates no database without name", function () {
- Actions.createNewDatabase(" ");
- assert(passedId === null);
- assert.equal(0, _.map(dispatchEvents, function (item) {
- if (item.type === ActionTypes.DATABASES_SET_PROMPT_VISIBLE) {
- return item;
- }
- }).length);
- assert.equal(1, notificationText.length);
- assert(notificationText[0].indexOf("valid database name") >= 0);
- });
-
- it("Shows error message on create fail", function () {
- Actions.createNewDatabase("testdb");
- errorCallback({"responseText": JSON.stringify({"reason": "testerror"})});
- assert.equal("testdb", passedId);
- assert.equal(2, notificationText.length);
- assert(notificationText[0].indexOf("Creating") >= 0);
- assert(notificationText[1].indexOf("failed") >= 0);
- assert(notificationText[1].indexOf("testerror") >= 0);
- assert(navigationTarget === null);
- });
+ };
+ oldRouter = app.router;
+ navigationTarget = null;
+ app.router = {
+ navigate: function (target) {
+ navigationTarget = target;
+ }
+ };
+ oldNotification = FauxtonAPI.addNotification;
+ notificationText = [];
+ FauxtonAPI.addNotification = function (options) {
+ notificationText.push(options.msg);
+ };
+ oldDispatch = FauxtonAPI.dispatch;
+ dispatchEvents = [];
+ FauxtonAPI.dispatch = function (what) {
+ dispatchEvents.push(what);
+ };
+ });
+ afterEach(function () {
+ Stores.databasesStore._collection = oldColl;
+ Stores.databasesStore._backboneCollection = oldBackbone;
+ app.router = oldRouter;
+ FauxtonAPI.addNotification = oldNotification;
+ FauxtonAPI.dispatch = oldDispatch;
});
- describe('Jump to database', function () {
+ it("Creates database in backend", function () {
+ Actions.createNewDatabase("testdb");
+ doneCallback();
+ assert.equal("testdb", passedId);
+ assert.equal(1, _.map(dispatchEvents, function (item) {
+ if (item.type === ActionTypes.DATABASES_SET_PROMPT_VISIBLE) {
+ return item;
+ }
+ }).length);
+ assert.equal(2, notificationText.length);
+ assert(notificationText[0].indexOf("Creating") >= 0);
+ assert(notificationText[1].indexOf("success") >= 0);
+ assert.ok(navigationTarget.indexOf("testdb") >= 0);
+ });
- var container, jumpEl, oldNavigate, oldAddNotification, oldGetDatabaseNames, old$;
- var navigationTarget, notificationText;
+ it("Creates no database without name", function () {
+ Actions.createNewDatabase(" ");
+ assert(passedId === null);
+ assert.equal(0, _.map(dispatchEvents, function (item) {
+ if (item.type === ActionTypes.DATABASES_SET_PROMPT_VISIBLE) {
+ return item;
+ }
+ }).length);
+ assert.equal(1, notificationText.length);
+ assert(notificationText[0].indexOf("valid database name") >= 0);
+ });
- beforeEach(function () {
- old$ = $;
- // simulate typeahead
- $ = function (selector) {
- var res = old$(selector);
- res.typeahead = function () {};
- return res;
- };
- oldNavigate = FauxtonAPI.navigate;
- navigationTarget = null;
- FauxtonAPI.navigate = function (url) {
- navigationTarget = url;
- };
- oldAddNotification = FauxtonAPI.addNotification;
- notificationText = [];
- FauxtonAPI.addNotification = function (options) {
- notificationText.push(options.msg);
- };
- oldGetDatabaseNames = Stores.databasesStore.getDatabaseNames;
- Stores.databasesStore.getDatabaseNames = function () {
- return ["db1", "db2"];
- };
- });
-
- afterEach(function () {
- $ = old$;
- FauxtonAPI.navigate = oldNavigate;
- FauxtonAPI.addNotification = oldAddNotification;
- Stores.databasesStore.getDatabaseNames = oldGetDatabaseNames;
- });
-
- it("jumps to an existing DB", function () {
- Actions.jumpToDatabase("db1");
- assert(navigationTarget.indexOf("db1") >= 0);
- assert.equal(0, notificationText.length);
- });
-
- it("does nothing on empty name", function () {
- Actions.jumpToDatabase(" ");
- assert(navigationTarget === null);
- assert.equal(0, notificationText.length);
- });
-
- it("shows a message on non-existent DB", function () {
- Actions.jumpToDatabase("db3");
- assert(navigationTarget === null);
- assert.equal(1, notificationText.length);
- assert(notificationText[0].indexOf("not exist") >= 0);
- });
+ it("Shows error message on create fail", function () {
+ Actions.createNewDatabase("testdb");
+ errorCallback({"responseText": JSON.stringify({"reason": "testerror"})});
+ assert.equal("testdb", passedId);
+ assert.equal(2, notificationText.length);
+ assert(notificationText[0].indexOf("Creating") >= 0);
+ assert(notificationText[1].indexOf("failed") >= 0);
+ assert(notificationText[1].indexOf("testerror") >= 0);
+ assert(navigationTarget === null);
+ });
+
+ });
+
+ describe('Jump to database', function () {
+
+ var container, jumpEl, oldNavigate, oldAddNotification, oldGetDatabaseNames, old$;
+ var navigationTarget, notificationText;
+
+ beforeEach(function () {
+ old$ = $;
+ // simulate typeahead
+ $ = function (selector) {
+ var res = old$(selector);
+ res.typeahead = function () {};
+ return res;
+ };
+ oldNavigate = FauxtonAPI.navigate;
+ navigationTarget = null;
+ FauxtonAPI.navigate = function (url) {
+ navigationTarget = url;
+ };
+ oldAddNotification = FauxtonAPI.addNotification;
+ notificationText = [];
+ FauxtonAPI.addNotification = function (options) {
+ notificationText.push(options.msg);
+ };
+ oldGetDatabaseNames = Stores.databasesStore.getDatabaseNames;
+ Stores.databasesStore.getDatabaseNames = function () {
+ return ["db1", "db2"];
+ };
+ });
+
+ afterEach(function () {
+ $ = old$;
+ FauxtonAPI.navigate = oldNavigate;
+ FauxtonAPI.addNotification = oldAddNotification;
+ Stores.databasesStore.getDatabaseNames = oldGetDatabaseNames;
+ });
+
+ it("jumps to an existing DB", function () {
+ Actions.jumpToDatabase("db1");
+ assert(navigationTarget.indexOf("db1") >= 0);
+ assert.equal(0, notificationText.length);
+ });
+
+ it("does nothing on empty name", function () {
+ Actions.jumpToDatabase(" ");
+ assert(navigationTarget === null);
+ assert.equal(0, notificationText.length);
+ });
+ it("shows a message on non-existent DB", function () {
+ Actions.jumpToDatabase("db3");
+ assert(navigationTarget === null);
+ assert.equal(1, notificationText.length);
+ assert(notificationText[0].indexOf("not exist") >= 0);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/componentsSpec.react.jsx b/app/addons/databases/tests/componentsSpec.react.jsx
index a1a5442..f9a4eb0 100644
--- a/app/addons/databases/tests/componentsSpec.react.jsx
+++ b/app/addons/databases/tests/componentsSpec.react.jsx
@@ -9,335 +9,331 @@
// 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([
- '../../../core/api',
- '../components.react',
- '../actions',
- '../actiontypes',
- '../stores',
- '../../../../test/mocha/testUtils',
- "react",
- 'react-dom',
- 'react-addons-test-utils',
- 'sinon'
-], function (FauxtonAPI, Views, Actions, ActionTypes, Stores, utils, React, ReactDOM, TestUtils, sinon) {
-
- var assert = utils.assert;
-
- describe('DatabasesController', function () {
-
- var container, dbEl, oldGetCollection;
-
- beforeEach(function () {
- // define our own collection
- oldGetCollection = Stores.databasesStore.getCollection;
- Stores.databasesStore.getCollection = function () {
- return [
- {
- "get": function (what) {
- if ("name" === what) {
- return "db1";
- } else {
- throw "Unknown get('" + what + "')";
- }
+import FauxtonAPI from "../../../core/api";
+import Views from "../components.react";
+import Actions from "../actions";
+import ActionTypes from "../actiontypes";
+import Stores from "../stores";
+import utils from "../../../../test/mocha/testUtils";
+import React from "react";
+import ReactDOM from "react-dom";
+import TestUtils from "react-addons-test-utils";
+import sinon from "sinon";
+
+var assert = utils.assert;
+
+describe('DatabasesController', function () {
+
+ var container, dbEl, oldGetCollection;
+
+ beforeEach(function () {
+ // define our own collection
+ oldGetCollection = Stores.databasesStore.getCollection;
+ Stores.databasesStore.getCollection = function () {
+ return [
+ {
+ "get": function (what) {
+ if ("name" === what) {
+ return "db1";
+ } else {
+ throw "Unknown get('" + what + "')";
+ }
+ },
+ "status": {
+ "loadSuccess": true,
+ "dataSize": function () {
+ return 2 * 1024 * 1024;
+ },
+ "numDocs": function () {
+ return 88;
+ },
+ "isGraveYard": function () {
+ return false;
},
- "status": {
- "loadSuccess": true,
- "dataSize": function () {
- return 2 * 1024 * 1024;
- },
- "numDocs": function () {
- return 88;
- },
- "isGraveYard": function () {
- return false;
- },
- "updateSeq": function () {
- return 99;
- }
+ "updateSeq": function () {
+ return 99;
+ }
+ }
+ },
+ {
+ "get": function (what) {
+ if ("name" === what) {
+ return "db2";
+ } else {
+ throw "Unknown get('" + what + "')";
}
},
- {
- "get": function (what) {
- if ("name" === what) {
- return "db2";
- } else {
- throw "Unknown get('" + what + "')";
- }
+ "status": {
+ "loadSuccess": true,
+ "dataSize": function () {
+ return 1024;
+ },
+ "numDocs": function () {
+ return 188;
},
- "status": {
- "loadSuccess": true,
- "dataSize": function () {
- return 1024;
- },
- "numDocs": function () {
- return 188;
- },
- "numDeletedDocs": function () {
- return 222;
- },
- "isGraveYard": function () {
- return true;
- },
- "updateSeq": function () {
- return 399;
- }
+ "numDeletedDocs": function () {
+ return 222;
+ },
+ "isGraveYard": function () {
+ return true;
+ },
+ "updateSeq": function () {
+ return 399;
}
}
- ];
- };
- container = document.createElement('div');
- dbEl = ReactDOM.render(React.createElement(Views.DatabasesController, {}), container);
- });
+ }
+ ];
+ };
+ container = document.createElement('div');
+ dbEl = ReactDOM.render(React.createElement(Views.DatabasesController, {}), container);
+ });
- afterEach(function () {
- Stores.databasesStore.getCollection = oldGetCollection;
- ReactDOM.unmountComponentAtNode(container);
- });
+ afterEach(function () {
+ Stores.databasesStore.getCollection = oldGetCollection;
+ ReactDOM.unmountComponentAtNode(container);
+ });
- it('renders base data of DBs', function () {
+ it('renders base data of DBs', function () {
- const el = ReactDOM.findDOMNode(dbEl);
+ const el = ReactDOM.findDOMNode(dbEl);
- assert.equal(1 + 2, el.getElementsByTagName('tr').length);
- assert.equal("db1", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[0].innerText.trim());
- assert.equal("2.0 MB", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[1].innerText.trim());
- assert.equal("88", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].innerText.trim());
- assert.equal(0, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].getElementsByTagName("i").length);
- assert.equal(3, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[4].getElementsByTagName("a").length);
- assert.equal("db2", el.getElementsByTagName('tr')[2].getElementsByTagName('td')[0].innerText.trim());
- assert.equal(1, el.getElementsByTagName('tr')[2].getElementsByTagName('td')[2].getElementsByTagName("i").length);
- });
+ assert.equal(1 + 2, el.getElementsByTagName('tr').length);
+ assert.equal("db1", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[0].innerText.trim());
+ assert.equal("2.0 MB", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[1].innerText.trim());
+ assert.equal("88", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].innerText.trim());
+ assert.equal(0, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].getElementsByTagName("i").length);
+ assert.equal(3, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[4].getElementsByTagName("a").length);
+ assert.equal("db2", el.getElementsByTagName('tr')[2].getElementsByTagName('td')[0].innerText.trim());
+ assert.equal(1, el.getElementsByTagName('tr')[2].getElementsByTagName('td')[2].getElementsByTagName("i").length);
+ });
+
+});
+describe('AddDatabaseWidget', function () {
+
+ var container, addEl, oldCreateNewDatabase;
+ var createCalled, passedDbName;
+
+ beforeEach(function () {
+ oldCreateNewDatabase = Actions.createNewDatabase;
+ Actions.createNewDatabase = function (dbName) {
+ createCalled = true;
+ passedDbName = dbName;
+ };
+ container = document.createElement('div');
+ addEl = ReactDOM.render(React.createElement(Views.AddDatabaseWidget, {}), container);
});
- describe('AddDatabaseWidget', function () {
+ afterEach(function () {
+ Actions.createNewDatabase = oldCreateNewDatabase;
+ ReactDOM.unmountComponentAtNode(container);
+ });
- var container, addEl, oldCreateNewDatabase;
- var createCalled, passedDbName;
+ it("Creates a database with given name", function () {
+ createCalled = false;
+ passedDbName = null;
+ const el = TestUtils.findRenderedDOMComponentWithTag(addEl, 'input');
+ ReactDOM.findDOMNode(el).value = "testdb";
+ addEl.onAddDatabase();
+ assert.equal(true, createCalled);
+ assert.equal("testdb", passedDbName);
+ });
- beforeEach(function () {
- oldCreateNewDatabase = Actions.createNewDatabase;
- Actions.createNewDatabase = function (dbName) {
- createCalled = true;
- passedDbName = dbName;
- };
- container = document.createElement('div');
- addEl = ReactDOM.render(React.createElement(Views.AddDatabaseWidget, {}), container);
- });
+});
- afterEach(function () {
- Actions.createNewDatabase = oldCreateNewDatabase;
- ReactDOM.unmountComponentAtNode(container);
- });
+describe('JumpToDatabaseWidget', function () {
+
+ var container, jumpEl, oldJumpToDatabase, oldGetDatabaseNames, old$;
+ var jumpCalled, passedDbName;
+
+ beforeEach(function () {
+ old$ = $;
+ // simulate typeahead
+ $ = function (selector) {
+ var res = old$(selector);
+ res.typeahead = function () {};
+ return res;
+ };
+ oldJumpToDatabase = Actions.jumpToDatabase;
+ Actions.jumpToDatabase = function (dbName) {
+ jumpCalled = true;
+ passedDbName = dbName;
+ };
+ oldGetDatabaseNames = Stores.databasesStore.getDatabaseNames;
+ Stores.databasesStore.getDatabaseNames = function () {
+ return ["db1", "db2"];
+ };
+ container = document.createElement('div');
+ jumpEl = ReactDOM.render(React.createElement(Views.JumpToDatabaseWidget, {}), container);
+ });
- it("Creates a database with given name", function () {
- createCalled = false;
- passedDbName = null;
- const el = TestUtils.findRenderedDOMComponentWithTag(addEl, 'input');
- ReactDOM.findDOMNode(el).value = "testdb";
- addEl.onAddDatabase();
- assert.equal(true, createCalled);
- assert.equal("testdb", passedDbName);
- });
+ afterEach(function () {
+ $ = old$;
+ Actions.jumpToDatabase = oldJumpToDatabase;
+ Stores.databasesStore.getDatabaseNames = oldGetDatabaseNames;
+ ReactDOM.unmountComponentAtNode(container);
+ // reset the store for future use
+ Stores.databasesStore.reset();
+ });
+ it("Jumps to a database with given name", function () {
+ jumpCalled = false;
+ passedDbName = null;
+ jumpEl.jumpToDb("db1");
+ assert.equal(true, jumpCalled);
+ assert.equal("db1", passedDbName);
});
- describe('JumpToDatabaseWidget', function () {
-
- var container, jumpEl, oldJumpToDatabase, oldGetDatabaseNames, old$;
- var jumpCalled, passedDbName;
-
- beforeEach(function () {
- old$ = $;
- // simulate typeahead
- $ = function (selector) {
- var res = old$(selector);
- res.typeahead = function () {};
- return res;
- };
- oldJumpToDatabase = Actions.jumpToDatabase;
- Actions.jumpToDatabase = function (dbName) {
- jumpCalled = true;
- passedDbName = dbName;
- };
- oldGetDatabaseNames = Stores.databasesStore.getDatabaseNames;
- Stores.databasesStore.getDatabaseNames = function () {
- return ["db1", "db2"];
- };
- container = document.createElement('div');
- jumpEl = ReactDOM.render(React.createElement(Views.JumpToDatabaseWidget, {}), container);
- });
+ it("jumps to an existing DB from input", function () {
+ jumpCalled = false;
+ passedDbName = null;
+ const input = TestUtils.findRenderedDOMComponentWithTag(jumpEl, 'input');
+ input.value = "db2";
+ jumpEl.jumpToDb();
+ assert.equal(true, jumpCalled);
+ assert.equal("db2", passedDbName);
+ });
- afterEach(function () {
- $ = old$;
- Actions.jumpToDatabase = oldJumpToDatabase;
- Stores.databasesStore.getDatabaseNames = oldGetDatabaseNames;
- ReactDOM.unmountComponentAtNode(container);
- // reset the store for future use
- Stores.databasesStore.reset();
- });
+ it('updates DB list if data is sent after initially mounted', function () {
+ var newCollection = new Backbone.Collection();
+ newCollection.add(new Backbone.Model({ name: 'new-db1' }));
+ newCollection.add(new Backbone.Model({ name: 'new-db2' }));
- it("Jumps to a database with given name", function () {
- jumpCalled = false;
- passedDbName = null;
- jumpEl.jumpToDb("db1");
- assert.equal(true, jumpCalled);
- assert.equal("db1", passedDbName);
- });
+ var spy = sinon.spy(jumpEl, 'componentDidUpdate');
- it("jumps to an existing DB from input", function () {
- jumpCalled = false;
- passedDbName = null;
- const input = TestUtils.findRenderedDOMComponentWithTag(jumpEl, 'input');
- input.value = "db2";
- jumpEl.jumpToDb();
- assert.equal(true, jumpCalled);
- assert.equal("db2", passedDbName);
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_INIT,
+ options: {
+ collection: newCollection.toJSON(),
+ backboneCollection: newCollection,
+ page: 1
+ }
});
- it('updates DB list if data is sent after initially mounted', function () {
- var newCollection = new Backbone.Collection();
- newCollection.add(new Backbone.Model({ name: 'new-db1' }));
- newCollection.add(new Backbone.Model({ name: 'new-db2' }));
+ // because of the need to override typeahead, this just does a spy on the componentDidUpdate method to ensure
+ // it gets called
+ assert.ok(spy.calledOnce);
- var spy = sinon.spy(jumpEl, 'componentDidUpdate');
+ });
+});
- FauxtonAPI.dispatch({
- type: ActionTypes.DATABASES_INIT,
- options: {
- collection: newCollection.toJSON(),
- backboneCollection: newCollection,
- page: 1
- }
- });
- // because of the need to override typeahead, this just does a spy on the componentDidUpdate method to ensure
- // it gets called
- assert.ok(spy.calledOnce);
+describe('DatabasePagination', function () {
+ it('uses custom URL prefix on the navigation if passed through props', function () {
+ var container = document.createElement('div');
+ var pagination = TestUtils.renderIntoDocument(<Views.DatabasePagination linkPath="_custom_path" />, container);
+ var links = $(ReactDOM.findDOMNode(pagination)).find('a');
+ assert.equal(links.length, 3, 'pagination contains links');
+ links.each(function () {
+ assert.include(this.href, '_custom_path', 'link contains custom path');
});
- });
-
- describe('DatabasePagination', function () {
- it('uses custom URL prefix on the navigation if passed through props', function () {
- var container = document.createElement('div');
- var pagination = TestUtils.renderIntoDocument(<Views.DatabasePagination linkPath="_custom_path" />, container);
- var links = $(ReactDOM.findDOMNode(pagination)).find('a');
+ ReactDOM.unmountComponentAtNode(container);
+ });
+});
- assert.equal(links.length, 3, 'pagination contains links');
- links.each(function () {
- assert.include(this.href, '_custom_path', 'link contains custom path');
- });
+describe('DatabaseTable', function () {
+ var container;
- ReactDOM.unmountComponentAtNode(container);
- });
+ beforeEach(function () {
+ container = document.createElement('div');
});
- describe('DatabaseTable', function () {
- var container;
+ afterEach(function () {
+ ReactDOM.unmountComponentAtNode(container);
+ });
- beforeEach(function () {
- container = document.createElement('div');
+ it('adds multiple extra columns if extended', function () {
+ var ColHeader1 = React.createClass({
+ render: function () { return <th>EXTRA COL 1</th>; }
});
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
+ var ColHeader2 = React.createClass({
+ render: function () { return <th>EXTRA COL 2</th>; }
});
-
- it('adds multiple extra columns if extended', function () {
- var ColHeader1 = React.createClass({
- render: function () { return <th>EXTRA COL 1</th>; }
- });
- var ColHeader2 = React.createClass({
- render: function () { return <th>EXTRA COL 2</th>; }
- });
- var ColHeader3 = React.createClass({
- render: function () { return <th>EXTRA COL 3</th>; }
- });
-
- FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader1);
- FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader2);
- FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader3);
-
- var table = TestUtils.renderIntoDocument(
- <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} loading={false} body={[]} />,
- container
- );
- var cols = $(ReactDOM.findDOMNode(table)).find('th');
-
- // (default # of rows is 5)
- assert.equal(cols.length, 8, 'extra columns show up');
-
- FauxtonAPI.unRegisterExtension('DatabaseTable:head');
+ var ColHeader3 = React.createClass({
+ render: function () { return <th>EXTRA COL 3</th>; }
});
- it('adds multiple extra column in DatabaseRow if extended', function () {
- var Cell = React.createClass({
- render: function () { return <td>EXTRA CELL</td>; }
- });
+ FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader1);
+ FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader2);
+ FauxtonAPI.registerExtension('DatabaseTable:head', ColHeader3);
- FauxtonAPI.registerExtension('DatabaseTable:databaseRow', Cell);
+ var table = TestUtils.renderIntoDocument(
+ <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} loading={false} body={[]} />,
+ container
+ );
+ var cols = $(ReactDOM.findDOMNode(table)).find('th');
- var row = new Backbone.Model({ name: 'db name' });
- row.status = {
- loadSuccess: true,
- dataSize: function () { return 0; },
- numDocs: function () { return 0; },
- updateSeq: function () { return 0; },
- isGraveYard: function () { return false; }
- };
+ // (default # of rows is 5)
+ assert.equal(cols.length, 8, 'extra columns show up');
- var databaseRow = TestUtils.renderIntoDocument(
- <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
- container
- );
- var links = $(ReactDOM.findDOMNode(databaseRow)).find('td');
+ FauxtonAPI.unRegisterExtension('DatabaseTable:head');
+ });
- // (default # of rows is 5)
- assert.equal(links.length, 6, 'extra column shows up');
+ it('adds multiple extra column in DatabaseRow if extended', function () {
+ var Cell = React.createClass({
+ render: function () { return <td>EXTRA CELL</td>; }
+ });
- FauxtonAPI.unRegisterExtension('DatabaseTable:databaseRow');
+ FauxtonAPI.registerExtension('DatabaseTable:databaseRow', Cell);
- Stores.databasesStore.reset();
- });
+ var row = new Backbone.Model({ name: 'db name' });
+ row.status = {
+ loadSuccess: true,
+ dataSize: function () { return 0; },
+ numDocs: function () { return 0; },
+ updateSeq: function () { return 0; },
+ isGraveYard: function () { return false; }
+ };
- it('shows error message if row marked as failed to load', function () {
- var row = new Backbone.Model({ name: 'db name' });
- row.status = {
- loadSuccess: false,
- dataSize: function () { return 0; },
- numDocs: function () { return 0; },
- updateSeq: function () { return 0; },
- isGraveYard: function () { return false; }
- };
-
- var databaseRow = TestUtils.renderIntoDocument(
- <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
- container
- );
- assert.equal($(ReactDOM.findDOMNode(databaseRow)).find('.database-load-fail').length, 1);
- });
+ var databaseRow = TestUtils.renderIntoDocument(
+ <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
+ container
+ );
+ var links = $(ReactDOM.findDOMNode(databaseRow)).find('td');
- it('shows no error if row marked as loaded', function () {
- var row = new Backbone.Model({ name: 'db name' });
- row.status = {
- loadSuccess: true,
- dataSize: function () { return 0; },
- numDocs: function () { return 0; },
- updateSeq: function () { return 0; },
- isGraveYard: function () { return false; }
- };
-
- var databaseRow = TestUtils.renderIntoDocument(
- <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
- container
- );
-
- assert.equal($(ReactDOM.findDOMNode(databaseRow)).find('.database-load-fail').length, 0);
- });
+ // (default # of rows is 5)
+ assert.equal(links.length, 6, 'extra column shows up');
+
+ FauxtonAPI.unRegisterExtension('DatabaseTable:databaseRow');
+
+ Stores.databasesStore.reset();
+ });
+
+ it('shows error message if row marked as failed to load', function () {
+ var row = new Backbone.Model({ name: 'db name' });
+ row.status = {
+ loadSuccess: false,
+ dataSize: function () { return 0; },
+ numDocs: function () { return 0; },
+ updateSeq: function () { return 0; },
+ isGraveYard: function () { return false; }
+ };
+
+ var databaseRow = TestUtils.renderIntoDocument(
+ <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
+ container
+ );
+ assert.equal($(ReactDOM.findDOMNode(databaseRow)).find('.database-load-fail').length, 1);
+ });
+ it('shows no error if row marked as loaded', function () {
+ var row = new Backbone.Model({ name: 'db name' });
+ row.status = {
+ loadSuccess: true,
+ dataSize: function () { return 0; },
+ numDocs: function () { return 0; },
+ updateSeq: function () { return 0; },
+ isGraveYard: function () { return false; }
+ };
+
+ var databaseRow = TestUtils.renderIntoDocument(
+ <Views.DatabaseTable showDeleteDatabaseModal={{showModal: false}} body={[row]} />,
+ container
+ );
+
+ assert.equal($(ReactDOM.findDOMNode(databaseRow)).find('.database-load-fail').length, 0);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/checkDatabaseTooltip.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/checkDatabaseTooltip.js b/app/addons/databases/tests/nightwatch/checkDatabaseTooltip.js
index ddb6b5f..00a9e96 100644
--- a/app/addons/databases/tests/nightwatch/checkDatabaseTooltip.js
+++ b/app/addons/databases/tests/nightwatch/checkDatabaseTooltip.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
module.exports = {
'Check the tooltip icon for DB with deleted items appears': function (client) {
var waitTime = client.globals.maxWaitTime,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/createsDatabase.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/createsDatabase.js b/app/addons/databases/tests/nightwatch/createsDatabase.js
index 4e7c99b..99d9e84 100644
--- a/app/addons/databases/tests/nightwatch/createsDatabase.js
+++ b/app/addons/databases/tests/nightwatch/createsDatabase.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
var newDatabaseName = 'fauxton-selenium-tests-db-create';
var helpers = require('../../../../../test/nightwatch_tests/helpers/helpers.js');
module.exports = {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/deletesDatabase.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/deletesDatabase.js b/app/addons/databases/tests/nightwatch/deletesDatabase.js
index 3109318..23d982c 100644
--- a/app/addons/databases/tests/nightwatch/deletesDatabase.js
+++ b/app/addons/databases/tests/nightwatch/deletesDatabase.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
module.exports = {
'Deletes a database': function (client) {
var waitTime = client.globals.maxWaitTime,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/deletesDatabaseSpecialChars.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/deletesDatabaseSpecialChars.js b/app/addons/databases/tests/nightwatch/deletesDatabaseSpecialChars.js
index 03150e4..007e842 100644
--- a/app/addons/databases/tests/nightwatch/deletesDatabaseSpecialChars.js
+++ b/app/addons/databases/tests/nightwatch/deletesDatabaseSpecialChars.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
module.exports = {
'Deletes a database with special chars': function (client) {
var waitTime = client.globals.maxWaitTime,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/switchDatabase.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/switchDatabase.js b/app/addons/databases/tests/nightwatch/switchDatabase.js
index 94c0fe1..cdd2948 100644
--- a/app/addons/databases/tests/nightwatch/switchDatabase.js
+++ b/app/addons/databases/tests/nightwatch/switchDatabase.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
module.exports = {
'Confirm selecting database via typeahead redirects properly': function (client) {
var waitTime = client.globals.maxWaitTime,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/nightwatch/zeroclipboard.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/zeroclipboard.js b/app/addons/databases/tests/nightwatch/zeroclipboard.js
index cd83582..04a0361 100644
--- a/app/addons/databases/tests/nightwatch/zeroclipboard.js
+++ b/app/addons/databases/tests/nightwatch/zeroclipboard.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
var os = require('os');
module.exports = {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/resourcesSpec.js b/app/addons/databases/tests/resourcesSpec.js
index 754d765..a434308 100644
--- a/app/addons/databases/tests/resourcesSpec.js
+++ b/app/addons/databases/tests/resourcesSpec.js
@@ -9,58 +9,55 @@
// 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([
- '../../../core/api',
- '../resources',
- '../../../../test/mocha/testUtils',
-], function (FauxtonAPI, Resources, testUtils) {
- var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox;
+import FauxtonAPI from "../../../core/api";
+import Resources from "../resources";
+import testUtils from "../../../../test/mocha/testUtils";
+var assert = testUtils.assert,
+ ViewSandbox = testUtils.ViewSandbox;
- describe("Databases: List", function () {
+describe("Databases: List", function () {
- describe("List items", function () {
+ describe("List items", function () {
- it("detects graveyards", function () {
- var modelWithGraveYard = new Resources.Status({
- doc_count: 5,
- doc_del_count: 6
- });
- var modelWithoutGraveYard = new Resources.Status({
- doc_count: 6,
- doc_del_count: 5
- });
- assert.ok(modelWithGraveYard.isGraveYard());
- assert.ok(!modelWithoutGraveYard.isGraveYard());
+ it("detects graveyards", function () {
+ var modelWithGraveYard = new Resources.Status({
+ doc_count: 5,
+ doc_del_count: 6
});
+ var modelWithoutGraveYard = new Resources.Status({
+ doc_count: 6,
+ doc_del_count: 5
+ });
+ assert.ok(modelWithGraveYard.isGraveYard());
+ assert.ok(!modelWithoutGraveYard.isGraveYard());
+ });
- it("can tell whether the data size showing is accurate or not", function () {
- var modelWithDataSize = new Resources.Status({
- other: 6,
- data_size: 5,
- disk_size: 2
- });
- assert.ok(modelWithDataSize.hasDataSize());
-
- var empty_probably_fetching_model = new Resources.Status({});
- assert.notOk(empty_probably_fetching_model.hasDataSize());
+ it("can tell whether the data size showing is accurate or not", function () {
+ var modelWithDataSize = new Resources.Status({
+ other: 6,
+ data_size: 5,
+ disk_size: 2
});
+ assert.ok(modelWithDataSize.hasDataSize());
+ var empty_probably_fetching_model = new Resources.Status({});
+ assert.notOk(empty_probably_fetching_model.hasDataSize());
});
- describe('List of Databases', function () {
- it('returns the names of databases in a list in an array', function () {
- var listCollection = new Resources.List([{
- name: 'ente'
- },
- {
- name: 'rocko'
- }]);
- var databaseNames = listCollection.getDatabaseNames();
+ });
- assert.equal(databaseNames[0], 'ente');
- assert.equal(databaseNames[1], 'rocko');
- });
+ describe('List of Databases', function () {
+ it('returns the names of databases in a list in an array', function () {
+ var listCollection = new Resources.List([{
+ name: 'ente'
+ },
+ {
+ name: 'rocko'
+ }]);
+ var databaseNames = listCollection.getDatabaseNames();
+
+ assert.equal(databaseNames[0], 'ente');
+ assert.equal(databaseNames[1], 'rocko');
});
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/databases/tests/storesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/storesSpec.js b/app/addons/databases/tests/storesSpec.js
index 45a8883..02ddbcf 100644
--- a/app/addons/databases/tests/storesSpec.js
+++ b/app/addons/databases/tests/storesSpec.js
@@ -10,63 +10,59 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- '../../../../test/mocha/testUtils',
- '../stores',
- '../actiontypes',
- '../resources'
-], function (app, FauxtonAPI, utils, Stores, ActionTypes, Resources) {
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import utils from "../../../../test/mocha/testUtils";
+import Stores from "../stores";
+import ActionTypes from "../actiontypes";
+import Resources from "../resources";
- var assert = utils.assert;
+var assert = utils.assert;
- describe('Databases Store', function () {
+describe('Databases Store', function () {
- var oldColl, oldBackbone;
- var passedId, doneCallback, errorCallback, navigationTarget;
+ var oldColl, oldBackbone;
+ var passedId, doneCallback, errorCallback, navigationTarget;
- beforeEach(function () {
- oldColl = Stores.databasesStore._collection;
- oldBackbone = Stores.databasesStore._backboneCollection;
- Stores.databasesStore._backboneCollection = {};
- });
+ beforeEach(function () {
+ oldColl = Stores.databasesStore._collection;
+ oldBackbone = Stores.databasesStore._backboneCollection;
+ Stores.databasesStore._backboneCollection = {};
+ });
- afterEach(function () {
- Stores.databasesStore._collection = oldColl;
- Stores.databasesStore._backboneCollection = oldBackbone;
- });
+ afterEach(function () {
+ Stores.databasesStore._collection = oldColl;
+ Stores.databasesStore._backboneCollection = oldBackbone;
+ });
- it("inits based on what we pass", function () {
- Stores.databasesStore.init({"name": "col1"}, {"name": "col2"});
- assert.equal("col1", Stores.databasesStore.getCollection().name);
- assert.equal("col2", Stores.databasesStore._backboneCollection.name);
- });
+ it("inits based on what we pass", function () {
+ Stores.databasesStore.init({"name": "col1"}, {"name": "col2"});
+ assert.equal("col1", Stores.databasesStore.getCollection().name);
+ assert.equal("col2", Stores.databasesStore._backboneCollection.name);
+ });
- describe("database collection info", function () {
+ describe("database collection info", function () {
- beforeEach(function () {
- Stores.databasesStore._backboneCollection.toJSON = function () {
- return {
- "db1": {
- "name": "db1"
- },
- "db2": {
- "name": "db2"
- }
- };
+ beforeEach(function () {
+ Stores.databasesStore._backboneCollection.toJSON = function () {
+ return {
+ "db1": {
+ "name": "db1"
+ },
+ "db2": {
+ "name": "db2"
+ }
};
- });
-
- it("determines database names", function () {
- assert.ok(JSON.stringify(["db1", "db2"]) == JSON.stringify(Stores.databasesStore.getDatabaseNames().sort()));
- });
+ };
+ });
- it("determines database availability", function () {
- assert(Stores.databasesStore.doesDatabaseExist("db1"));
- assert(!Stores.databasesStore.doesDatabaseExist("db3"));
- });
+ it("determines database names", function () {
+ assert.ok(JSON.stringify(["db1", "db2"]) == JSON.stringify(Stores.databasesStore.getDatabaseNames().sort()));
+ });
+ it("determines database availability", function () {
+ assert(Stores.databasesStore.doesDatabaseExist("db1"));
+ assert(!Stores.databasesStore.doesDatabaseExist("db3"));
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/base.js
----------------------------------------------------------------------
diff --git a/app/addons/documentation/base.js b/app/addons/documentation/base.js
index 7d94ef8..76a998b 100644
--- a/app/addons/documentation/base.js
+++ b/app/addons/documentation/base.js
@@ -10,25 +10,20 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../app',
- '../../core/api',
- './routes',
- './assets/less/documentation.less'
-],
+import app from "../../app";
+import FauxtonAPI from "../../core/api";
+import Documentation from "./routes";
+import "./assets/less/documentation.less";
-function (app, FauxtonAPI, Documentation) {
+Documentation.initialize = function () {
+ FauxtonAPI.addHeaderLink({
+ id: 'Documentation',
+ title: 'Documentation',
+ icon: 'fonticon-bookmark',
+ href: '/documentation',
+ bottomNav: true,
+ top: true
+ });
+};
- Documentation.initialize = function () {
- FauxtonAPI.addHeaderLink({
- id: 'Documentation',
- title: 'Documentation',
- icon: 'fonticon-bookmark',
- href: '/documentation',
- bottomNav: true,
- top: true
- });
- };
-
- return Documentation;
-});
+export default Documentation;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documentation/components.react.jsx b/app/addons/documentation/components.react.jsx
index dacce94..01b0ddf 100644
--- a/app/addons/documentation/components.react.jsx
+++ b/app/addons/documentation/components.react.jsx
@@ -10,58 +10,54 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../app',
- '../../core/api',
- 'react',
- './stores'
-], function (app, FauxtonAPI, React, Stores) {
-
- var documentationStore = Stores.documentationStore;
-
- var DocumentationController = React.createClass({
- getStoreState: function () {
- return {
- links: documentationStore.getLinks()
- };
- },
-
- getInitialState: function () {
- return this.getStoreState();
- },
-
- createLinkRows: function () {
- return this.state.links.map(function (linkObject) {
- return (
- <tr key={linkObject.title}>
- <td className="icons-container">
- <div className={"icon " + linkObject.iconClassName}> </div>
- </td>
- <td>
- <a href={linkObject.link} target="_blank" data-bypass="true">{linkObject.title}</a>
- </td>
- </tr>
- );
- });
- },
-
- render: function () {
+import app from "../../app";
+import FauxtonAPI from "../../core/api";
+import React from "react";
+import Stores from "./stores";
+
+var documentationStore = Stores.documentationStore;
+
+var DocumentationController = React.createClass({
+ getStoreState: function () {
+ return {
+ links: documentationStore.getLinks()
+ };
+ },
+
+ getInitialState: function () {
+ return this.getStoreState();
+ },
+
+ createLinkRows: function () {
+ return this.state.links.map(function (linkObject) {
return (
- <div id="documentation-page" className="scrollable">
- <div className="links">
- <table>
- <tbody>
- {this.createLinkRows()}
- </tbody>
- </table>
- </div>
- </div>
+ <tr key={linkObject.title}>
+ <td className="icons-container">
+ <div className={"icon " + linkObject.iconClassName}> </div>
+ </td>
+ <td>
+ <a href={linkObject.link} target="_blank" data-bypass="true">{linkObject.title}</a>
+ </td>
+ </tr>
);
- }
- });
-
- return {
- DocumentationController: DocumentationController
- };
-
+ });
+ },
+
+ render: function () {
+ return (
+ <div id="documentation-page" className="scrollable">
+ <div className="links">
+ <table>
+ <tbody>
+ {this.createLinkRows()}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ );
+ }
});
+
+export default {
+ DocumentationController: DocumentationController
+};
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documentation/resources.js b/app/addons/documentation/resources.js
index d203e08..845d5fb 100644
--- a/app/addons/documentation/resources.js
+++ b/app/addons/documentation/resources.js
@@ -1,4 +1,3 @@
-
// 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
@@ -11,8 +10,4 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([],
-function () {
- // this is empty because the compiler looks for a resource.js file here
- return null;
-});
+export default null;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/routes.js
----------------------------------------------------------------------
diff --git a/app/addons/documentation/routes.js b/app/addons/documentation/routes.js
index 5e98fa4..f09ebe8 100644
--- a/app/addons/documentation/routes.js
+++ b/app/addons/documentation/routes.js
@@ -10,30 +10,25 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../app',
- '../../core/api',
- './components.react'
-],
+import app from "../../app";
+import FauxtonAPI from "../../core/api";
+import DocumentationComponents from "./components.react";
-function (app, FauxtonAPI, DocumentationComponents) {
-
- var DocumentationRouteObject = FauxtonAPI.RouteObject.extend({
- selectedHeader: 'Documentation',
- layout: 'one_pane',
- disableLoader: false,
- routes: {
- 'documentation': 'documentation'
- },
- crumbs: [
- {'name': 'Documentation', 'link': '/documentation'}
- ],
- roles: ['fx_loggedIn'],
- documentation: function () {
- this.setComponent('#dashboard-content', DocumentationComponents.DocumentationController);
- }
- });
- DocumentationRouteObject.RouteObjects = [DocumentationRouteObject];
-
- return DocumentationRouteObject;
+var DocumentationRouteObject = FauxtonAPI.RouteObject.extend({
+ selectedHeader: 'Documentation',
+ layout: 'one_pane',
+ disableLoader: false,
+ routes: {
+ 'documentation': 'documentation'
+ },
+ crumbs: [
+ {'name': 'Documentation', 'link': '/documentation'}
+ ],
+ roles: ['fx_loggedIn'],
+ documentation: function () {
+ this.setComponent('#dashboard-content', DocumentationComponents.DocumentationController);
+ }
});
+DocumentationRouteObject.RouteObjects = [DocumentationRouteObject];
+
+export default DocumentationRouteObject;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/documentation/stores.js b/app/addons/documentation/stores.js
index 1f79c01..1f6542a 100644
--- a/app/addons/documentation/stores.js
+++ b/app/addons/documentation/stores.js
@@ -10,78 +10,74 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../app',
- '../../core/api',
-], function (app, FauxtonAPI) {
+import app from "../../app";
+import FauxtonAPI from "../../core/api";
- var DocumentationStore = FauxtonAPI.Store.extend({
- getLinks: function () {
- return [
- {
- title: 'CouchDB Official Documentation -- Online',
- link: 'http://docs.couchdb.org/en/latest/',
- iconClassName: 'couchdb-icon'
- },
- {
- title: 'CouchDB Official Documentation -- Offline',
- link: '/_utils/docs/contents.html',
- iconClassName: 'couchdb-icon'
- },
- {
- title: 'CouchDB Weekly News',
- link: 'http://blog.couchdb.org/',
- iconClassName: 'couchdb-icon'
- },
- {
- title: 'CouchDB Homepage',
- link: 'https://couchdb.apache.org/',
- iconClassName: 'couchdb-icon'
- },
- {
- title: 'CouchDB on Github',
- link: 'https://github.com/apache/couchdb',
- iconClassName: 'github-icon'
- },
- {
- title: 'Fauxton on Github',
- link: 'https://github.com/apache/couchdb-fauxton',
- iconClassName: 'github-icon'
- },
- {
- title: 'Fauxton Visual Guide',
- link: 'https://couchdb.apache.org/fauxton-visual-guide/index.html',
- iconClassName: 'couchdb-icon'
- },
- {
- title: 'The Apache Software Foundation',
- link: 'http://www.apache.org/',
- iconClassName: 'asf-feather-icon'
- },
- {
- title: 'Follow CouchDB on Twitter',
- link: 'https://twitter.com/couchdb',
- iconClassName: 'twitter-icon'
- },
- {
- title: 'Follow CouchDB on Google Plus',
- link: 'https://plus.google.com/+CouchDB',
- iconClassName: 'google-plus-icon'
- },
- {
- title: 'Follow CouchDB on LinkedIn',
- link: 'https://www.linkedin.com/company/apache-couchdb',
- iconClassName: 'linkedin-icon'
- }
- ];
+var DocumentationStore = FauxtonAPI.Store.extend({
+ getLinks: function () {
+ return [
+ {
+ title: 'CouchDB Official Documentation -- Online',
+ link: 'http://docs.couchdb.org/en/latest/',
+ iconClassName: 'couchdb-icon'
+ },
+ {
+ title: 'CouchDB Official Documentation -- Offline',
+ link: '/_utils/docs/contents.html',
+ iconClassName: 'couchdb-icon'
+ },
+ {
+ title: 'CouchDB Weekly News',
+ link: 'http://blog.couchdb.org/',
+ iconClassName: 'couchdb-icon'
+ },
+ {
+ title: 'CouchDB Homepage',
+ link: 'https://couchdb.apache.org/',
+ iconClassName: 'couchdb-icon'
+ },
+ {
+ title: 'CouchDB on Github',
+ link: 'https://github.com/apache/couchdb',
+ iconClassName: 'github-icon'
+ },
+ {
+ title: 'Fauxton on Github',
+ link: 'https://github.com/apache/couchdb-fauxton',
+ iconClassName: 'github-icon'
+ },
+ {
+ title: 'Fauxton Visual Guide',
+ link: 'https://couchdb.apache.org/fauxton-visual-guide/index.html',
+ iconClassName: 'couchdb-icon'
+ },
+ {
+ title: 'The Apache Software Foundation',
+ link: 'http://www.apache.org/',
+ iconClassName: 'asf-feather-icon'
+ },
+ {
+ title: 'Follow CouchDB on Twitter',
+ link: 'https://twitter.com/couchdb',
+ iconClassName: 'twitter-icon'
+ },
+ {
+ title: 'Follow CouchDB on Google Plus',
+ link: 'https://plus.google.com/+CouchDB',
+ iconClassName: 'google-plus-icon'
+ },
+ {
+ title: 'Follow CouchDB on LinkedIn',
+ link: 'https://www.linkedin.com/company/apache-couchdb',
+ iconClassName: 'linkedin-icon'
+ }
+ ];
- }
- });
-
- var documentationStore = new DocumentationStore();
+ }
+});
- return {
- documentationStore: documentationStore
- };
+var documentationStore = new DocumentationStore();
-});
+export default {
+ documentationStore: documentationStore
+};
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documentation/tests/nightwatch/checksDocsPage.js
----------------------------------------------------------------------
diff --git a/app/addons/documentation/tests/nightwatch/checksDocsPage.js b/app/addons/documentation/tests/nightwatch/checksDocsPage.js
index 4a44e54..c421d7c 100644
--- a/app/addons/documentation/tests/nightwatch/checksDocsPage.js
+++ b/app/addons/documentation/tests/nightwatch/checksDocsPage.js
@@ -10,6 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
+// 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.
+
module.exports = {
'Check the documentation page exists': function (client) {
var waitTime = client.globals.maxWaitTime,
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documents/base.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/base.js b/app/addons/documents/base.js
index 3de66d0..f85c573 100644
--- a/app/addons/documents/base.js
+++ b/app/addons/documents/base.js
@@ -10,201 +10,194 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "../../app",
- "../../core/api",
-
- // Modules
- "./routes",
- "./assets/less/documents.less"
-],
+import app from "../../app";
+import FauxtonAPI from "../../core/api";
+import Documents from "./routes";
+import "./assets/less/documents.less";
+
+function getQueryParam (query) {
+ if (!query) {
+ query = '';
+ }
+ return query;
+}
+
+FauxtonAPI.registerUrls( 'allDocs', {
+ server: function (id, query) {
+ return app.host + '/' + id + '/_all_docs' + getQueryParam(query);
+ },
+ app: function (id, query) {
+ return 'database/' + id + '/_all_docs' + getQueryParam(query);
+ },
+ apiurl: function (id, query) {
+ return window.location.origin + '/' + id + '/_all_docs' + getQueryParam(query);
+ }
+});
-function (app, FauxtonAPI, Documents) {
+FauxtonAPI.registerUrls('bulk_docs', {
+ server: function (id, query) {
+ return app.host + '/' + id + '/_bulk_docs' + getQueryParam(query);
+ },
+ app: function (id, query) {
+ return 'database/' + id + '/_bulk_docs' + getQueryParam(query);
+ },
+ apiurl: function (id, query) {
+ return window.location.origin + '/' + id + '/_bulk_docs' + getQueryParam(query);
+ }
+});
- function getQueryParam (query) {
- if (!query) {
- query = '';
- }
- return query;
+FauxtonAPI.registerUrls('revision-browser', {
+ app: function (id, doc) {
+ return 'database/' + id + '/' + doc + '/conflicts';
}
+});
- FauxtonAPI.registerUrls( 'allDocs', {
- server: function (id, query) {
- return app.host + '/' + id + '/_all_docs' + getQueryParam(query);
- },
- app: function (id, query) {
- return 'database/' + id + '/_all_docs' + getQueryParam(query);
- },
- apiurl: function (id, query) {
- return window.location.origin + '/' + id + '/_all_docs' + getQueryParam(query);
- }
- });
-
- FauxtonAPI.registerUrls('bulk_docs', {
- server: function (id, query) {
- return app.host + '/' + id + '/_bulk_docs' + getQueryParam(query);
- },
- app: function (id, query) {
- return 'database/' + id + '/_bulk_docs' + getQueryParam(query);
- },
- apiurl: function (id, query) {
- return window.location.origin + '/' + id + '/_bulk_docs' + getQueryParam(query);
- }
- });
+FauxtonAPI.registerUrls( 'designDocs', {
+ server: function (id, designDoc) {
+ return app.host + '/' + id + '/' + designDoc + '/_info';
+ },
- FauxtonAPI.registerUrls('revision-browser', {
- app: function (id, doc) {
- return 'database/' + id + '/' + doc + '/conflicts';
- }
- });
+ app: function (id, designDoc) {
+ return 'database/' + id + '/_design/' + app.utils.safeURLName(designDoc) + '/_info';
+ },
- FauxtonAPI.registerUrls( 'designDocs', {
- server: function (id, designDoc) {
- return app.host + '/' + id + '/' + designDoc + '/_info';
- },
+ apiurl: function (id, designDoc) {
+ return window.location.origin + '/' + id + '/' + designDoc + '/_info';
+ }
+});
- app: function (id, designDoc) {
- return 'database/' + id + '/_design/' + app.utils.safeURLName(designDoc) + '/_info';
- },
+FauxtonAPI.registerUrls( 'view', {
+ server: function (database, designDoc, viewName) {
+ return app.host + '/' + database + '/_design/' + designDoc + '/_view/' + viewName;
+ },
- apiurl: function (id, designDoc) {
- return window.location.origin + '/' + id + '/' + designDoc + '/_info';
- }
- });
+ app: function (database, designDoc) {
+ return 'database/' + database + '/_design/' + designDoc + '/_view/';
+ },
- FauxtonAPI.registerUrls( 'view', {
- server: function (database, designDoc, viewName) {
- return app.host + '/' + database + '/_design/' + designDoc + '/_view/' + viewName;
- },
+ apiurl: function (id, designDoc, viewName) {
+ return window.location.origin + '/' + id + '/_design/' + designDoc + '/_view/' + viewName;
+ },
- app: function (database, designDoc) {
- return 'database/' + database + '/_design/' + designDoc + '/_view/';
- },
+ edit: function (database, designDoc, indexName) {
+ return 'database/' + database + '/_design/' + designDoc + '/_view/' + indexName + '/edit';
+ },
- apiurl: function (id, designDoc, viewName) {
- return window.location.origin + '/' + id + '/_design/' + designDoc + '/_view/' + viewName;
- },
+ showView: function (database, designDoc, viewName) {
+ return '/database/' + database + '/' + designDoc + '/_view/' + viewName;
+ },
- edit: function (database, designDoc, indexName) {
- return 'database/' + database + '/_design/' + designDoc + '/_view/' + indexName + '/edit';
- },
+ fragment: function (database, designDoc, viewName) {
+ return 'database/' + database + designDoc + '/_view/' + viewName;
+ }
+});
- showView: function (database, designDoc, viewName) {
- return '/database/' + database + '/' + designDoc + '/_view/' + viewName;
- },
+FauxtonAPI.registerUrls('document', {
+ server: function (database, doc, query) {
+ if (_.isUndefined(query)) {
+ query = '';
+ }
+ return app.host + '/' + database + '/' + doc + query;
+ },
- fragment: function (database, designDoc, viewName) {
- return 'database/' + database + designDoc + '/_view/' + viewName;
+ attachment: function (database, doc, filename, query) {
+ if (_.isUndefined(query)) {
+ query = '';
}
- });
-
- FauxtonAPI.registerUrls('document', {
- server: function (database, doc, query) {
- if (_.isUndefined(query)) {
- query = '';
- }
- return app.host + '/' + database + '/' + doc + query;
- },
-
- attachment: function (database, doc, filename, query) {
- if (_.isUndefined(query)) {
- query = '';
- }
- return app.host + '/' + database + '/' + doc + '/' + filename + query;
- },
-
- app: function (database, doc) {
- return '/database/' + database + '/' + doc;
- },
-
- apiurl: function (database, doc) {
- if (!doc) {
- // api url for creating a doc with POST
- return window.location.origin + '/' + database;
- }
-
- return window.location.origin + '/' + database + '/' + doc;
- },
-
- 'web-index': function (database, doc) {
- return '/database/' + database + '/' + doc;
+ return app.host + '/' + database + '/' + doc + '/' + filename + query;
+ },
+
+ app: function (database, doc) {
+ return '/database/' + database + '/' + doc;
+ },
+
+ apiurl: function (database, doc) {
+ if (!doc) {
+ // api url for creating a doc with POST
+ return window.location.origin + '/' + database;
}
- });
- FauxtonAPI.registerUrls( 'new', {
- newDocument: function (database) {
- return '/database/' + database + '/new';
- },
+ return window.location.origin + '/' + database + '/' + doc;
+ },
- newView: function (database) {
- return '/database/' + database + '/new_view';
- },
+ 'web-index': function (database, doc) {
+ return '/database/' + database + '/' + doc;
+ }
+});
- addView: function (database, ddoc) {
- return '/database/' + database + '/new_view/' + ddoc;
- }
- });
+FauxtonAPI.registerUrls( 'new', {
+ newDocument: function (database) {
+ return '/database/' + database + '/new';
+ },
+
+ newView: function (database) {
+ return '/database/' + database + '/new_view';
+ },
- FauxtonAPI.registerUrls( 'base', {
- server: function (database) {
- return app.host + '/' + database + '/';
- },
+ addView: function (database, ddoc) {
+ return '/database/' + database + '/new_view/' + ddoc;
+ }
+});
- app: function (database) {
- return '/database/' + database + '/';
- },
- });
+FauxtonAPI.registerUrls( 'base', {
+ server: function (database) {
+ return app.host + '/' + database + '/';
+ },
- FauxtonAPI.registerUrls('mango', {
+ app: function (database) {
+ return '/database/' + database + '/';
+ },
+});
- 'index-server': function (db, query) {
- if (!query) {
- query = '';
- }
+FauxtonAPI.registerUrls('mango', {
- return app.host + '/' + db + '/_index' + query;
- },
+ 'index-server': function (db, query) {
+ if (!query) {
+ query = '';
+ }
- 'index-apiurl': function (db, query) {
- if (!query) {
- query = '';
- }
+ return app.host + '/' + db + '/_index' + query;
+ },
- return window.location.origin + '/' + db + '/_index' + query;
- },
+ 'index-apiurl': function (db, query) {
+ if (!query) {
+ query = '';
+ }
- 'index-app': function (db, query) {
- if (!query) {
- query = '';
- }
+ return window.location.origin + '/' + db + '/_index' + query;
+ },
- return 'database/' + db + '/_index' + query;
- },
+ 'index-app': function (db, query) {
+ if (!query) {
+ query = '';
+ }
- 'query-server': function (db, query) {
- if (!query) {
- query = '';
- }
+ return 'database/' + db + '/_index' + query;
+ },
- return app.host + '/' + db + '/_find' + query;
- },
+ 'query-server': function (db, query) {
+ if (!query) {
+ query = '';
+ }
- 'query-apiurl': function (db, query) {
- if (!query) {
- query = '';
- }
+ return app.host + '/' + db + '/_find' + query;
+ },
- return window.location.origin + '/' + db + '/_find' + query;
- },
+ 'query-apiurl': function (db, query) {
+ if (!query) {
+ query = '';
+ }
- 'query-app': function (db, query) {
- if (!query) {
- query = '';
- }
+ return window.location.origin + '/' + db + '/_find' + query;
+ },
- return 'database/' + db + '/_find' + query;
+ 'query-app': function (db, query) {
+ if (!query) {
+ query = '';
}
- });
- return Documents;
+ return 'database/' + db + '/_find' + query;
+ }
});
+
+export default Documents;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documents/changes/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/changes/actions.js b/app/addons/documents/changes/actions.js
index 2fa4c6e..4fa9fd9 100644
--- a/app/addons/documents/changes/actions.js
+++ b/app/addons/documents/changes/actions.js
@@ -10,96 +10,91 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- './actiontypes',
- './stores',
- '../helpers'
-],
-function (app, FauxtonAPI, ActionTypes, Stores, Helpers) {
-
- var changesStore = Stores.changesStore;
- var pollingTimeout = 60000;
- var currentRequest;
-
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import ActionTypes from "./actiontypes";
+import Stores from "./stores";
+import Helpers from "../helpers";
+
+var changesStore = Stores.changesStore;
+var pollingTimeout = 60000;
+var currentRequest;
+
+
+export default {
+ toggleTabVisibility: function () {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.TOGGLE_CHANGES_TAB_VISIBILITY
+ });
+ },
+
+ addFilter: function (filter) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.ADD_CHANGES_FILTER_ITEM,
+ filter: filter
+ });
+ },
+
+ removeFilter: function (filter) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.REMOVE_CHANGES_FILTER_ITEM,
+ filter: filter
+ });
+ },
+
+ initChanges: function (options) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.INIT_CHANGES,
+ options: options
+ });
+ currentRequest = null;
+ this.getLatestChanges();
+ },
+
+ getLatestChanges: function () {
+ var params = {
+ limit: 100
+ };
+
+ // after the first request for the changes list has been made, switch to longpoll
+ if (currentRequest) {
+ params.since = changesStore.getLastSeqNum();
+ params.timeout = pollingTimeout;
+ params.feed = 'longpoll';
+ }
- return {
- toggleTabVisibility: function () {
- FauxtonAPI.dispatch({
- type: ActionTypes.TOGGLE_CHANGES_TAB_VISIBILITY
- });
- },
+ var query = $.param(params);
+ var db = app.utils.safeURLName(changesStore.getDatabaseName());
- addFilter: function (filter) {
- FauxtonAPI.dispatch({
- type: ActionTypes.ADD_CHANGES_FILTER_ITEM,
- filter: filter
- });
- },
+ var endpoint = FauxtonAPI.urls('changes', 'server', db, '');
+ currentRequest = $.getJSON(endpoint);
+ currentRequest.then(_.bind(this.updateChanges, this));
+ },
- removeFilter: function (filter) {
+ updateChanges: function (json) {
+ // only bother updating the list of changes if the seq num has changed
+ var latestSeqNum = Helpers.getSeqNum(json.last_seq);
+ if (latestSeqNum !== changesStore.getLastSeqNum()) {
FauxtonAPI.dispatch({
- type: ActionTypes.REMOVE_CHANGES_FILTER_ITEM,
- filter: filter
+ type: ActionTypes.UPDATE_CHANGES,
+ changes: json.results,
+ seqNum: latestSeqNum
});
- },
+ }
- initChanges: function (options) {
- FauxtonAPI.dispatch({
- type: ActionTypes.INIT_CHANGES,
- options: options
- });
- currentRequest = null;
+ if (changesStore.pollingEnabled()) {
this.getLatestChanges();
- },
-
- getLatestChanges: function () {
- var params = {
- limit: 100
- };
-
- // after the first request for the changes list has been made, switch to longpoll
- if (currentRequest) {
- params.since = changesStore.getLastSeqNum();
- params.timeout = pollingTimeout;
- params.feed = 'longpoll';
- }
-
- var query = $.param(params);
- var db = app.utils.safeURLName(changesStore.getDatabaseName());
-
- var endpoint = FauxtonAPI.urls('changes', 'server', db, '');
- currentRequest = $.getJSON(endpoint);
- currentRequest.then(_.bind(this.updateChanges, this));
- },
-
- updateChanges: function (json) {
- // only bother updating the list of changes if the seq num has changed
- var latestSeqNum = Helpers.getSeqNum(json.last_seq);
- if (latestSeqNum !== changesStore.getLastSeqNum()) {
- FauxtonAPI.dispatch({
- type: ActionTypes.UPDATE_CHANGES,
- changes: json.results,
- seqNum: latestSeqNum
- });
- }
-
- if (changesStore.pollingEnabled()) {
- this.getLatestChanges();
- }
- },
+ }
+ },
- togglePolling: function () {
- FauxtonAPI.dispatch({ type: ActionTypes.TOGGLE_CHANGES_POLLING });
+ togglePolling: function () {
+ FauxtonAPI.dispatch({ type: ActionTypes.TOGGLE_CHANGES_POLLING });
- // the user just enabled polling. Start 'er up
- if (changesStore.pollingEnabled()) {
- this.getLatestChanges();
- } else {
- currentRequest.abort();
- }
+ // the user just enabled polling. Start 'er up
+ if (changesStore.pollingEnabled()) {
+ this.getLatestChanges();
+ } else {
+ currentRequest.abort();
}
- };
-
-});
+ }
+};
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/documents/changes/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/changes/actiontypes.js b/app/addons/documents/changes/actiontypes.js
index edca4b9..04d217d 100644
--- a/app/addons/documents/changes/actiontypes.js
+++ b/app/addons/documents/changes/actiontypes.js
@@ -10,15 +10,13 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([], function () {
- return {
- INIT_CHANGES: 'INIT_CHANGES',
- UPDATE_CHANGES: 'UPDATE_CHANGES',
- TOGGLE_CHANGES_TAB_VISIBILITY: 'TOGGLE_CHANGES_TAB_VISIBILITY',
- ADD_CHANGES_FILTER_ITEM: 'ADD_CHANGES_FILTER_ITEM',
- REMOVE_CHANGES_FILTER_ITEM: 'REMOVE_CHANGES_FILTER_ITEM',
- UPDATE_CHANGES_FILTER: 'UPDATE_CHANGES_FILTER',
- TOGGLE_CHANGES_CODE_VISIBILITY: 'TOGGLE_CHANGES_CODE_VISIBILITY',
- TOGGLE_CHANGES_POLLING: 'TOGGLE_CHANGES_POLLING'
- };
-});
+export default {
+ INIT_CHANGES: 'INIT_CHANGES',
+ UPDATE_CHANGES: 'UPDATE_CHANGES',
+ TOGGLE_CHANGES_TAB_VISIBILITY: 'TOGGLE_CHANGES_TAB_VISIBILITY',
+ ADD_CHANGES_FILTER_ITEM: 'ADD_CHANGES_FILTER_ITEM',
+ REMOVE_CHANGES_FILTER_ITEM: 'REMOVE_CHANGES_FILTER_ITEM',
+ UPDATE_CHANGES_FILTER: 'UPDATE_CHANGES_FILTER',
+ TOGGLE_CHANGES_CODE_VISIBILITY: 'TOGGLE_CHANGES_CODE_VISIBILITY',
+ TOGGLE_CHANGES_POLLING: 'TOGGLE_CHANGES_POLLING'
+};