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:30 UTC
[02/27] fauxton commit: updated refs/heads/master to 0ca35da
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/verifyinstall/tests/actionsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/verifyinstall/tests/actionsSpec.js b/app/addons/verifyinstall/tests/actionsSpec.js
index c1c4751..5560d78 100644
--- a/app/addons/verifyinstall/tests/actionsSpec.js
+++ b/app/addons/verifyinstall/tests/actionsSpec.js
@@ -10,25 +10,21 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- '../../../../test/mocha/testUtils',
- '../stores',
- '../actiontypes',
- 'sinon'
-], function (app, FauxtonAPI, testUtils, Stores, ActionTypes, sinon) {
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import testUtils from "../../../../test/mocha/testUtils";
+import Stores from "../stores";
+import ActionTypes from "../actiontypes";
+import sinon from "sinon";
- var assert = testUtils.assert;
+var assert = testUtils.assert;
- describe('Verify Install Actions', function () {
-
- it('resets the store when action called', function () {
- var spy = sinon.spy(Stores.verifyInstallStore, 'reset');
- FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_RESET });
- assert.ok(spy.calledOnce);
- });
+describe('Verify Install Actions', function () {
+ it('resets the store when action called', function () {
+ var spy = sinon.spy(Stores.verifyInstallStore, 'reset');
+ FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_RESET });
+ assert.ok(spy.calledOnce);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/verifyinstall/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/verifyinstall/tests/componentsSpec.react.jsx b/app/addons/verifyinstall/tests/componentsSpec.react.jsx
index 9ba5b4c..2d33160 100644
--- a/app/addons/verifyinstall/tests/componentsSpec.react.jsx
+++ b/app/addons/verifyinstall/tests/componentsSpec.react.jsx
@@ -10,128 +10,122 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- 'react',
- 'react-dom',
- '../../../../test/mocha/testUtils',
- '../constants',
- '../components.react',
- 'react-addons-test-utils',
- 'sinon'
-
-], function (app, FauxtonAPI, React, ReactDOM, testUtils, Constants, Components, TestUtils, sinon) {
- FauxtonAPI.router = new FauxtonAPI.Router([]);
-
- var assert = testUtils.assert;
-
- describe('VerifyInstallResults', function () {
- var container, el;
-
- var tests = [
- { key: 'CREATE_DATABASE', id: 'js-test-create-db' },
- { key: 'CREATE_DOCUMENT', id: 'js-test-create-doc' },
- { key: 'UPDATE_DOCUMENT', id: 'js-test-update-doc' },
- { key: 'DELETE_DOCUMENT', id: 'js-test-delete-doc' },
- { key: 'CREATE_VIEW', id: 'js-test-create-view' },
- { key: 'REPLICATION', id: 'js-test-replication' }
- ];
-
- var testResults = {};
- tests.forEach(function (test) {
- testResults[Constants.TESTS[test.key]] = { complete: false };
- });
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import React from "react";
+import ReactDOM from "react-dom";
+import testUtils from "../../../../test/mocha/testUtils";
+import Constants from "../constants";
+import Components from "../components.react";
+import TestUtils from "react-addons-test-utils";
+import sinon from "sinon";
+FauxtonAPI.router = new FauxtonAPI.Router([]);
+
+var assert = testUtils.assert;
+
+describe('VerifyInstallResults', function () {
+ var container, el;
+
+ var tests = [
+ { key: 'CREATE_DATABASE', id: 'js-test-create-db' },
+ { key: 'CREATE_DOCUMENT', id: 'js-test-create-doc' },
+ { key: 'UPDATE_DOCUMENT', id: 'js-test-update-doc' },
+ { key: 'DELETE_DOCUMENT', id: 'js-test-delete-doc' },
+ { key: 'CREATE_VIEW', id: 'js-test-create-view' },
+ { key: 'REPLICATION', id: 'js-test-replication' }
+ ];
+
+ var testResults = {};
+ tests.forEach(function (test) {
+ testResults[Constants.TESTS[test.key]] = { complete: false };
+ });
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
- });
+ afterEach(function () {
+ ReactDOM.unmountComponentAtNode(container);
+ });
- it('confirm all result fields blank before tests ran', function () {
- container = document.createElement('div');
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={testResults} />, container);
+ it('confirm all result fields blank before tests ran', function () {
+ container = document.createElement('div');
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={testResults} />, container);
- tests.forEach(function (test) {
- assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id).html(), '');
- });
+ tests.forEach(function (test) {
+ assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id).html(), '');
});
+ });
- it('confirm each result field shows success after successful test', function () {
- tests.forEach(function (test) {
- var copy = _.clone(testResults);
+ it('confirm each result field shows success after successful test', function () {
+ tests.forEach(function (test) {
+ var copy = _.clone(testResults);
- // mark this single test as complete
- copy[Constants.TESTS[test.key]] = {
- complete: true,
- success: true
- };
+ // mark this single test as complete
+ copy[Constants.TESTS[test.key]] = {
+ complete: true,
+ success: true
+ };
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={copy} />, container);
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={copy} />, container);
- // now look at the DOM for that element. It should contain a tick char
- assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id + ' span').html(), '\u2713');
- });
+ // now look at the DOM for that element. It should contain a tick char
+ assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id + ' span').html(), '\u2713');
});
+ });
- it('confirm each result field shows error marker after failed test', function () {
- tests.forEach(function (test) {
- var copy = _.clone(testResults);
+ it('confirm each result field shows error marker after failed test', function () {
+ tests.forEach(function (test) {
+ var copy = _.clone(testResults);
- // mark this single test as complete
- copy[Constants.TESTS[test.key]] = {
- complete: true,
- success: false
- };
+ // mark this single test as complete
+ copy[Constants.TESTS[test.key]] = {
+ complete: true,
+ success: false
+ };
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={copy} />, container);
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallResults testResults={copy} />, container);
- // now look at the DOM for that element. It should contain an error char
- assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id + ' span').html(), '\u2717');
- });
+ // now look at the DOM for that element. It should contain an error char
+ assert.equal($(ReactDOM.findDOMNode(el)).find('#' + test.id + ' span').html(), '\u2717');
});
});
+});
- describe('VerifyInstallButton', function () {
- var container, el;
-
- beforeEach(function () {
- container = document.createElement('div');
- });
-
- afterEach(function () {
- ReactDOM.unmountComponentAtNode(container);
- });
+describe('VerifyInstallButton', function () {
+ var container, el;
- it('calls verify function on click', function () {
- var stub = { func: function () { } };
- var spy = sinon.spy(stub, 'func');
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={false} />, container);
- TestUtils.Simulate.click($(ReactDOM.findDOMNode(el))[0]);
- assert.ok(spy.calledOnce);
- });
+ beforeEach(function () {
+ container = document.createElement('div');
+ });
- it('does not call verify function when verification already ongoing', function () {
- var stub = { func: function () { } };
- var spy = sinon.spy(stub, 'func');
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={true} />, container);
- TestUtils.Simulate.click($(ReactDOM.findDOMNode(el))[0]);
- assert.notOk(spy.calledOnce);
- });
+ afterEach(function () {
+ ReactDOM.unmountComponentAtNode(container);
+ });
- it('shows appropriate default label', function () {
- var stub = { func: function () { } };
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={false} />, container);
- assert.equal($(ReactDOM.findDOMNode(el)).html(), 'Verify Installation');
- });
+ it('calls verify function on click', function () {
+ var stub = { func: function () { } };
+ var spy = sinon.spy(stub, 'func');
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={false} />, container);
+ TestUtils.Simulate.click($(ReactDOM.findDOMNode(el))[0]);
+ assert.ok(spy.calledOnce);
+ });
- it('shows appropriate label during verification', function () {
- var stub = { func: function () { } };
- el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={true} />, container);
- assert.equal($(ReactDOM.findDOMNode(el)).html(), 'Verifying');
- });
+ it('does not call verify function when verification already ongoing', function () {
+ var stub = { func: function () { } };
+ var spy = sinon.spy(stub, 'func');
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={true} />, container);
+ TestUtils.Simulate.click($(ReactDOM.findDOMNode(el))[0]);
+ assert.notOk(spy.calledOnce);
+ });
+ it('shows appropriate default label', function () {
+ var stub = { func: function () { } };
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={false} />, container);
+ assert.equal($(ReactDOM.findDOMNode(el)).html(), 'Verify Installation');
});
+ it('shows appropriate label during verification', function () {
+ var stub = { func: function () { } };
+ el = TestUtils.renderIntoDocument(<Components.VerifyInstallButton verify={stub.func} isVerifying={true} />, container);
+ assert.equal($(ReactDOM.findDOMNode(el)).html(), 'Verifying');
+ });
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/addons/verifyinstall/tests/verifyinstall.storesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/verifyinstall/tests/verifyinstall.storesSpec.js b/app/addons/verifyinstall/tests/verifyinstall.storesSpec.js
index 01d0647..eeddf7d 100644
--- a/app/addons/verifyinstall/tests/verifyinstall.storesSpec.js
+++ b/app/addons/verifyinstall/tests/verifyinstall.storesSpec.js
@@ -10,42 +10,38 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../../../app',
- '../../../core/api',
- '../../../../test/mocha/testUtils',
- '../stores',
- '../actiontypes'
-], function (app, FauxtonAPI, testUtils, Stores, ActionTypes) {
+import app from "../../../app";
+import FauxtonAPI from "../../../core/api";
+import testUtils from "../../../../test/mocha/testUtils";
+import Stores from "../stores";
+import ActionTypes from "../actiontypes";
- var assert = testUtils.assert;
+var assert = testUtils.assert;
- describe('VerifyInstallStore', function () {
+describe('VerifyInstallStore', function () {
- afterEach(function () {
- Stores.verifyInstallStore.reset();
- });
-
- it('check store defaults', function () {
- assert.ok(Stores.verifyInstallStore.checkIsVerifying() === false);
+ afterEach(function () {
+ Stores.verifyInstallStore.reset();
+ });
- // confirm all the tests are initially marked as incomplete
- var tests = Stores.verifyInstallStore.getTestResults();
- _.each(tests, function (test) {
- assert.ok(test.complete === false);
- });
- });
+ it('check store defaults', function () {
+ assert.ok(Stores.verifyInstallStore.checkIsVerifying() === false);
- it('publishing start event changes state in store', function () {
- FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_START });
- assert.ok(Stores.verifyInstallStore.checkIsVerifying() === true);
+ // confirm all the tests are initially marked as incomplete
+ var tests = Stores.verifyInstallStore.getTestResults();
+ _.each(tests, function (test) {
+ assert.ok(test.complete === false);
});
+ });
- it('publishing completion event changes state in store', function () {
- FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_ALL_TESTS_COMPLETE });
- assert.ok(Stores.verifyInstallStore.checkIsVerifying() === false);
- });
+ it('publishing start event changes state in store', function () {
+ FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_START });
+ assert.ok(Stores.verifyInstallStore.checkIsVerifying() === true);
+ });
+ it('publishing completion event changes state in store', function () {
+ FauxtonAPI.dispatch({ type: ActionTypes.VERIFY_INSTALL_ALL_TESTS_COMPLETE });
+ assert.ok(Stores.verifyInstallStore.checkIsVerifying() === false);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/app.js
----------------------------------------------------------------------
diff --git a/app/app.js b/app/app.js
index 06fa67a..bb449fa 100644
--- a/app/app.js
+++ b/app/app.js
@@ -10,123 +10,110 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- // application.
- './initialize',
-
- // libraries
- 'jquery',
- 'lodash',
- 'backbone',
- 'bootstrap',
- './helpers',
- './core/utils',
-
- // modules
- './core/api',
- './core/couchdbSession',
-
- // plugins
- 'backbone.layoutmanager',
- "../assets/less/fauxton.less"
-],
-
-function (app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
-
- // Make sure we have a console.log
- if (_.isUndefined(console)) {
- console = {
- log: function () {},
- trace: function () {},
- debug: function () {}
- };
+import app from "./initialize";
+import $ from "jquery";
+import _ from "lodash";
+import Backbone from "backbone";
+import Bootstrap from "bootstrap";
+import Helpers from "./helpers";
+import Utils from "./core/utils";
+import FauxtonAPI from "./core/api";
+import Couchdb from "./core/couchdbSession";
+import "backbone.layoutmanager";
+import "../assets/less/fauxton.less";
+
+// Make sure we have a console.log
+if (_.isUndefined(console)) {
+ console = {
+ log: function () {},
+ trace: function () {},
+ debug: function () {}
+ };
+}
+
+// make sure we have location.origin
+if (_.isUndefined(window.location.origin)) {
+ var port = '';
+ if (window.location.port) {
+ port = ':' + window.location.port;
}
+ window.location.origin = window.location.protocol + '//' +
+ window.location.hostname + port;
+}
+
+// Provide a global location to place configuration settings and module
+// creation also mix in Backbone.Events
+Object.assign(app, {
+ utils: Utils,
+ getParams: FauxtonAPI.utils.getParams,
+ helpers: Helpers
+});
- // make sure we have location.origin
- if (_.isUndefined(window.location.origin)) {
- var port = '';
- if (window.location.port) {
- port = ':' + window.location.port;
- }
- window.location.origin = window.location.protocol + '//' +
- window.location.hostname + port;
- }
-
- // Provide a global location to place configuration settings and module
- // creation also mix in Backbone.Events
- _.extend(app, {
- utils: Utils,
- getParams: FauxtonAPI.utils.getParams,
- helpers: Helpers
- });
-
- // Localize or create a new JavaScript Template object
- var JST = window.JST = window.JST || {};
-
- // Configure LayoutManager with Backbone Boilerplate defaults
- FauxtonAPI.Layout.configure({
- // Allow LayoutManager to augment Backbone.View.prototype.
- manage: true,
- prefix: 'app/',
-
- // Inject app/helper.js for shared functionality across all html templates
- renderTemplate: function (template, context) {
- return template(_.extend(Helpers, context));
- },
-
- fetchTemplate: function (path) {
- // Initialize done for use in async-mode
- var done;
-
- // Concatenate the file extension.
- path = path + '.html';
-
- // If cached, use the compiled template.
- if (JST[path]) {
- return JST[path];
- } else {
- // Put fetch into `async-mode`.
- done = this.async();
- // Seek out the template asynchronously.
- return $.ajax({ url: app.root + path }).then(function (contents) {
- done(JST[path] = _.template(contents));
- });
- }
- }
- });
-
- FauxtonAPI.setSession(new Couchdb.Session());
-
-
- // Define your master router on the application namespace and trigger all
- // navigation from this instance.
- FauxtonAPI.config({
- el: '.wrapper',
- masterLayout: new FauxtonAPI.Layout(),
-
- // I haven't wrapped these dispatch methods in a action
- // because I don't want to require fauxton/actions in this method.
- addHeaderLink: function (link) {
- FauxtonAPI.dispatch({
- type: 'ADD_NAVBAR_LINK',
- link: link
- });
- },
-
- updateHeaderLink: function (link) {
- FauxtonAPI.dispatch({
- type: 'UPDATE_NAVBAR_LINK',
- link: link
- });
- },
-
- removeHeaderLink: function (link) {
- FauxtonAPI.dispatch({
- type: 'REMOVE_NAVBAR_LINK',
- link: link
+// Localize or create a new JavaScript Template object
+const JST = window.JST = window.JST || {};
+
+// Configure LayoutManager with Backbone Boilerplate defaults
+FauxtonAPI.Layout.configure({
+ // Allow LayoutManager to augment Backbone.View.prototype.
+ manage: true,
+ prefix: 'app/',
+
+ // Inject app/helper.js for shared functionality across all html templates
+ renderTemplate: function (template, context) {
+ return template(_.extend(Helpers, context));
+ },
+
+ fetchTemplate: function (path) {
+ // Initialize done for use in async-mode
+ let done;
+
+ // Concatenate the file extension.
+ path = path + '.html';
+
+ // If cached, use the compiled template.
+ if (JST[path]) {
+ return JST[path];
+ } else {
+ // Put fetch into `async-mode`.
+ done = this.async();
+ // Seek out the template asynchronously.
+ return $.ajax({ url: app.root + path }).then(function (contents) {
+ done(JST[path] = _.template(contents));
});
}
- });
+ }
+});
- return app;
+FauxtonAPI.setSession(new Couchdb.Session());
+
+// Define your master router on the application namespace and trigger all
+// navigation from this instance.
+FauxtonAPI.config({
+ el: '.wrapper',
+ masterLayout: new FauxtonAPI.Layout(),
+
+ // I haven't wrapped these dispatch methods in a action
+ // because I don't want to require fauxton/actions in this method.
+ addHeaderLink: function (link) {
+ FauxtonAPI.dispatch({
+ type: 'ADD_NAVBAR_LINK',
+ link: link
+ });
+ },
+
+ updateHeaderLink: function (link) {
+ FauxtonAPI.dispatch({
+ type: 'UPDATE_NAVBAR_LINK',
+ link: link
+ });
+ },
+
+ removeHeaderLink: function (link) {
+ FauxtonAPI.dispatch({
+ type: 'REMOVE_NAVBAR_LINK',
+ link: link
+ });
+ }
});
+
+export default app;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/constants.js
----------------------------------------------------------------------
diff --git a/app/constants.js b/app/constants.js
index a90b21d..cbda246 100644
--- a/app/constants.js
+++ b/app/constants.js
@@ -10,51 +10,47 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([], function () {
+export default {
- var constants = {
+ MISC: {
+ TRAY_TOGGLE_SPEED: 250,
+ DEFAULT_PAGE_SIZE: 20,
+ MODAL_BACKDROP_Z_INDEX: 1025
+ },
- MISC: {
- TRAY_TOGGLE_SPEED: 250,
- DEFAULT_PAGE_SIZE: 20,
- MODAL_BACKDROP_Z_INDEX: 1025
- },
+ DATABASES: {
+ DOCUMENT_LIMIT: 100
+ },
- DATABASES: {
- DOCUMENT_LIMIT: 100
- },
+ // global events for common used components
+ EVENTS: {
+ TRAY_OPENED: 'tray:opened',
+ NAVBAR_SIZE_CHANGED: 'navbar:size_changed'
+ },
- // global events for common used components
- EVENTS: {
- TRAY_OPENED: 'tray:opened',
- NAVBAR_SIZE_CHANGED: 'navbar:size_changed'
- },
+ // documentation URLs
+ DOC_URLS: {
+ GENERAL: '/_utils/docs/intro/api.html#documents',
+ ALL_DBS: '/_utils/docs/api/server/common.html?highlight=all_dbs#get--_all_dbs',
+ REPLICATION: '/_utils/docs/replication/replicator.html#basics',
+ DESIGN_DOCS: '/_utils/docs/couchapp/ddocs.html#design-docs',
+ DESIGN_DOC_METADATA: '/_utils/docs/api/ddoc/common.html#api-ddoc-view-index-info',
+ VIEW_FUNCS: '/_utils/docs/couchapp/ddocs.html#view-functions',
+ MAP_FUNCS: '/_utils/docs/couchapp/ddocs.html#map-functions',
+ REDUCE_FUNCS: '/_utils/docs/couchapp/ddocs.html#reduce-and-rereduce-functions',
+ API_REF: '/_utils/docs/http-api.html',
+ DB_PERMISSION: '/_utils/docs/api/database/security.html#db-security',
+ STATS: '/_utils/docs/api/server/common.html?highlight=stats#get--_stats',
+ ACTIVE_TASKS: '/_utils/docs/api/server/common.html?highlight=stats#active-tasks',
+ LOG: '/_utils/docs/api/server/common.html?highlight=stats#log',
+ CONFIG: '/_utils/docs/config/index.html',
+ VIEWS: '/_utils/docs/intro/overview.html#views',
+ MANGO_INDEX: '/_utils/docs/intro/api.html#documents',
+ MANGO_SEARCH: '/_utils/docs/intro/api.html#documents',
+ CHANGES: '/_utils/docs/api/database/changes.html?highlight=changes#post--db-_changes'
+ },
- // documentation URLs
- DOC_URLS: {
- GENERAL: '/_utils/docs/intro/api.html#documents',
- ALL_DBS: '/_utils/docs/api/server/common.html?highlight=all_dbs#get--_all_dbs',
- REPLICATION: '/_utils/docs/replication/replicator.html#basics',
- DESIGN_DOCS: '/_utils/docs/couchapp/ddocs.html#design-docs',
- DESIGN_DOC_METADATA: '/_utils/docs/api/ddoc/common.html#api-ddoc-view-index-info',
- VIEW_FUNCS: '/_utils/docs/couchapp/ddocs.html#view-functions',
- MAP_FUNCS: '/_utils/docs/couchapp/ddocs.html#map-functions',
- REDUCE_FUNCS: '/_utils/docs/couchapp/ddocs.html#reduce-and-rereduce-functions',
- API_REF: '/_utils/docs/http-api.html',
- DB_PERMISSION: '/_utils/docs/api/database/security.html#db-security',
- STATS: '/_utils/docs/api/server/common.html?highlight=stats#get--_stats',
- ACTIVE_TASKS: '/_utils/docs/api/server/common.html?highlight=stats#active-tasks',
- LOG: '/_utils/docs/api/server/common.html?highlight=stats#log',
- CONFIG: '/_utils/docs/config/index.html',
- VIEWS: '/_utils/docs/intro/overview.html#views',
- MANGO_INDEX: '/_utils/docs/intro/api.html#documents',
- MANGO_SEARCH: '/_utils/docs/intro/api.html#documents',
- CHANGES: '/_utils/docs/api/database/changes.html?highlight=changes#post--db-_changes'
- },
-
- LOCAL_STORAGE: {
- SIDEBAR_MINIMIZED: 'sidebar-minimized'
- }
- };
- return constants;
-});
+ LOCAL_STORAGE: {
+ SIDEBAR_MINIMIZED: 'sidebar-minimized'
+ }
+};
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/api.js
----------------------------------------------------------------------
diff --git a/app/core/api.js b/app/core/api.js
index 5573cf6..6240337 100644
--- a/app/core/api.js
+++ b/app/core/api.js
@@ -10,108 +10,102 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- './base',
- './layout',
- './router',
- './routeObject',
- './utils',
- './store',
- '../constants',
-
- 'flux',
- 'jquery',
- 'backbone'
-],
-
-function (FauxtonAPI, Layout, Router, RouteObject, utils, Store, constants, Flux, $, Backbone) {
- Backbone.$ = $;
- Backbone.ajax = function () {
- return Backbone.$.ajax.apply(Backbone.$, arguments);
- };
-
- FauxtonAPI = _.extend(FauxtonAPI, {
- Layout: Layout,
- Router: Router,
- RouteObject: RouteObject,
- utils: utils,
- Store: Store,
- Events: _.extend({}, Backbone.Events),
- dispatcher: new Flux.Dispatcher()
- });
+import FauxtonAPI from "./base";
+import Layout from "./layout";
+import Router from "./router";
+import RouteObject from "./routeObject";
+import utils from "./utils";
+import Store from "./store";
+import constants from "../constants";
+import Flux from "flux";
+import $ from "jquery";
+import Backbone from "backbone";
+Backbone.$ = $;
+Backbone.ajax = function () {
+ return Backbone.$.ajax.apply(Backbone.$, arguments);
+ };
- // Pass along all constants
- FauxtonAPI.constants = constants;
+Object.assign(FauxtonAPI, {
+ Layout: Layout,
+ Router: Router,
+ RouteObject: RouteObject,
+ utils: utils,
+ Store: Store,
+ Events: _.extend({}, Backbone.Events),
+ dispatcher: new Flux.Dispatcher()
+});
- FauxtonAPI.dispatch = _.bind(FauxtonAPI.dispatcher.dispatch, FauxtonAPI.dispatcher);
+// Pass along all constants
+FauxtonAPI.constants = constants;
- FauxtonAPI.navigate = function (url, _opts) {
- var options = _.extend({trigger: true}, _opts);
- FauxtonAPI.router.navigate(url, options);
- };
+FauxtonAPI.dispatch = _.bind(FauxtonAPI.dispatcher.dispatch, FauxtonAPI.dispatcher);
- FauxtonAPI.beforeUnload = function () {
- FauxtonAPI.router.beforeUnload.apply(FauxtonAPI.router, arguments);
- };
+FauxtonAPI.navigate = function (url, _opts) {
+ var options = _.extend({trigger: true}, _opts);
+ FauxtonAPI.router.navigate(url, options);
+};
- FauxtonAPI.removeBeforeUnload = function () {
- FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments);
- };
+FauxtonAPI.beforeUnload = function () {
+ FauxtonAPI.router.beforeUnload.apply(FauxtonAPI.router, arguments);
+};
- FauxtonAPI.addRoute = function (route) {
- FauxtonAPI.router.route(route.route, route.name, route.callback);
- };
+FauxtonAPI.removeBeforeUnload = function () {
+ FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments);
+};
- FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
- FauxtonAPI.router.triggerRouteEvent('route:' + routeEvent, args);
- };
+FauxtonAPI.addRoute = function (route) {
+ FauxtonAPI.router.route(route.route, route.name, route.callback);
+};
- var urlPaths = {};
+FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
+ FauxtonAPI.router.triggerRouteEvent('route:' + routeEvent, args);
+};
- FauxtonAPI.registerUrls = function (namespace, urls) {
- urlPaths[namespace] = urls;
- };
+var urlPaths = {};
- //This is a little rough and needs some improvement. But the basic concept is there
- FauxtonAPI.urls = function (name, context) {
- var interceptors = FauxtonAPI.getExtensions('urls:interceptors');
- var url;
+FauxtonAPI.registerUrls = function (namespace, urls) {
+ urlPaths[namespace] = urls;
+};
- var args = arguments;
- _.find(interceptors, function (interceptor) {
- var out = interceptor.apply(null, args);
+//This is a little rough and needs some improvement. But the basic concept is there
+FauxtonAPI.urls = function (name, context) {
+ var interceptors = FauxtonAPI.getExtensions('urls:interceptors');
+ var url;
- if (out) {
- url = out;
- return true;
- }
- return false;
- });
+ var args = arguments;
+ _.find(interceptors, function (interceptor) {
+ var out = interceptor.apply(null, args);
- if (!_.isUndefined(url)) { return url; }
-
- if (!urlPaths[name]) {
- console.error('could not find name ', name);
- return '';
+ if (out) {
+ url = out;
+ return true;
}
+ return false;
+ });
- if (!urlPaths[name][context]) {
- console.error('could not find context ', context);
- return '';
- }
+ if (!_.isUndefined(url)) { return url; }
- args = Array.prototype.slice.call(arguments, 2);
- url = urlPaths[name][context].apply(null, args);
- return url;
- };
+ if (!urlPaths[name]) {
+ console.error('could not find name ', name);
+ return '';
+ }
- // out-the-box Fauxton has only Views, but scripts extending Fauxton may introduce others (search indexes, geospatial
- // indexes, etc). This returns an array of the special design doc property names for the index types
- FauxtonAPI.getIndexTypePropNames = function () {
- var indexTypes = FauxtonAPI.getExtensions('IndexTypes:propNames');
- indexTypes.push('views');
- return indexTypes;
- };
+ if (!urlPaths[name][context]) {
+ console.error('could not find context ', context);
+ return '';
+ }
- return FauxtonAPI;
-});
+ args = Array.prototype.slice.call(arguments, 2);
+ url = urlPaths[name][context].apply(null, args);
+ return url;
+};
+
+// out-the-box Fauxton has only Views, but scripts extending Fauxton may introduce others (search indexes, geospatial
+// indexes, etc). This returns an array of the special design doc property names for the index types
+FauxtonAPI.getIndexTypePropNames = function () {
+ var indexTypes = FauxtonAPI.getExtensions('IndexTypes:propNames');
+ indexTypes.push('views');
+ return indexTypes;
+};
+
+export default FauxtonAPI;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/auth.js
----------------------------------------------------------------------
diff --git a/app/core/auth.js b/app/core/auth.js
index 09c854b..f0a82f1 100644
--- a/app/core/auth.js
+++ b/app/core/auth.js
@@ -10,55 +10,51 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "./base",
- "backbone"
-],
-function (FauxtonAPI, Backbone) {
+import FauxtonAPI from "./base";
+import Backbone from "backbone";
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
+// This is not exposed externally as it should not need to be accessed or overridden
+var Auth = function (options) {
+ this._options = options;
+ this.initialize.apply(this, arguments);
+};
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
+// Piggy-back on Backbone's self-propagating extend function,
+Auth.extend = Backbone.Model.extend;
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function () {},
+_.extend(Auth.prototype, Backbone.Events, {
+ authDeniedCb: function () {},
- initialize: function () {
- var that = this;
- },
+ initialize: function () {
+ var that = this;
+ },
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
+ authHandlerCb : function (roles) {
+ var deferred = $.Deferred();
+ deferred.resolve();
+ return deferred;
+ },
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
+ registerAuth: function (authHandlerCb) {
+ this.authHandlerCb = authHandlerCb;
+ },
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
+ registerAuthDenied: function (authDeniedCb) {
+ this.authDeniedCb = authDeniedCb;
+ },
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
+ checkAccess: function (roles) {
+ var requiredRoles = roles || [],
+ that = this;
- if (!FauxtonAPI.session) {
- throw new Error("Fauxton.session is not configured.");
- }
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
+ if (!FauxtonAPI.session) {
+ throw new Error("Fauxton.session is not configured.");
}
- });
- return Auth;
+ return FauxtonAPI.session.fetchUser().then(function (user) {
+ return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
+ });
+ }
});
+
+export default Auth;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/base.js
----------------------------------------------------------------------
diff --git a/app/core/base.js b/app/core/base.js
index 5825d79..cf3b2dc 100644
--- a/app/core/base.js
+++ b/app/core/base.js
@@ -10,134 +10,129 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "backbone",
- "backbone.layoutmanager"
-],
-
-function (Backbone, LayoutManager) {
- var FauxtonAPI = {
- //add default objects
- router: {
- navigate: function () {}
- },
-
- masterLayout: {},
+import Backbone from "backbone";
+import LayoutManager from "backbone.layoutmanager";
+var FauxtonAPI = {
+ //add default objects
+ router: {
+ navigate: function () {}
+ },
+
+ masterLayout: {},
+
+ addNotification: function () {},
+
+ config: function (options) {
+ return _.extend(this, options);
+ }
+};
+
+FauxtonAPI.Deferred = function () {
+ return $.Deferred();
+};
+
+FauxtonAPI.when = function (deferreds) {
+ if (deferreds instanceof Array) {
+ return $.when.apply(null, deferreds);
+ }
+
+ return $.when(deferreds);
+};
+
+FauxtonAPI.addonExtensions = {
+ initialize: function () {},
+ RouteObjects: {},
+ Views: {}
+};
+
+FauxtonAPI.addon = function (extra) {
+ return _.extend(_.clone(FauxtonAPI.addonExtensions), extra);
+};
+
+FauxtonAPI.View = Backbone.View.extend({
+ // This should return an array of promises, an empty array, or null
+ establish: function () {
+ return null;
+ },
+ loaderClassname: 'loader',
+ manage: true,
+ disableLoader: false,
+
+ forceRender: function () {
+ this.hasRendered = false;
+ }
+});
- addNotification: function () {},
+var caching = {
+ fetchOnce: function (opt) {
+ var options = _.extend({}, opt);
- config: function (options) {
- return _.extend(this, options);
+ if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
+ this._deferred = this.fetch();
}
- };
- FauxtonAPI.Deferred = function () {
- return $.Deferred();
- };
+ return this._deferred;
+ }
+};
- FauxtonAPI.when = function (deferreds) {
- if (deferreds instanceof Array) {
- return $.when.apply(null, deferreds);
- }
-
- return $.when(deferreds);
- };
-
- FauxtonAPI.addonExtensions = {
- initialize: function () {},
- RouteObjects: {},
- Views: {}
- };
-
- FauxtonAPI.addon = function (extra) {
- return _.extend(_.clone(FauxtonAPI.addonExtensions), extra);
- };
-
- FauxtonAPI.View = Backbone.View.extend({
- // This should return an array of promises, an empty array, or null
- establish: function () {
- return null;
- },
- loaderClassname: 'loader',
- manage: true,
- disableLoader: false,
-
- forceRender: function () {
- this.hasRendered = false;
- }
- });
+FauxtonAPI.Model = Backbone.Model.extend({ });
- var caching = {
- fetchOnce: function (opt) {
- var options = _.extend({}, opt);
+FauxtonAPI.Collection = Backbone.Collection.extend({ });
- if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
- this._deferred = this.fetch();
- }
-
- return this._deferred;
- }
- };
-
- FauxtonAPI.Model = Backbone.Model.extend({ });
-
- FauxtonAPI.Collection = Backbone.Collection.extend({ });
+_.each([FauxtonAPI.Model, FauxtonAPI.Collection], function (ctor) {
+ _.extend(ctor.prototype, caching);
+});
- _.each([FauxtonAPI.Model, FauxtonAPI.Collection], function (ctor) {
- _.extend(ctor.prototype, caching);
+var extensions = _.extend({}, Backbone.Events);
+// Can look at a remove function later.
+FauxtonAPI.registerExtension = function (name, view) {
+ if (!extensions[name]) {
+ extensions[name] = [];
+ }
+
+ extensions.trigger('add:' + name, view);
+ extensions[name].push(view);
+};
+
+FauxtonAPI.unRegisterExtension = function (name) {
+ var views = extensions[name];
+
+ if (!views) { return; }
+ extensions.trigger('remove:' + name, views);
+ delete extensions[name];
+};
+
+FauxtonAPI.getExtensions = function (name) {
+ var views = extensions[name];
+
+ if (!views) {
+ views = [];
+ }
+ return views;
+};
+
+FauxtonAPI.removeExtensionItem = function (name, view, cb) {
+ var views = extensions[name];
+ if (!views) { return; }
+
+ var _cb = arguments[arguments.length - 1];
+ if (_.isObject(view) && !cb) {
+ _cb = function (item) { return _.isEqual(item, view);};
+ }
+
+ views = _.filter(views, function (item) {
+ return !_cb(item);
});
- var extensions = _.extend({}, Backbone.Events);
- // Can look at a remove function later.
- FauxtonAPI.registerExtension = function (name, view) {
- if (!extensions[name]) {
- extensions[name] = [];
- }
+ extensions[name] = views;
+ extensions.trigger('removeItem:' + name, view);
+};
- extensions.trigger('add:' + name, view);
- extensions[name].push(view);
- };
+FauxtonAPI.extensions = extensions;
- FauxtonAPI.unRegisterExtension = function (name) {
- var views = extensions[name];
+FauxtonAPI.setSession = function (newSession) {
+ FauxtonAPI.session = newSession;
+ return FauxtonAPI.session.fetchUser();
+};
- if (!views) { return; }
- extensions.trigger('remove:' + name, views);
- delete extensions[name];
- };
-
- FauxtonAPI.getExtensions = function (name) {
- var views = extensions[name];
-
- if (!views) {
- views = [];
- }
- return views;
- };
-
- FauxtonAPI.removeExtensionItem = function (name, view, cb) {
- var views = extensions[name];
- if (!views) { return; }
-
- var _cb = arguments[arguments.length - 1];
- if (_.isObject(view) && !cb) {
- _cb = function (item) { return _.isEqual(item, view);};
- }
-
- views = _.filter(views, function (item) {
- return !_cb(item);
- });
-
- extensions[name] = views;
- extensions.trigger('removeItem:' + name, view);
- };
-
- FauxtonAPI.extensions = extensions;
-
- FauxtonAPI.setSession = function (newSession) {
- FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- return FauxtonAPI;
-});
+export default FauxtonAPI;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/app/core/couchdbSession.js b/app/core/couchdbSession.js
index bbc0d6e..5f18c6b 100644
--- a/app/core/couchdbSession.js
+++ b/app/core/couchdbSession.js
@@ -10,61 +10,57 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "./base"
-],
-function (FauxtonAPI) {
- var CouchdbSession = {
- Session: FauxtonAPI.Model.extend({
- url: '/_session',
+import FauxtonAPI from "./base";
+var CouchdbSession = {
+ Session: FauxtonAPI.Model.extend({
+ url: '/_session',
- user: function () {
- var userCtx = this.get('userCtx');
+ user: function () {
+ var userCtx = this.get('userCtx');
- if (!userCtx || !userCtx.name) { return null; }
+ if (!userCtx || !userCtx.name) { return null; }
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
+ return {
+ name: userCtx.name,
+ roles: userCtx.roles
+ };
+ },
- isAdmin: function () {
- var userCtx = this.get('userCtx');
- return userCtx.roles.indexOf('_admin') !== -1;
- },
+ isAdmin: function () {
+ var userCtx = this.get('userCtx');
+ return userCtx.roles.indexOf('_admin') !== -1;
+ },
- fetchUser: function (opt) {
- var options = opt || {},
- currentUser = this.user(),
- fetch = _.bind(this.fetchOnce, this);
+ fetchUser: function (opt) {
+ var options = opt || {},
+ currentUser = this.user(),
+ fetch = _.bind(this.fetchOnce, this);
- if (options.forceFetch) {
- fetch = _.bind(this.fetch, this);
- }
+ if (options.forceFetch) {
+ fetch = _.bind(this.fetch, this);
+ }
- return fetch(opt).then(function () {
- var user = this.user();
+ return fetch(opt).then(function () {
+ var user = this.user();
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- this.trigger('session:userChanged');
- } else {
- this.trigger('session:userFetched');
- }
+ // Notify anyone listening on these events that either a user has changed
+ // or current user is the same
+ if (currentUser !== user) {
+ this.trigger('session:userChanged');
+ } else {
+ this.trigger('session:userFetched');
+ }
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- }.bind(this), this.triggerError.bind(this));
- },
+ // this will return the user as a value to all function that calls done on this
+ // eg. session.fetchUser().done(user) { .. do something with user ..}
+ return user;
+ }.bind(this), this.triggerError.bind(this));
+ },
- triggerError: function (xhr, type, message) {
- this.trigger('session:error', xhr, type, message);
- }
- })
- };
+ triggerError: function (xhr, type, message) {
+ this.trigger('session:error', xhr, type, message);
+ }
+ })
+};
- return CouchdbSession;
-});
+export default CouchdbSession;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/layout.js
----------------------------------------------------------------------
diff --git a/app/core/layout.js b/app/core/layout.js
index 24afc84..c277889 100644
--- a/app/core/layout.js
+++ b/app/core/layout.js
@@ -10,88 +10,84 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- 'backbone',
- 'backbone.layoutmanager'
-], function (Backbone) {
-
- // A wrapper of the main Backbone.layoutmanager
- // Allows the main layout of the page to be changed by any plugin.
- var Layout = function () {
- this.layout = new Backbone.Layout({
- template: "templates/layouts/with_sidebar",
- className: 'pusher'
- });
+import Backbone from "backbone";
+import "backbone.layoutmanager";
+
+// A wrapper of the main Backbone.layoutmanager
+// Allows the main layout of the page to be changed by any plugin.
+var Layout = function () {
+ this.layout = new Backbone.Layout({
+ template: "templates/layouts/with_sidebar",
+ className: 'pusher'
+ });
+ this.layoutViews = {};
+ this.reactComponents = {};
+ //this views don't ever get removed. An example of this is the main navigation sidebar
+ this.permanentViews = {};
+ this.el = this.layout.el;
+};
+
+Layout.configure = function (options) {
+ Backbone.Layout.configure(options);
+};
+
+// creatings the dashboard object same way backbone does
+_.extend(Layout.prototype, {
+ render: function () {
+ return this.layout.render();
+ },
+
+ setTemplate: function (template) {
+ if (template.prefix) {
+ this.layout.template = template.prefix + template.name;
+ } else {
+ this.layout.template = "templates/layouts/" + template;
+ }
+ // If we're changing layouts all bets are off, so kill off all the
+ // existing views in the layout.
+ _.each(this.layoutViews, function (view) {view.removeView();});
this.layoutViews = {};
- this.reactComponents = {};
- //this views don't ever get removed. An example of this is the main navigation sidebar
- this.permanentViews = {};
- this.el = this.layout.el;
- };
-
- Layout.configure = function (options) {
- Backbone.Layout.configure(options);
- };
-
- // creatings the dashboard object same way backbone does
- _.extend(Layout.prototype, {
- render: function () {
- return this.layout.render();
- },
-
- setTemplate: function (template) {
- if (template.prefix) {
- this.layout.template = template.prefix + template.name;
- } else {
- this.layout.template = "templates/layouts/" + template;
- }
- // If we're changing layouts all bets are off, so kill off all the
- // existing views in the layout.
- _.each(this.layoutViews, function (view) {view.removeView();});
- this.layoutViews = {};
- return this.render().promise();
- },
-
- setView: function (selector, view, keep) {
- this.layout.setView(selector, view, false);
-
- if (!keep) {
- this.layoutViews[selector] = view;
- } else {
- this.permanentViews[selector] = view;
- }
-
- return view;
- },
-
- renderView: function (selector) {
- var view = this.layoutViews[selector];
- if (!view) {
- return false;
- } else {
- return view.render();
- }
- },
-
- removeView: function (selector) {
- var view = this.layout.getView(selector);
-
- if (!view) {
- return false;
- }
-
- this.layout.removeView(selector);
-
- if (this.layoutViews[selector]) {
- delete this.layoutViews[selector];
- }
-
- return true;
+ return this.render().promise();
+ },
+
+ setView: function (selector, view, keep) {
+ this.layout.setView(selector, view, false);
+
+ if (!keep) {
+ this.layoutViews[selector] = view;
+ } else {
+ this.permanentViews[selector] = view;
}
- });
+ return view;
+ },
+
+ renderView: function (selector) {
+ var view = this.layoutViews[selector];
+ if (!view) {
+ return false;
+ } else {
+ return view.render();
+ }
+ },
- return Layout;
+ removeView: function (selector) {
+ var view = this.layout.getView(selector);
+
+ if (!view) {
+ return false;
+ }
+
+ this.layout.removeView(selector);
+
+ if (this.layoutViews[selector]) {
+ delete this.layoutViews[selector];
+ }
+
+ return true;
+ }
});
+
+export default Layout;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/app/core/routeObject.js b/app/core/routeObject.js
index 1543cfd..07552ed 100644
--- a/app/core/routeObject.js
+++ b/app/core/routeObject.js
@@ -10,358 +10,354 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- './base',
- 'react',
- 'react-dom',
- 'backbone'
-],
-function (FauxtonAPI, React, ReactDOM, Backbone) {
-
- var RouteObject = function (options) {
- this._options = options;
- this.reactComponents = {};
+import FauxtonAPI from "./base";
+import React from "react";
+import ReactDOM from "react-dom";
+import Backbone from "backbone";
+
+var RouteObject = function (options) {
+ this._options = options;
+ this.reactComponents = {};
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
+ this._configure(options || {});
+ this.initialize.apply(this, arguments);
+ this.addEvents();
+};
- var broadcaster = {};
- _.extend(broadcaster, Backbone.Events);
+var broadcaster = {};
+_.extend(broadcaster, Backbone.Events);
- RouteObject.on = function (eventName, fn) {
- broadcaster.on(eventName, fn);
- };
+RouteObject.on = function (eventName, fn) {
+ broadcaster.on(eventName, fn);
+};
- /* How Route Object events work
- To listen to a specific route objects events:
+/* How Route Object events work
+ To listen to a specific route objects events:
- myRouteObject = FauxtonAPI.RouteObject.extend({
- events: {
- "beforeRender": "beforeRenderEvent"
- },
+ myRouteObject = FauxtonAPI.RouteObject.extend({
+ events: {
+ "beforeRender": "beforeRenderEvent"
+ },
- beforeRenderEvent: function (view, selector) {
- console.log('Hey, beforeRenderEvent triggered',arguments);
- },
- });
+ beforeRenderEvent: function (view, selector) {
+ console.log('Hey, beforeRenderEvent triggered',arguments);
+ },
+ });
- It is also possible to listen to events triggered from all Routeobjects.
- This is great for more general things like adding loaders, hooks.
+ It is also possible to listen to events triggered from all Routeobjects.
+ This is great for more general things like adding loaders, hooks.
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- console.log('hey, this will trigger when any routeobject renders a view');
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ console.log('hey, this will trigger when any routeobject renders a view');
+ });
+
+ Current Events to subscribe to:
+ * beforeFullRender -- before a full render is being done
+ * beforeEstablish -- before the routeobject calls establish
+ * AfterEstablish -- after the routeobject has run establish
+ * beforeRender -- before a view is rendered
+ * afterRender -- a view is finished being rendered
+ * renderComplete -- all rendering is complete
+
+*/
+
+// Piggy-back on Backbone's self-propagating extend function
+RouteObject.extend = Backbone.Model.extend;
+
+var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
+
+_.extend(RouteObject.prototype, Backbone.Events, {
+ // Should these be default vals or empty funcs?
+ views: {},
+ routes: {},
+ events: {},
+ crumbs: [],
+ layout: "with_sidebar",
+ apiUrl: null,
+ hideNotificationPanel: null,
+ disableLoader: false,
+ loaderClassname: 'loader',
+ renderedState: false,
+ establish: function () {},
+ route: function () {},
+ roles: [],
+ _promises: [],
+ initialize: function () {}
+}, {
+
+ renderWith: function (route, masterLayout, args) {
+
+ // set the options for this render
+ var options = {
+ masterLayout: masterLayout,
+ route: route,
+ args: args
+ };
+
+ var promiseLayout = this.setTemplateOnFullRender(masterLayout);
+
+ this.triggerBroadcast('beforeEstablish');
+
+ var renderAllViews = _.bind(this.renderAllViews, this, options),
+ establishError = _.bind(this.establishError, this),
+ renderComplete = _.bind(this.renderComplete, this),
+ callEstablish = _.bind(this.callEstablish, this),
+ renderReactComponents = _.bind(this.renderReactComponents, this),
+ promise = this.establish();
+
+ // Only start the view rendering process once the template has been rendered
+ // otherwise we get double renders
+ promiseLayout.then(function () {
+ renderReactComponents();
+ callEstablish(promise)
+ .then(renderAllViews, establishError)
+ .then(renderComplete);
});
+ },
+
+ setTemplateOnFullRender: function (masterLayout) {
+
+ var promise = $.Deferred();
+
+ // Only want to redo the template if its a full render
+ if (!this.renderedState) {
+ this.triggerBroadcast('beforeFullRender');
+ masterLayout.setTemplate(this.layout).then(promise.resolve, promise.reject);
+ } else {
+ promise.resolve();
+ }
+
+ return promise;
+ },
- Current Events to subscribe to:
- * beforeFullRender -- before a full render is being done
- * beforeEstablish -- before the routeobject calls establish
- * AfterEstablish -- after the routeobject has run establish
- * beforeRender -- before a view is rendered
- * afterRender -- a view is finished being rendered
- * renderComplete -- all rendering is complete
-
- */
-
- // Piggy-back on Backbone's self-propagating extend function
- RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- hideNotificationPanel: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function () {},
- route: function () {},
- roles: [],
- _promises: [],
- initialize: function () {}
- }, {
-
- renderWith: function (route, masterLayout, args) {
-
- // set the options for this render
- var options = {
- masterLayout: masterLayout,
- route: route,
- args: args
- };
-
- var promiseLayout = this.setTemplateOnFullRender(masterLayout);
-
- this.triggerBroadcast('beforeEstablish');
-
- var renderAllViews = _.bind(this.renderAllViews, this, options),
- establishError = _.bind(this.establishError, this),
- renderComplete = _.bind(this.renderComplete, this),
- callEstablish = _.bind(this.callEstablish, this),
- renderReactComponents = _.bind(this.renderReactComponents, this),
- promise = this.establish();
-
- // Only start the view rendering process once the template has been rendered
- // otherwise we get double renders
- promiseLayout.then(function () {
- renderReactComponents();
- callEstablish(promise)
- .then(renderAllViews, establishError)
- .then(renderComplete);
- });
- },
-
- setTemplateOnFullRender: function (masterLayout) {
-
- var promise = $.Deferred();
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- this.triggerBroadcast('beforeFullRender');
- masterLayout.setTemplate(this.layout).then(promise.resolve, promise.reject);
- } else {
- promise.resolve();
+ renderReactComponents: function () {
+ _.each(this.reactComponents, function (componentInfo, selector) {
+ if ($(selector)[0]) {
+ ReactDOM.render(React.createElement(componentInfo.component, componentInfo.props), $(selector)[0]);
}
+ });
+ },
- return promise;
- },
+ callEstablish: function (establishPromise) {
+ this.addPromise(establishPromise);
+ return FauxtonAPI.when(establishPromise);
+ },
- renderReactComponents: function () {
- _.each(this.reactComponents, function (componentInfo, selector) {
- if ($(selector)[0]) {
- ReactDOM.render(React.createElement(componentInfo.component, componentInfo.props), $(selector)[0]);
- }
- });
- },
+ renderAllViews: function (options, resp) {
+ var routeObject = this,
+ renderView = _.bind(this.renderView, this, routeObject, options);
- callEstablish: function (establishPromise) {
- this.addPromise(establishPromise);
- return FauxtonAPI.when(establishPromise);
- },
+ this.triggerBroadcast('afterEstablish');
- renderAllViews: function (options, resp) {
- var routeObject = this,
- renderView = _.bind(this.renderView, this, routeObject, options);
+ var promises = _.map(routeObject.getViews(), renderView, this);
+ return FauxtonAPI.when(promises);
+ },
- this.triggerBroadcast('afterEstablish');
+ renderView: function (routeObject, options, view, selector) {
+ var viewInfo = {
+ view: view,
+ selector: selector,
+ masterLayout: options.masterLayout
+ };
- var promises = _.map(routeObject.getViews(), renderView, this);
- return FauxtonAPI.when(promises);
- },
+ var renderViewOnLayout = _.bind(this.renderViewOnLayout, this, viewInfo);
- renderView: function (routeObject, options, view, selector) {
- var viewInfo = {
- view: view,
- selector: selector,
- masterLayout: options.masterLayout
- };
+ if (view.hasRendered) {
+ this.triggerBroadcast('viewHasRendered', view, selector);
+ return;
+ }
- var renderViewOnLayout = _.bind(this.renderViewOnLayout, this, viewInfo);
+ this.triggerBroadcast('beforeRender', view, selector);
- if (view.hasRendered) {
- this.triggerBroadcast('viewHasRendered', view, selector);
- return;
- }
+ return this.callEstablish(view.establish()).then(renderViewOnLayout, this.establishError);
+ },
- this.triggerBroadcast('beforeRender', view, selector);
-
- return this.callEstablish(view.establish()).then(renderViewOnLayout, this.establishError);
- },
-
- renderViewOnLayout: function (viewInfo, resp, xhr) {
- var masterLayout = viewInfo.masterLayout,
- triggerBroadcast = _.bind(this.triggerBroadcast, this);
-
- masterLayout.setView(viewInfo.selector, viewInfo.view);
- var promise = masterLayout.renderView(viewInfo.selector).promise();
-
- promise.then(function () {
- triggerBroadcast('afterRender', viewInfo.view, viewInfo.selector);
- });
-
- return promise;
- },
-
- establishError: function (resp) {
- if (!resp || !resp.responseText) { return; }
- FauxtonAPI.addNotification({
- msg: 'An Error occurred: ' + JSON.parse(resp.responseText).reason,
- type: 'error',
- clear: true
- });
- },
-
- renderComplete: function () {
- // Track that we've done a full initial render
- this.setRenderedState(true);
- this.triggerBroadcast('renderComplete');
- },
-
- setRenderedState: function (bool) {
- this.renderedState = bool;
- },
-
- triggerBroadcast: function (eventName) {
- var args = Array.prototype.slice.call(arguments);
- this.trigger.apply(this, args);
-
- args.splice(0, 1, eventName, this);
- broadcaster.trigger.apply(broadcaster, args);
- },
-
- get: function (key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function (events) {
- events = events || this.get('events');
- _.each(events, function (method, event) {
- if (!_.isFunction(method) && !_.isFunction (this[method])) {
- throw new Error("Invalid method: " + method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
- }, this);
- },
-
- _configure: function (options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function (key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function (selector) {
- return this.views[selector];
- },
-
- setView: function (selector, view) {
- this.removeView(selector);
- this.removeComponent(selector);
- this.views[selector] = view;
- return view;
- },
+ renderViewOnLayout: function (viewInfo, resp, xhr) {
+ var masterLayout = viewInfo.masterLayout,
+ triggerBroadcast = _.bind(this.triggerBroadcast, this);
- setComponent: function (selector, component, props) {
- this.removeView(selector);
- this.removeComponent(selector);
- this.reactComponents[selector] = {
- component: component,
- props: props || null
- };
- },
-
- removeComponent: function (selector) {
- if (_.has(this.reactComponents, selector)) {
- if ($(selector)[0]) {
- ReactDOM.unmountComponentAtNode($(selector)[0]);
- }
- this.reactComponents[selector] = null;
- delete this.reactComponents[selector];
+ masterLayout.setView(viewInfo.selector, viewInfo.view);
+ var promise = masterLayout.renderView(viewInfo.selector).promise();
+
+ promise.then(function () {
+ triggerBroadcast('afterRender', viewInfo.view, viewInfo.selector);
+ });
+
+ return promise;
+ },
+
+ establishError: function (resp) {
+ if (!resp || !resp.responseText) { return; }
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred: ' + JSON.parse(resp.responseText).reason,
+ type: 'error',
+ clear: true
+ });
+ },
+
+ renderComplete: function () {
+ // Track that we've done a full initial render
+ this.setRenderedState(true);
+ this.triggerBroadcast('renderComplete');
+ },
+
+ setRenderedState: function (bool) {
+ this.renderedState = bool;
+ },
+
+ triggerBroadcast: function (eventName) {
+ var args = Array.prototype.slice.call(arguments);
+ this.trigger.apply(this, args);
+
+ args.splice(0, 1, eventName, this);
+ broadcaster.trigger.apply(broadcaster, args);
+ },
+
+ get: function (key) {
+ return _.isFunction(this[key]) ? this[key]() : this[key];
+ },
+
+ addEvents: function (events) {
+ events = events || this.get('events');
+ _.each(events, function (method, event) {
+ if (!_.isFunction(method) && !_.isFunction (this[method])) {
+ throw new Error("Invalid method: " + method);
+ }
+ method = _.isFunction(method) ? method : this[method];
+
+ this.on(event, method);
+ }, this);
+ },
+
+ _configure: function (options) {
+ _.each(_.intersection(_.keys(options), routeObjectOptions), function (key) {
+ this[key] = options[key];
+ }, this);
+ },
+
+ getView: function (selector) {
+ return this.views[selector];
+ },
+
+ setView: function (selector, view) {
+ this.removeView(selector);
+ this.removeComponent(selector);
+ this.views[selector] = view;
+ return view;
+ },
+
+ setComponent: function (selector, component, props) {
+ this.removeView(selector);
+ this.removeComponent(selector);
+ this.reactComponents[selector] = {
+ component: component,
+ props: props || null
+ };
+ },
+
+ removeComponent: function (selector) {
+ if (_.has(this.reactComponents, selector)) {
+ if ($(selector)[0]) {
+ ReactDOM.unmountComponentAtNode($(selector)[0]);
}
- },
+ this.reactComponents[selector] = null;
+ delete this.reactComponents[selector];
+ }
+ },
- removeComponents: function () {
- _.each(this.reactComponents, function (component, selector) {
- this.removeComponent(selector);
- }, this);
+ removeComponents: function () {
+ _.each(this.reactComponents, function (component, selector) {
+ this.removeComponent(selector);
+ }, this);
- this.reactComponents = {};
- },
+ this.reactComponents = {};
+ },
- getViews: function () {
- return this.views;
- },
+ getViews: function () {
+ return this.views;
+ },
- removeView: function (selector) {
- if (_.has(this.views, selector)) {
- this.views[selector].remove();
- this.views[selector] = null;
- delete this.views[selector];
- }
- },
+ removeView: function (selector) {
+ if (_.has(this.views, selector)) {
+ this.views[selector].remove();
+ this.views[selector] = null;
+ delete this.views[selector];
+ }
+ },
- removeViews: function () {
- _.each(this.views, function (view, selector) {
- view.remove();
- delete this.views[selector];
- view = null;
- }, this);
- },
+ removeViews: function () {
+ _.each(this.views, function (view, selector) {
+ view.remove();
+ delete this.views[selector];
+ view = null;
+ }, this);
+ },
- addPromise: function (promise) {
- if (_.isEmpty(promise)) { return; }
+ addPromise: function (promise) {
+ if (_.isEmpty(promise)) { return; }
- if (!_.isArray(promise)) {
- return this._promises.push(promise);
- }
+ if (!_.isArray(promise)) {
+ return this._promises.push(promise);
+ }
- _.each(promise, function (p) {
- this._promises.push(p);
- }, this);
- },
-
- cleanup: function () {
- this.removeComponents();
- this.removeViews();
- this.rejectPromises();
- },
-
- rejectPromises: function () {
- _.each(this._promises, function (promise) {
- if (promise.state() === "resolved") { return; }
- if (promise.abort) {
- return promise.abort("Route change");
- }
-
- promise.reject && promise.reject();
- }, this);
-
- this._promises = [];
- },
-
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
+ _.each(promise, function (p) {
+ this._promises.push(p);
+ }, this);
+ },
+
+ cleanup: function () {
+ this.removeComponents();
+ this.removeViews();
+ this.rejectPromises();
+ },
+
+ rejectPromises: function () {
+ _.each(this._promises, function (promise) {
+ if (promise.state() === "resolved") { return; }
+ if (promise.abort) {
+ return promise.abort("Route change");
}
- routeCallback.apply(this, args);
- },
+ promise.reject && promise.reject();
+ }, this);
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
+ this._promises = [];
+ },
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
- }
+ getRouteUrls: function () {
+ return _.keys(this.get('routes'));
+ },
- return this.roles;
+ hasRoute: function (route) {
+ if (this.get('routes')[route]) {
+ return true;
+ }
+ return false;
+ },
+
+ routeCallback: function (route, args) {
+ var routes = this.get('routes'),
+ routeObj = routes[route],
+ routeCallback;
+
+ if (typeof routeObj === 'object') {
+ routeCallback = this[routeObj.route];
+ } else {
+ routeCallback = this[routeObj];
}
- });
- return RouteObject;
+ routeCallback.apply(this, args);
+ },
+
+ getRouteRoles: function (routeUrl) {
+ var route = this.get('routes')[routeUrl];
+
+ if ((typeof route === 'object') && route.roles) {
+ return route.roles;
+ }
+
+ return this.roles;
+ }
+
});
+export default RouteObject;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/router.js
----------------------------------------------------------------------
diff --git a/app/core/router.js b/app/core/router.js
index f8d160f..35cbc6d 100644
--- a/app/core/router.js
+++ b/app/core/router.js
@@ -10,112 +10,105 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "./base",
- "./auth",
- "backbone"
-],
+import FauxtonAPI from "./base";
+import Auth from "./auth";
+import Backbone from "backbone";
-function (FauxtonAPI, Auth, Backbone) {
+var beforeUnloads = {};
- var beforeUnloads = {};
+export default Backbone.Router.extend({
+ routes: {},
- var Router = Backbone.Router.extend({
- routes: {},
+ beforeUnload: function (name, fn) {
+ beforeUnloads[name] = fn;
+ },
- beforeUnload: function (name, fn) {
- beforeUnloads[name] = fn;
- },
+ removeBeforeUnload: function (name) {
+ delete beforeUnloads[name];
+ },
- removeBeforeUnload: function (name) {
- delete beforeUnloads[name];
- },
-
- navigate: function (fragment, trigger) {
- var continueNav = true,
- msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
- if (beforeReturn) { return true; }
- });
+ navigate: function (fragment, trigger) {
+ var continueNav = true,
+ msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
+ if (beforeReturn) { return true; }
+ });
- if (msg) {
- continueNav = window.confirm(msg);
- }
+ if (msg) {
+ continueNav = window.confirm(msg);
+ }
- if (continueNav) {
- Backbone.Router.prototype.navigate(fragment, trigger);
- }
- },
-
- addModuleRouteObject: function (RouteObject) {
- var that = this;
- var masterLayout = FauxtonAPI.masterLayout,
- routeUrls = RouteObject.prototype.getRouteUrls();
-
- _.each(routeUrls, function (route) {
- this.route(route, route.toString(), function () {
- var args = Array.prototype.slice.call(arguments),
- roles = RouteObject.prototype.getRouteRoles(route),
- authPromise = FauxtonAPI.auth.checkAccess(roles);
-
- authPromise.then(function () {
- if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
- that.activeRouteObject && that.activeRouteObject.cleanup();
- that.activeRouteObject = new RouteObject(route, masterLayout, args);
- }
-
- var routeObject = that.activeRouteObject;
- routeObject.rejectPromises();
- routeObject.routeCallback(route, args);
- routeObject.renderWith(route, masterLayout, args);
- }, function () {
- FauxtonAPI.auth.authDeniedCb();
- });
+ if (continueNav) {
+ Backbone.Router.prototype.navigate(fragment, trigger);
+ }
+ },
+
+ addModuleRouteObject: function (RouteObject) {
+ var that = this;
+ var masterLayout = FauxtonAPI.masterLayout,
+ routeUrls = RouteObject.prototype.getRouteUrls();
+
+ _.each(routeUrls, function (route) {
+ this.route(route, route.toString(), function () {
+ var args = Array.prototype.slice.call(arguments),
+ roles = RouteObject.prototype.getRouteRoles(route),
+ authPromise = FauxtonAPI.auth.checkAccess(roles);
+
+ authPromise.then(function () {
+ if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
+ that.activeRouteObject && that.activeRouteObject.cleanup();
+ that.activeRouteObject = new RouteObject(route, masterLayout, args);
+ }
+ var routeObject = that.activeRouteObject;
+ routeObject.rejectPromises();
+ routeObject.routeCallback(route, args);
+ routeObject.renderWith(route, masterLayout, args);
+ }, function () {
+ FauxtonAPI.auth.authDeniedCb();
});
- }, this);
- },
-
- setModuleRoutes: function (addons) {
- _.each(addons, function (module) {
- if (module) {
- module.initialize();
- // This is pure routes the addon provides
- if (module.RouteObjects) {
- _.each(module.RouteObjects, this.addModuleRouteObject, this);
- }
- }
- }, this);
- },
-
- initialize: function (addons) {
- this.addons = addons;
- this.auth = FauxtonAPI.auth = new Auth();
- // NOTE: This must be below creation of the layout
- // FauxtonAPI header links and others depend on existence of the layout
- this.setModuleRoutes(addons);
-
- $(FauxtonAPI.el).append(FauxtonAPI.masterLayout.el);
- FauxtonAPI.masterLayout.render();
-
- this.lastPages = [];
- //keep last pages visited in Fauxton
- Backbone.history.on('route', function () {
- this.lastPages.push(Backbone.history.fragment);
- if (this.lastPages.length > 2) {
- this.lastPages.shift();
+
+ });
+ }, this);
+ },
+
+ setModuleRoutes: function (addons) {
+ _.each(addons, function (module) {
+ if (module) {
+ module.initialize();
+ // This is pure routes the addon provides
+ if (module.RouteObjects) {
+ _.each(module.RouteObjects, this.addModuleRouteObject, this);
}
- }, this);
- },
+ }
+ }, this);
+ },
+
+ initialize: function (addons) {
+ this.addons = addons;
+ this.auth = FauxtonAPI.auth = new Auth();
+ // NOTE: This must be below creation of the layout
+ // FauxtonAPI header links and others depend on existence of the layout
+ this.setModuleRoutes(addons);
+
+ $(FauxtonAPI.el).append(FauxtonAPI.masterLayout.el);
+ FauxtonAPI.masterLayout.render();
+
+ this.lastPages = [];
+ //keep last pages visited in Fauxton
+ Backbone.history.on('route', function () {
+ this.lastPages.push(Backbone.history.fragment);
+ if (this.lastPages.length > 2) {
+ this.lastPages.shift();
+ }
+ }, this);
+ },
- triggerRouteEvent: function (event, args) {
- if (this.activeRouteObject) {
- var eventArgs = [event].concat(args);
+ triggerRouteEvent: function (event, args) {
+ if (this.activeRouteObject) {
+ var eventArgs = [event].concat(args);
- this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs);
- this.activeRouteObject.renderWith(eventArgs, FauxtonAPI.masterLayout, args);
- }
+ this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs);
+ this.activeRouteObject.renderWith(eventArgs, FauxtonAPI.masterLayout, args);
}
- });
-
- return Router;
+ }
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/store.js
----------------------------------------------------------------------
diff --git a/app/core/store.js b/app/core/store.js
index 6614372..21d371a 100644
--- a/app/core/store.js
+++ b/app/core/store.js
@@ -10,25 +10,20 @@
// License for the specific language governing permissions and limitations under
// the License.
-define([
- "backbone"
-],
-function (Backbone) {
+import Backbone from "backbone";
- var Store = function () {
- this.initialize.apply(this, arguments);
- _.bindAll(this);
- };
+var Store = function () {
+ this.initialize.apply(this, arguments);
+ _.bindAll(this);
+};
- Store.extend = Backbone.Model.extend;
- _.extend(Store.prototype, Backbone.Events, {
- triggerChange: function () {
- this.trigger('change');
- },
+Store.extend = Backbone.Model.extend;
+_.extend(Store.prototype, Backbone.Events, {
+ triggerChange: function () {
+ this.trigger('change');
+ },
- initialize: function () {}
- });
-
- return Store;
+ initialize: function () {}
});
+export default Store;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/tests/apiSpec.js
----------------------------------------------------------------------
diff --git a/app/core/tests/apiSpec.js b/app/core/tests/apiSpec.js
index 0851f64..28e4f45 100644
--- a/app/core/tests/apiSpec.js
+++ b/app/core/tests/apiSpec.js
@@ -9,41 +9,37 @@
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../api',
- '../../../test/mocha/testUtils',
-], function (FauxtonAPI, testUtils) {
- var assert = testUtils.assert;
+import FauxtonAPI from "../api";
+import testUtils from "../../../test/mocha/testUtils";
+var assert = testUtils.assert;
- describe('URLs', function () {
+describe('URLs', function () {
- it('can register and get url', function () {
- var testUrl = 'this_is_a_test_url';
-
- FauxtonAPI.registerUrls('testURL', {
- server: function () {
- return testUrl;
- }
- });
-
- assert.equal(FauxtonAPI.urls('testURL', 'server'), testUrl);
+ it('can register and get url', function () {
+ var testUrl = 'this_is_a_test_url';
+ FauxtonAPI.registerUrls('testURL', {
+ server: function () {
+ return testUrl;
+ }
});
- it('can register interceptor to change url', function () {
- var testUrl = 'interceptor_url';
+ assert.equal(FauxtonAPI.urls('testURL', 'server'), testUrl);
+
+ });
- FauxtonAPI.registerExtension('urls:interceptors', function (name, context) {
- if (name === 'testURL' && context === 'intercept') {
- return testUrl;
- }
+ it('can register interceptor to change url', function () {
+ var testUrl = 'interceptor_url';
- return false;
- });
+ FauxtonAPI.registerExtension('urls:interceptors', function (name, context) {
+ if (name === 'testURL' && context === 'intercept') {
+ return testUrl;
+ }
- assert.equal(FauxtonAPI.urls('testURL', 'intercept'), testUrl);
+ return false;
});
+ assert.equal(FauxtonAPI.urls('testURL', 'intercept'), testUrl);
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/tests/couchdbSessionSpec.js
----------------------------------------------------------------------
diff --git a/app/core/tests/couchdbSessionSpec.js b/app/core/tests/couchdbSessionSpec.js
index 8b91a8f..7155037 100644
--- a/app/core/tests/couchdbSessionSpec.js
+++ b/app/core/tests/couchdbSessionSpec.js
@@ -9,42 +9,38 @@
// 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([
- '../../app',
- '../api',
- '../../../test/mocha/testUtils',
- 'sinon'
-], function (app, FauxtonAPI, testUtils, sinon) {
- var assert = testUtils.assert;
-
- describe('CouchDBSession', function () {
-
- before(function (done) {
- sinon.stub(FauxtonAPI.session, 'fetch', function () {
- var promise = FauxtonAPI.Deferred();
- promise.reject();
- return promise;
- });
-
- done();
+import app from "../../app";
+import FauxtonAPI from "../api";
+import testUtils from "../../../test/mocha/testUtils";
+import sinon from "sinon";
+var assert = testUtils.assert;
+
+describe('CouchDBSession', function () {
+
+ before(function (done) {
+ sinon.stub(FauxtonAPI.session, 'fetch', function () {
+ var promise = FauxtonAPI.Deferred();
+ promise.reject();
+ return promise;
});
- after(function (done) {
- testUtils.restore(FauxtonAPI.session.fetch);
- testUtils.restore(FauxtonAPI.session.triggerError);
+ done();
+ });
- done();
- });
+ after(function (done) {
+ testUtils.restore(FauxtonAPI.session.fetch);
+ testUtils.restore(FauxtonAPI.session.triggerError);
- it('triggers error on failed fetch', function (done) {
+ done();
+ });
- sinon.stub(FauxtonAPI.session, 'triggerError', function () {
- done();
- });
+ it('triggers error on failed fetch', function (done) {
- FauxtonAPI.session.fetchUser();
+ sinon.stub(FauxtonAPI.session, 'triggerError', function () {
+ done();
});
+ FauxtonAPI.session.fetchUser();
});
});
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0ca35da7/app/core/tests/layoutSpec.js
----------------------------------------------------------------------
diff --git a/app/core/tests/layoutSpec.js b/app/core/tests/layoutSpec.js
index fb19111..d2aa4b6 100644
--- a/app/core/tests/layoutSpec.js
+++ b/app/core/tests/layoutSpec.js
@@ -9,121 +9,118 @@
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
-define([
- '../api',
- '../../../test/mocha/testUtils',
-], function (FauxtonAPI, testUtils) {
- var assert = testUtils.assert;
+import FauxtonAPI from "../api";
+import testUtils from "../../../test/mocha/testUtils";
+var assert = testUtils.assert;
- describe("Fauxton Layout", function () {
- var layout;
+describe("Fauxton Layout", function () {
+ var layout;
- beforeEach(function () {
- layout = new FauxtonAPI.Layout();
- });
-
- describe('#setTemplate', function () {
+ beforeEach(function () {
+ layout = new FauxtonAPI.Layout();
+ });
- it("Should set template without prefix", function () {
- layout.setTemplate('myTemplate');
+ describe('#setTemplate', function () {
- assert.equal(layout.layout.template, 'templates/layouts/myTemplate');
+ it("Should set template without prefix", function () {
+ layout.setTemplate('myTemplate');
- });
+ assert.equal(layout.layout.template, 'templates/layouts/myTemplate');
- it("Should set template with prefix", function () {
- layout.setTemplate({name: 'myTemplate', prefix: 'myPrefix/'});
+ });
- assert.equal(layout.layout.template, 'myPrefix/myTemplate');
- });
+ it("Should set template with prefix", function () {
+ layout.setTemplate({name: 'myTemplate', prefix: 'myPrefix/'});
- it("Should remove old views", function () {
- var view = new FauxtonAPI.View();
+ assert.equal(layout.layout.template, 'myPrefix/myTemplate');
+ });
- layout.setView('#selector', view);
+ it("Should remove old views", function () {
+ var view = new FauxtonAPI.View();
- var removeSpy = sinon.spy(view, 'removeView');
- layout.setTemplate('myTemplate');
- assert.ok(removeSpy.calledOnce);
+ layout.setView('#selector', view);
- });
+ var removeSpy = sinon.spy(view, 'removeView');
+ layout.setTemplate('myTemplate');
+ assert.ok(removeSpy.calledOnce);
- it("Should render", function () {
- var mockRender = sinon.spy(layout, 'render');
+ });
- layout.setTemplate('myTemplate');
+ it("Should render", function () {
+ var mockRender = sinon.spy(layout, 'render');
- assert.ok(mockRender.calledOnce);
+ layout.setTemplate('myTemplate');
- });
+ assert.ok(mockRender.calledOnce);
});
- describe('#setView', function () {
- var view;
- beforeEach(function () {
- view = new FauxtonAPI.View();
- });
+ });
- it("Should keep record of view", function () {
- layout.setView('.selector', view);
- assert.equal(view, layout.layoutViews['.selector']);
- });
+ describe('#setView', function () {
+ var view;
+ beforeEach(function () {
+ view = new FauxtonAPI.View();
+ });
- it("Should not keep record of view if keep is false", function () {
- layout.setView('.selector', view, true);
- assert.ok(_.isUndefined(layout.layoutViews['.selector']));
- assert.equal(view, layout.permanentViews['.selector']);
- });
+ it("Should keep record of view", function () {
+ layout.setView('.selector', view);
+ assert.equal(view, layout.layoutViews['.selector']);
+ });
+ it("Should not keep record of view if keep is false", function () {
+ layout.setView('.selector', view, true);
+ assert.ok(_.isUndefined(layout.layoutViews['.selector']));
+ assert.equal(view, layout.permanentViews['.selector']);
});
- describe('#removeView', function () {
- var view;
+ });
- beforeEach(function () {
- view = new FauxtonAPI.View();
- layout.setView('#selector', view);
- });
+ describe('#removeView', function () {
+ var view;
- it('Should remove view from layout', function () {
- var removeSpy = sinon.spy(layout.layout, 'removeView');
+ beforeEach(function () {
+ view = new FauxtonAPI.View();
+ layout.setView('#selector', view);
+ });
- layout.removeView('#selector');
- assert.ok(removeSpy.calledOnce);
- });
+ it('Should remove view from layout', function () {
+ var removeSpy = sinon.spy(layout.layout, 'removeView');
- it('Should remove view from list of active views', function () {
- layout.setView('#selector', view);
- layout.removeView('#selector');
+ layout.removeView('#selector');
+ assert.ok(removeSpy.calledOnce);
+ });
- assert.ok(_.isUndefined(layout.layoutViews['#selector']));
- });
+ it('Should remove view from list of active views', function () {
+ layout.setView('#selector', view);
+ layout.removeView('#selector');
- it("should return false if view doesn't exist", function () {
- assert.notOk(layout.removeView('#fake'));
- });
+ assert.ok(_.isUndefined(layout.layoutViews['#selector']));
+ });
+ it("should return false if view doesn't exist", function () {
+ assert.notOk(layout.removeView('#fake'));
});
- describe('#renderView', function () {
- var view;
+ });
- beforeEach(function () {
- view = new FauxtonAPI.View();
- layout.setView('#selector', view);
- });
+ describe('#renderView', function () {
+ var view;
- it('should render view', function () {
- var renderSpy = sinon.spy(view, 'render');
- layout.renderView('#selector');
- assert.ok(renderSpy.calledOnce);
- });
+ beforeEach(function () {
+ view = new FauxtonAPI.View();
+ layout.setView('#selector', view);
+ });
- it('should not render a non-existing view', function () {
- assert.notOk(layout.renderView('#fake'));
- });
+ it('should render view', function () {
+ var renderSpy = sinon.spy(view, 'render');
+ layout.renderView('#selector');
+ assert.ok(renderSpy.calledOnce);
+ });
+ it('should not render a non-existing view', function () {
+ assert.notOk(layout.renderView('#fake'));
});
+
});
});