Github user benkeen commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/670#discussion_r60451413
  
    --- Diff: app/addons/documents/rev-browser/rev-browser.components.react.jsx 
---
    @@ -0,0 +1,446 @@
    +// 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([
    +  '../../../core/api',
    +  '../../../app',
    +  'react',
    +  'react-dom',
    +  './rev-browser.actions',
    +  './rev-browser.stores',
    +  '../../components/react-components.react',
    +
    +  'react-bootstrap',
    +  'react-select',
    +  'jsondiffpatch',
    +  'jsondiffpatch/src/formatters/html',
    +
    +  'brace',
    +
    +  'react-select/less/default.less',
    +  'jsondiffpatch/public/formatters-styles/html.css'
    +], (FauxtonAPI, app, React, ReactDOM, RevActions, RevStores, 
ReactComponents,
    +    ReactBootstrap, ReactSelect, jdp, jdpformatters, ace) => {
    +
    +  const storageKeyDeleteConflictsModal = 'deleteConflictsHideModal';
    +
    +  const store = RevStores.revBrowserStore;
    +  const ConfirmButton = ReactComponents.ConfirmButton;
    +
    +  const ButtonGroup = ReactBootstrap.ButtonGroup;
    +  const Button = ReactBootstrap.Button;
    +  const Modal = ReactBootstrap.Modal;
    +
    +  require('brace/ext/static_highlight');
    +  const highlight = ace.acequire('ace/ext/static_highlight');
    +
    +  require('brace/mode/json');
    +  const JavaScriptMode = ace.acequire('ace/mode/json').Mode;
    +
    +  require('brace/theme/idle_fingers');
    +  const theme = ace.acequire('ace/theme/idle_fingers');
    +
    +
    +  class DiffyController extends React.Component {
    +
    +    constructor (props) {
    +      super(props);
    +
    +      this.state = this.getStoreState();
    +    }
    +
    +    getStoreState () {
    +
    +      return {
    +        tree: store.getRevTree(),
    +        ours: store.getOurs(),
    +        theirs: store.getTheirs(),
    +        conflictingRevs: store.getConflictingRevs(),
    +        dropdownData: store.getDropdownData(),
    +        isDiffViewEnabled: store.getIsDiffViewEnabled(),
    +        databaseName: store.getDatabaseName()
    +      };
    +    }
    +
    +    componentDidMount () {
    +      store.on('change', this.onChange, this);
    +    }
    +
    +    componentWillUnmount () {
    +      store.off('change', this.onChange);
    +    }
    +
    +    onChange () {
    +      this.setState(this.getStoreState());
    +    }
    +
    +    toggleDiffView (enableDiff) {
    +      RevActions.toggleDiffView(enableDiff);
    +    }
    +
    +    render () {
    +      const {tree, ours, theirs, dropdownData, conflictingRevs, 
isDiffViewEnabled} = this.state;
    +
    +      if (!tree) {
    +        return null;
    +      }
    +
    +      // no conflicts happened for this doc
    +      if (!theirs || !conflictingRevs.length) {
    +        return <div style={{textAlign: 'center', color: '#fff'}}><h2>No 
conflicts</h2></div>;
    +      }
    +
    +      return (
    +        <div className="revision-wrapper scrollable">
    +          <RevisionBrowserControls {...this.state} />
    +          <div className="revision-view-controls">
    +            <ButtonGroup className="two-sides-toggle-button">
    +              <Button
    +                style={{width: '120px'}}
    +                className={isDiffViewEnabled ? 'active' : ''}
    +                onClick={this.toggleDiffView.bind(this, true)}
    +              >
    +                <i className="icon-columns" /> Diff
    +              </Button>
    +              <Button
    +                style={{width: '120px'}}
    +                className={isDiffViewEnabled ? '' : 'active'}
    +                onClick={this.toggleDiffView.bind(this, false)}
    +              >
    +                <i className="icon-file-text" /> Document
    +              </Button>
    +            </ButtonGroup>
    +          </div>
    +
    +          {isDiffViewEnabled ?
    +            <RevisionDiffArea ours={ours} theirs={theirs} /> :
    +            <SplitScreenArea ours={ours} theirs={theirs} /> }
    +        </div>
    +      );
    +    }
    +  };
    +
    +
    +  class SplitScreenArea extends React.Component {
    +
    +    constructor (props) {
    +      super(props);
    +    }
    +
    +    componentDidUpdate () {
    +      this.hightlightAfterRender();
    +    }
    +
    +    componentDidMount () {
    +      this.hightlightAfterRender();
    +    }
    +
    +    hightlightAfterRender () {
    +      const format = (input) => { return JSON.stringify(input, null, '  
'); };
    +
    +      const jsmode = new JavaScriptMode();
    +      const left = ReactDOM.findDOMNode(this.refs.revLeftOurs);
    +      const right = ReactDOM.findDOMNode(this.refs.revRightTheirs);
    +
    +      const leftRes = highlight.render(format(this.props.ours), jsmode, 
theme, 0, true);
    +      left.innerHTML = leftRes.html;
    +      const rightRes = highlight.render(format(this.props.theirs), jsmode, 
theme, 0, true);
    +      right.innerHTML = rightRes.html;
    +    }
    +
    +    render () {
    +      const {ours, theirs} = this.props;
    +
    +      if (!ours || !theirs) {
    +        return <div></div>;
    +      }
    +
    +      return (
    +        <div className="revision-split-area" style={{padding: '20px 15px', 
display: 'flex', color: '#fff'}}>
    --- End diff --
    
    May be better to move this to less or you'll need to include all the 
cross-browser rules for flex here (see `.display-flex()` in 
assets/less/mixins.less).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to