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: Fix View Attachments menu and upload modal in doc editor (#999)
Date Mon, 23 Oct 2017 12:34:27 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 8fd8f2b  Fix View Attachments menu and upload modal in doc editor (#999)
8fd8f2b is described below

commit 8fd8f2b8625bd341f05e943b51cfddfdbf096261
Author: Antonio Maranhao <30349380+Antonio-Maranhao@users.noreply.github.com>
AuthorDate: Mon Oct 23 08:34:25 2017 -0400

    Fix View Attachments menu and upload modal in doc editor (#999)
---
 app/addons/documents/doc-editor/actions.js    |  5 +++-
 app/addons/documents/doc-editor/components.js | 43 +++++++++++++++++----------
 2 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/app/addons/documents/doc-editor/actions.js b/app/addons/documents/doc-editor/actions.js
index b309335..7fda0df 100644
--- a/app/addons/documents/doc-editor/actions.js
+++ b/app/addons/documents/doc-editor/actions.js
@@ -173,6 +173,9 @@ function uploadAttachment (params) {
     type: 'PUT',
     data: file,
     contentType: file.type,
+    headers: {
+      Accept: "application/json; charset=utf-8"
+    },
     processData: false,
     xhrFields: {
       withCredentials: true
@@ -214,7 +217,7 @@ function uploadAttachment (params) {
       FauxtonAPI.dispatch({
         type: ActionTypes.FILE_UPLOAD_ERROR,
         options: {
-          error: JSON.parse(resp.responseText).reason
+          error: resp.responseJSON ? resp.responseJSON.reason : 'Error uploading file: ('
+ resp.statusText + ')'
         }
       });
     }
diff --git a/app/addons/documents/doc-editor/components.js b/app/addons/documents/doc-editor/components.js
index fd96b49..252d0d6 100644
--- a/app/addons/documents/doc-editor/components.js
+++ b/app/addons/documents/doc-editor/components.js
@@ -17,6 +17,7 @@ import app from "../../../app";
 import PropTypes from 'prop-types';
 
 import React from "react";
+import { Dropdown, MenuItem } from "react-bootstrap";
 import ReactDOM from "react-dom";
 import Actions from "./actions";
 import Stores from "./stores";
@@ -224,12 +225,11 @@ class AttachmentsPanelButton extends React.Component {
     return _.map(this.props.doc.get('_attachments'), function (item, filename) {
       var url = FauxtonAPI.urls('document', 'attachment', db, doc, app.utils.safeURLName(filename));
       return (
-        <li key={filename}>
-          <a href={url} target="_blank" data-bypass="true"> <strong>{filename}</strong>
-            <span className="attachment-delimiter">-</span>
-            <span>{item.content_type}, {Helpers.formatSize(item.length)}</span>
-          </a>
-        </li>
+        <MenuItem key={filename} href={url} target="_blank" data-bypass="true">
+          <strong>{filename}</strong>
+          <span className="attachment-delimiter">-</span>
+          <span>{item.content_type}{item.content_type ? ', ' : ''}{Helpers.formatSize(item.length)}</span>
+        </MenuItem>
       );
     });
   };
@@ -241,15 +241,16 @@ class AttachmentsPanelButton extends React.Component {
 
     return (
       <div className="panel-section view-attachments-section btn-group">
-        <button className="panel-button dropdown-toggle btn" data-bypass="true" data-toggle="dropdown"
title="View Attachments"
-          id="view-attachments-menu">
-          <i className="icon icon-paper-clip"></i>
-          <span className="button-text">View Attachments</span>
-          <span className="caret"></span>
-        </button>
-        <ul className="dropdown-menu" role="menu" aria-labelledby="view-attachments-menu">
-          {this.getAttachmentList()}
-        </ul>
+        <Dropdown id="view-attachments-menu">
+          <Dropdown.Toggle noCaret className="panel-button dropdown-toggle btn" data-bypass="true">
+            <i className="icon icon-paper-clip"></i>
+            <span className="button-text">View Attachments</span>
+            <span className="caret"></span>
+          </Dropdown.Toggle>
+          <Dropdown.Menu>
+            {this.getAttachmentList()}
+          </Dropdown.Menu>
+        </Dropdown>
       </div>
     );
   }
@@ -296,6 +297,18 @@ class UploadModal extends React.Component {
     };
   };
 
+  componentDidMount() {
+    store.on('change', this.onChange, this);
+  }
+
+  componentWillUnmount() {
+    store.off('change', this.onChange);
+  }
+
+  onChange = () => {
+    this.setState(this.getStoreState());
+  };
+
   closeModal = (e) => {
     if (e) {
       e.preventDefault();

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

Mime
View raw message