Repository: couchdb-fauxton Updated Branches: refs/heads/master 96d31bc7d -> 1de65dc28
componentize: add confirmbutton component PR: #313 PR-URL: https://github.com/apache/couchdb-fauxton/pull/313 Reviewed-By: garren smith <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/1de65dc2 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/1de65dc2 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/1de65dc2 Branch: refs/heads/master Commit: 1de65dc28ce85aa1e3a2f4f102df6fd70a66235e Parents: 96d31bc Author: Robert Kowalski <[email protected]> Authored: Mon Mar 9 10:04:15 2015 -0500 Committer: Robert Kowalski <[email protected]> Committed: Thu Mar 26 13:31:32 2015 +0100 ---------------------------------------------------------------------- .../components/react-components.react.jsx | 13 +++++++ .../tests/confirmButtonSpec.react.jsx | 41 ++++++++++++++++++++ .../documents/index-editor/components.react.jsx | 5 +-- 3 files changed, 56 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1de65dc2/app/addons/components/react-components.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/components/react-components.react.jsx b/app/addons/components/react-components.react.jsx index a21c794..4cb479a 100644 --- a/app/addons/components/react-components.react.jsx +++ b/app/addons/components/react-components.react.jsx @@ -258,7 +258,20 @@ function (app, FauxtonAPI, React, Components, beautifyHelper) { } }); + var ConfirmButton = React.createClass({ + render: function () { + return ( + <button type="submit" className="btn btn-success save"> + <i className="icon fonticon-ok-circled"></i> + {this.props.text} + </button> + ); + } + }); + + var ReactComponents = { + ConfirmButton: ConfirmButton, ToggleHeaderButton: ToggleHeaderButton, StyledSelect: StyledSelect, CodeEditor: CodeEditor, http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1de65dc2/app/addons/components/tests/confirmButtonSpec.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/components/tests/confirmButtonSpec.react.jsx b/app/addons/components/tests/confirmButtonSpec.react.jsx new file mode 100644 index 0000000..d6d1a9c --- /dev/null +++ b/app/addons/components/tests/confirmButtonSpec.react.jsx @@ -0,0 +1,41 @@ +// 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. +define([ + 'api', + 'addons/components/react-components.react', + + 'testUtils', + 'react' +], function (FauxtonAPI, ReactComponents, utils, React) { + + var assert = utils.assert; + var TestUtils = React.addons.TestUtils; + + describe('ConfirmButton', function () { + var container, button; + beforeEach(function () { + container = document.createElement('div'); + }); + + afterEach(function () { + React.unmountComponentAtNode(container); + }); + + it('should render text properties', function () { + button = TestUtils.renderIntoDocument( + <ReactComponents.ConfirmButton text="Click here to render Rocko Artischocko" />, + container + ); + assert.equal($(button.getDOMNode()).text(), 'Click here to render Rocko Artischocko'); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1de65dc2/app/addons/documents/index-editor/components.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/documents/index-editor/components.react.jsx b/app/addons/documents/index-editor/components.react.jsx index 01e5153..1d3e98c 100644 --- a/app/addons/documents/index-editor/components.react.jsx +++ b/app/addons/documents/index-editor/components.react.jsx @@ -27,6 +27,7 @@ function (app, FauxtonAPI, React, Stores, Actions, Components, ReactComponents, var StyledSelect = ReactComponents.StyledSelect; var CodeEditor = ReactComponents.CodeEditor; var PaddedBorderedBox = ReactComponents.PaddedBorderedBox; + var ConfirmButton = ReactComponents.ConfirmButton; var DesignDocSelector = React.createClass({ @@ -397,9 +398,7 @@ function (app, FauxtonAPI, React, Stores, Actions, Components, ReactComponents, </PaddedBorderedBox> <div className="padded-box"> <div className="control-group"> - <button type="submit" className="btn btn-success save"> - <i className="icon fonticon-ok-circled"></i> Save & Build Index - </button> + <ConfirmButton text="Save & Build Index" /> <DeleteView /> </div> </div>
