couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to e41b785
Date Fri, 11 Sep 2015 21:20:47 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master ae91c75e6 -> e41b78536


Allow custom buttons to be added to the Doc Editor page

This feature was accidentally removed in the recent full page doc
editor refactor. This ticket adds the option back in to allow
other code to add arbitrary buttons on the doc editor page.


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

Branch: refs/heads/master
Commit: e41b785368954eab04db90b8d79536010f6d6f89
Parents: ae91c75
Author: Ben Keen <ben.keen@gmail.com>
Authored: Fri Sep 11 13:11:29 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Fri Sep 11 13:11:29 2015 -0700

----------------------------------------------------------------------
 .../documents/doc-editor/components.react.jsx    |  9 ++++++++-
 .../tests/doc-editor.componentsSpec.react.jsx    | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e41b7853/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 ddc7fa1..e4a4a79 100644
--- a/app/addons/documents/doc-editor/components.react.jsx
+++ b/app/addons/documents/doc-editor/components.react.jsx
@@ -155,6 +155,13 @@ define([
       this.refs.docEditor.clearChanges();
     },
 
+    getExtensionIcons: function () {
+      var extensions = FauxtonAPI.getExtensions('DocEditor:icons');
+      return _.map(extensions, function (Extension, i) {
+        return (<Extension doc={this.state.doc} key={i} />);
+      }, this);
+    },
+
     getButtonRow: function () {
       if (this.props.isNewDoc) {
         return false;
@@ -162,7 +169,7 @@ define([
       return (
         <div>
           <AttachmentsPanelButton doc={this.state.doc} isLoading={this.state.isLoading}
/>
-          <div className="doc-editor-extension-icons"></div>
+          <div className="doc-editor-extension-icons">{this.getExtensionIcons()}</div>
           <PanelButton title="Upload Attachment" iconClass="icon-circle-arrow-up" onClick={Actions.showUploadModal}
/>
           <PanelButton title="Clone Document" iconClass="icon-repeat" onClick={Actions.showCloneDocModal}
/>
           <PanelButton title="Delete" iconClass="icon-trash" onClick={Actions.showDeleteDocModal}
/>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e41b7853/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx b/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
index b1720f2..15258e2 100644
--- a/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
+++ b/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
@@ -184,4 +184,23 @@ define([
     });
   });
 
+
+  describe("Custom Extension Buttons", function () {
+    it('supports buttons', function () {
+      var CustomButton = React.createClass({
+        render: function () {
+          return (
+            <button>Oh no she di'n't!</button>
+          );
+        }
+      });
+      FauxtonAPI.registerExtension('DocEditor:icons', CustomButton);
+
+      var container = document.createElement('div');
+      var el = TestUtils.renderIntoDocument(<Components.DocEditorController database={database}
/>, container);
+      assert.isTrue(/Oh\sno\sshe\sdi'n't!/.test(el.getDOMNode().outerHTML));
+      React.unmountComponentAtNode(container);
+    });
+  });
+
 });


Mime
View raw message