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 2017/09/06 13:11:06 UTC

[couchdb-fauxton] branch master updated: Update how Create Document link is created to allow overriding it (#975)

This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/master by this push:
     new b0c0512  Update how Create Document link is created to allow overriding it (#975)
b0c0512 is described below

commit b0c0512b10decddb14cfa16761b98f575f6e0b37
Author: Antonio Maranhao <30...@users.noreply.github.com>
AuthorDate: Wed Sep 6 09:11:04 2017 -0400

    Update how Create Document link is created to allow overriding it (#975)
    
    Fix link for Create Document button
---
 app/addons/documents/components/results-toolbar.js       | 5 ++---
 app/addons/documents/helpers.js                          | 6 ++++++
 app/addons/documents/tests/nightwatch/createsDocument.js | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/app/addons/documents/components/results-toolbar.js b/app/addons/documents/components/results-toolbar.js
index f7c95c0..90fc5e0 100644
--- a/app/addons/documents/components/results-toolbar.js
+++ b/app/addons/documents/components/results-toolbar.js
@@ -13,7 +13,7 @@ import React from 'react';
 import BulkDocumentHeaderController from "../header/header";
 import Stores from "../sidebar/stores";
 import Components from "../../components/react-components";
-import app from '../../../app';
+import Helpers from '../helpers';
 
 const {BulkActionComponent} = Components;
 const store = Stores.sidebarStore;
@@ -55,10 +55,9 @@ export class ResultsToolBar extends React.Component {
 
     let createDocumentLink = null;
     if (database) {
-      const safeDatabaseId = app.utils.safeURLName(database.id);
       createDocumentLink = (
         <div className="document-result-screen__toolbar-flex-container">
-          <a href={`#/database/${safeDatabaseId}/new`} className="btn save document-result-screen__toolbar-create-btn btn-primary">
+          <a href={Helpers.getNewDocUrl(database.id)} className="btn save document-result-screen__toolbar-create-btn btn-primary">
             Create Document
           </a>
         </div>
diff --git a/app/addons/documents/helpers.js b/app/addons/documents/helpers.js
index 1134e07..e9bec3b 100644
--- a/app/addons/documents/helpers.js
+++ b/app/addons/documents/helpers.js
@@ -89,10 +89,16 @@ const truncateDoc = (docString, maxRows) => {
   };
 };
 
+const getNewDocUrl = (databaseName) => {
+  const safeDatabaseName = encodeURIComponent(databaseName);
+  return FauxtonAPI.urls('new', 'newDocument', safeDatabaseName);
+};
+
 export default {
   getSeqNum,
   getNewButtonLinks,
   getModifyDatabaseLinks,
+  getNewDocUrl,
   parseJSON,
   truncateDoc
 };
diff --git a/app/addons/documents/tests/nightwatch/createsDocument.js b/app/addons/documents/tests/nightwatch/createsDocument.js
index c985bfd..428ed8b 100644
--- a/app/addons/documents/tests/nightwatch/createsDocument.js
+++ b/app/addons/documents/tests/nightwatch/createsDocument.js
@@ -71,7 +71,7 @@ module.exports = {
       .waitForElementPresent('.tableview-checkbox-cell', waitTime, false)
       .clickWhenVisible('.document-result-screen__toolbar-create-btn')
       .waitForElementPresent('#editor-container', waitTime, false)
-      .verify.urlEquals(baseUrl + '/#/database/' + newDatabaseName + '/new')
+      .verify.urlEquals(baseUrl + '/#database/' + newDatabaseName + '/new')
       .waitForElementPresent('.ace_gutter-active-line', waitTime, false)
 
       // confirm the header elements are showing up

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].