couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [couchdb-fauxton] branch master updated: (#893) - consistent error message for views and doc
Date Mon, 03 Apr 2017 08:30:28 GMT
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  8aabaf3   (#893) - consistent error message for views and doc
8aabaf3 is described below

commit 8aabaf3206d7e2077541b0a1333c804eb16f47a5
Author: garren smith <garren.smith@gmail.com>
AuthorDate: Mon Apr 3 10:30:22 2017 +0200

    (#893) - consistent error message for views and doc
    
    consistent error message for views and doc
---
 app/addons/documents/doc-editor/actions.js    | 2 +-
 app/addons/documents/index-results/actions.js | 9 ++++++++-
 app/core/utils.js                             | 6 ++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/app/addons/documents/doc-editor/actions.js b/app/addons/documents/doc-editor/actions.js
index e7a45ac..b309335 100644
--- a/app/addons/documents/doc-editor/actions.js
+++ b/app/addons/documents/doc-editor/actions.js
@@ -37,7 +37,7 @@ function initDocEditor (params) {
     }
   }, function (xhr) {
     if (xhr.status === 404) {
-      errorNotification('The document does not exist.');
+      errorNotification(`The ${doc.id} document does not exist.`);
     }
 
     FauxtonAPI.navigate(FauxtonAPI.urls('allDocs', 'app', params.database.id, ''));
diff --git a/app/addons/documents/index-results/actions.js b/app/addons/documents/index-results/actions.js
index b01fc69..b484fad 100644
--- a/app/addons/documents/index-results/actions.js
+++ b/app/addons/documents/index-results/actions.js
@@ -57,13 +57,20 @@ export default {
       //Make this more robust as sometimes the colection is passed through here.
       var xhr = collection.responseText ? collection : _xhr;
       var errorMsg = 'Bad Request';
+      console.log('xxx', xhr);
 
       try {
         const responseText = JSON.parse(xhr.responseText);
         if (responseText.reason) {
           errorMsg = responseText.reason;
         }
-        if (responseText.error && responseText.error === 'not_found') {
+
+        if (responseText.reason && responseText.reason === 'missing_named_view')
{
+          errorMsg = `The ${options.collection.view} ${options.collection.design} does not
exist.`;
+          FauxtonAPI.navigate(
+            FauxtonAPI.urls('allDocsSanitized', 'app', options.collection.database.safeID()),
+            {trigger: true}
+          );
           return;
         }
       } catch (e) {
diff --git a/app/core/utils.js b/app/core/utils.js
index 584444f..3c0d33f 100644
--- a/app/core/utils.js
+++ b/app/core/utils.js
@@ -124,6 +124,12 @@ const utils = {
   },
 
   stripHTML: function (str) {
+
+    if (!document) {
+      //not in browser, this should be ignored when testing in jest
+      return str;
+    }
+
     var tmpElement = document.createElement("div");
     tmpElement.innerHTML = str;
     return tmpElement.textContent || tmpElement.innerText;

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

Mime
View raw message