couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [6/7] fauxton commit: updated refs/heads/master to 73521f1
Date Mon, 04 Jul 2016 13:29:36 GMT
changes from review

PR: #732
PR-URL: https://github.com/apache/couchdb-fauxton/pull/732
Reviewed-By: garren smith <garren.smith@gmail.com>


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

Branch: refs/heads/master
Commit: 18d08e96a90dc4d1e77865b39d00a890ace899ea
Parents: db95bb3
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Mon Jun 27 16:33:40 2016 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Mon Jul 4 15:25:28 2016 +0200

----------------------------------------------------------------------
 app/addons/components/actions.js                |   9 --
 app/addons/components/actiontypes.js            |   1 -
 .../assets/less/header-breadcrumbs.less         |   6 +
 app/addons/components/header-breadcrumbs.jsx    |   9 +-
 app/addons/components/stores.js                 | 129 +++++++++++++++++++
 .../documents/doc-editor/components.react.jsx   |   7 +-
 app/addons/documents/helpers.js                 |  18 ---
 app/addons/documents/routes-doc-editor.js       |  29 ++---
 app/addons/fauxton/base.js                      |   2 +-
 app/core/tests/routeObjectSpec.js               |   2 -
 10 files changed, 150 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/components/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/components/actions.js b/app/addons/components/actions.js
index c9618aa..53ccd15 100644
--- a/app/addons/components/actions.js
+++ b/app/addons/components/actions.js
@@ -69,17 +69,8 @@ function deleteDatabase (dbId) {
   });
 }
 
-function setBreadCrumbs (crumbs) {
-  FauxtonAPI.dispatch({
-    type: ActionTypes.CMPNTS_BREADCRUMBS_SET_CRUMBS,
-    options: {
-      crumbs: crumbs
-    }
-  });
-}
 
 export default {
-  setBreadCrumbs: setBreadCrumbs,
   deleteDatabase: deleteDatabase,
   showDeleteDatabaseModal: showDeleteDatabaseModal,
   showAPIBarButton: showAPIBarButton,

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/components/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/components/actiontypes.js b/app/addons/components/actiontypes.js
index 2940c51..c349806 100644
--- a/app/addons/components/actiontypes.js
+++ b/app/addons/components/actiontypes.js
@@ -16,5 +16,4 @@ export default {
   CMPNTS_UPDATE_API_BAR: 'CMPNTS_UPDATE_API_BAR',
   CMPNTS_SET_API_BAR_CONTENT_VISIBLE_STATE: 'CMPNTS_SET_API_BAR_CONTENT_VISIBLE_STATE',
   CMPNTS_DATABASES_SHOWDELETE_MODAL: 'CMPNTS_DATABASES_SHOWDELETE_MODAL',
-  CMPNTS_BREADCRUMBS_SET_CRUMBS: 'CMPNTS_BREADCRUMBS_SET_CRUMBS'
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/components/assets/less/header-breadcrumbs.less
----------------------------------------------------------------------
diff --git a/app/addons/components/assets/less/header-breadcrumbs.less b/app/addons/components/assets/less/header-breadcrumbs.less
index f419eb1..37f5bd2 100644
--- a/app/addons/components/assets/less/header-breadcrumbs.less
+++ b/app/addons/components/assets/less/header-breadcrumbs.less
@@ -27,6 +27,12 @@
   cursor: hand;
 }
 
+.faux-header__breadcrumbs-divider {
+  width: 13px;
+  padding-top: 22px;
+  font-size: 20px;
+}
+
 .faux-header__controlbox-backlink {
   border-right: 1px solid #ccc;
   padding-left: 10px;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/components/header-breadcrumbs.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/header-breadcrumbs.jsx b/app/addons/components/header-breadcrumbs.jsx
index c93561f..8c3cdef 100644
--- a/app/addons/components/header-breadcrumbs.jsx
+++ b/app/addons/components/header-breadcrumbs.jsx
@@ -15,11 +15,9 @@ import ReactDOM from 'react-dom';
 
 export const Breadcrumbs = ({crumbs}) => {
 
-  const childs = getChildren(crumbs);
-
   return (
     <div className="faux-header__breadcrumbs">
-      {childs}
+      {getChildren(crumbs)}
     </div>
   );
 
@@ -35,11 +33,8 @@ const CrumbElement = ({children}) => {
 };
 
 const Divider = () => {
-  const style = {width: '13px', paddingTop: '22px', fontSize: '20px'};
   return (
-    <div
-      className="fonticon-right-open faux-header__breadcrumbs-divider"
-      style={style}></div>
+    <div className="fonticon-right-open faux-header__breadcrumbs-divider"></div>
   );
 };
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/components/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/components/stores.js b/app/addons/components/stores.js
new file mode 100644
index 0000000..af5a69c
--- /dev/null
+++ b/app/addons/components/stores.js
@@ -0,0 +1,129 @@
+// 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.
+
+import FauxtonAPI from "../../core/api";
+import app from "../../app";
+import ActionTypes from "./actiontypes";
+var Stores = {};
+
+Stores.ComponentStore = FauxtonAPI.Store.extend({
+  initialize: function () {
+    this.reset();
+  },
+
+  reset: function () {
+    this._apiBarVisible = false;
+    this._apiBarButtonVisible = true;
+    this._endpoint = '';
+    this._docURL = FauxtonAPI.constants.DOC_URLS.GENERAL;
+  },
+
+  updateAPIBar: function (settings) {
+    this._apiBarVisible = settings.contentVisible;
+    this._apiBarButtonVisible = settings.buttonVisible;
+    this._endpoint = settings.endpoint;
+    this._docURL = settings.docURL;
+  },
+
+  setVisibleButton: function (state) {
+    this._apiBarButtonVisible = state;
+  },
+
+  setApiBarVisible: function (state) {
+    this._apiBarVisible = state;
+  },
+
+  getEndpoint: function () {
+    return this._endpoint;
+  },
+
+  getDocURL: function () {
+    return this._docURL;
+  },
+
+  getIsAPIBarButtonVisible: function () {
+    return this._apiBarButtonVisible;
+  },
+
+  getIsAPIBarVisible: function () {
+    return this._apiBarVisible;
+  },
+
+  dispatch: function (action) {
+    switch (action.type) {
+      case ActionTypes.CMPNTS_SHOW_API_BAR_BUTTON:
+        this.setVisibleButton(true);
+      break;
+
+      case ActionTypes.CMPNTS_HIDE_API_BAR_BUTTON:
+        this.setVisibleButton(false);
+      break;
+
+      case ActionTypes.CMPNTS_SET_API_BAR_CONTENT_VISIBLE_STATE:
+        this.setApiBarVisible(action.options);
+      break;
+
+      case ActionTypes.CMPNTS_UPDATE_API_BAR:
+        this.updateAPIBar(action.options);
+      break;
+
+      default:
+      return;
+        // do nothing
+    }
+
+    this.triggerChange();
+  }
+});
+
+Stores.DeleteDbModalStore = FauxtonAPI.Store.extend({
+  initialize: function () {
+    this.reset();
+  },
+
+  reset: function () {
+    this._deleteModal = {showDeleteModal: false, dbId: '', isSystemDatabase: false};
+  },
+
+  setDeleteModal: function (options) {
+    options.isSystemDatabase = app.utils.isSystemDatabase(options.dbId);
+    this._deleteModal = options;
+  },
+
+  getShowDeleteDatabaseModal: function () {
+    return this._deleteModal;
+  },
+
+  dispatch: function (action) {
+    switch (action.type) {
+      case ActionTypes.CMPNTS_DATABASES_SHOWDELETE_MODAL:
+        this.setDeleteModal(action.options);
+      break;
+
+      default:
+      return;
+    }
+
+    this.triggerChange();
+  }
+});
+
+
+
+
+Stores.deleteDbModalStore = new Stores.DeleteDbModalStore();
+Stores.deleteDbModalStore.dispatchToken = FauxtonAPI.dispatcher.register(Stores.deleteDbModalStore.dispatch);
+
+Stores.componentStore = new Stores.ComponentStore();
+Stores.componentStore.dispatchToken = FauxtonAPI.dispatcher.register(Stores.componentStore.dispatch);
+
+export default Stores;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/documents/doc-editor/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/doc-editor/components.react.jsx b/app/addons/documents/doc-editor/components.react.jsx
index f338a70..b1956f5 100644
--- a/app/addons/documents/doc-editor/components.react.jsx
+++ b/app/addons/documents/doc-editor/components.react.jsx
@@ -47,7 +47,6 @@ var DocEditorController = React.createClass({
   getDefaultProps: function () {
     return {
       database: {},
-      previousPage: '',
       isNewDoc: false
     };
   },
@@ -173,7 +172,7 @@ var DocEditorController = React.createClass({
               <i className="icon fonticon-ok-circled"></i> {saveButtonLabel}
             </button>
             <div>
-              <a href={this.props.previousPage} className="js-back cancel-button">Cancel</a>
+              <a href={FauxtonAPI.urls('allDocs', 'app', this.props.database.id)} className="js-back
cancel-button">Cancel</a>
             </div>
           </div>
           <div className="alignRight">
@@ -347,7 +346,7 @@ var UploadModal = React.createClass({
         <Modal.Body>
           <div className={errorClasses}>{this.state.errorMessage}</div>
           <div>
-            <form ref="uploadForm" className="form" method="post">
+            <form ref="uploadForm" className="form">
               <p>
                 Please select the file you want to upload as an attachment to this document.
This creates a new
                 revision of the document, so it's not necessary to save after uploading.
@@ -427,7 +426,7 @@ const CloneDocModal = React.createClass({
           <Modal.Title>Clone Document</Modal.Title>
         </Modal.Header>
         <Modal.Body>
-          <form className="form" method="post">
+          <form className="form" onSubmit={(e) => { e.preventDefault(); this.cloneDoc();
}}>
             <p>
               Set new document's ID:
             </p>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/documents/helpers.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/helpers.js b/app/addons/documents/helpers.js
index f477101..9bc0e5d 100644
--- a/app/addons/documents/helpers.js
+++ b/app/addons/documents/helpers.js
@@ -14,23 +14,6 @@ import app from "../../app";
 import FauxtonAPI from "../../core/api";
 
 
-function getPreviousPageForDoc (database, wasCloned) {
-  var previousPage = database.url('index'), // default to the current database's all_docs
page
-      lastPages = FauxtonAPI.router.lastPages;
-
-  if (!wasCloned && lastPages.length >= 2) {
-
-    // if we came from "/new", we don't want to link the user there
-    if (/(new|new_view)$/.test(lastPages[1])) {
-      previousPage = lastPages[0];
-    } else {
-      previousPage = lastPages[1];
-    }
-  }
-
-  return previousPage;
-}
-
 // sequence info is an array in couchdb2 with two indexes. On couch 1.x, it's just a string
/ number
 function getSeqNum (val) {
   return _.isArray(val) ? val[1] : val;
@@ -108,7 +91,6 @@ function truncateDoc (docString, maxRows) {
 
 
 export default {
-  getPreviousPageForDoc: getPreviousPageForDoc,
   getSeqNum: getSeqNum,
   getNewButtonLinks: getNewButtonLinks,
   getModifyDatabaseLinks: getModifyDatabaseLinks,

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/documents/routes-doc-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-doc-editor.js b/app/addons/documents/routes-doc-editor.js
index 0600105..828ec63 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -40,11 +40,11 @@ const RevBrowserRouteObject = FauxtonAPI.RouteObject.extend({
   },
 
   crumbs: function () {
-    const previousPage = Helpers.getPreviousPageForDoc(this.database);
+    const backLink = FauxtonAPI.urls('allDocs', 'app', this.database.safeID());
     const docUrl = FauxtonAPI.urls('document', 'app', this.database.safeID(), this.docId);
 
     return [
-      { type: 'back', link: previousPage },
+      { name: this.database.safeID(), link: backLink },
       { name: this.docId + ' > Conflicts' }
     ];
   },
@@ -73,7 +73,6 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
     this.docId = options[1];
     this.database = this.database || new Databases.Model({ id: this.databaseName });
     this.doc = new Documents.NewDoc(null, { database: this.database });
-    this.wasCloned = false;
   },
 
   routes: {
@@ -83,25 +82,16 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
     'database/:database/new': 'codeEditor'
   },
 
-  crumbs: function () {
-
-    if (this.docId) {
-      let previousPage = Helpers.getPreviousPageForDoc(this.database, this.wasCloned);
+  crumbs: function () {},
 
-      return [
-        { type: 'back', link: previousPage },
-        { name: this.docId }
-      ];
-    }
+  codeEditor: function (databaseName, docId) {
+    const backLink = FauxtonAPI.urls('allDocs', 'app', databaseName);
 
-    let previousPage = Helpers.getPreviousPageForDoc(this.database);
-    return [
-      { type: 'back', link: previousPage },
-      { name: 'New Document' }
+    this.crumbs =  [
+      { name: databaseName, link: backLink },
+      { name: docId ? docId : 'New Document' }
     ];
-  },
 
-  codeEditor: function (databaseName, docId) {
     this.database = new Databases.Model({ id: databaseName });
 
     if (docId) {
@@ -111,8 +101,7 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
     Actions.initDocEditor({ doc: this.doc, database: this.database });
     this.setComponent('#dashboard-content', ReactComponents.DocEditorController, {
       database: this.database,
-      isNewDoc: docId ? false : true,
-      previousPage: '#/' + Helpers.getPreviousPageForDoc(this.database)
+      isNewDoc: docId ? false : true
     });
   },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/base.js b/app/addons/fauxton/base.js
index 11c412b..f09c975 100644
--- a/app/addons/fauxton/base.js
+++ b/app/addons/fauxton/base.js
@@ -59,13 +59,13 @@ Fauxton.initialize = function () {
     if (routeObject.overrideBreadcrumbs) { return; }
 
     FauxtonAPI.masterLayout.removeView('#breadcrumbs');
+
     const crumbs = routeObject.get('crumbs');
 
     if (!crumbs.length) {
       return;
     }
 
-    ComponentActions.setBreadCrumbs(crumbs);
     routeObject.setComponent('#breadcrumbs', Breadcrumbs, {crumbs: crumbs});
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/18d08e96/app/core/tests/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/app/core/tests/routeObjectSpec.js b/app/core/tests/routeObjectSpec.js
index 8330e8b..61bd50e 100644
--- a/app/core/tests/routeObjectSpec.js
+++ b/app/core/tests/routeObjectSpec.js
@@ -44,7 +44,6 @@ describe('RouteObjects', function () {
         setView: sinon.spy(),
         renderView: sinon.spy(),
         hooks: [],
-        setBreadcrumbs: sinon.spy(),
         apiBar: apiBar
       };
 
@@ -141,7 +140,6 @@ describe('RouteObjects', function () {
         setView: sinon.spy(),
         renderView: sinon.spy(),
         hooks: [],
-        setBreadcrumbs: sinon.spy(),
         apiBar: apiBar
       };
 


Mime
View raw message