popojargo commented on a change in pull request #1036: move revision browser to 
use redux
URL: https://github.com/apache/couchdb-fauxton/pull/1036#discussion_r158586260
 
 

 ##########
 File path: 
app/addons/documents/rev-browser/components/revisionbrowsercontrols.js
 ##########
 @@ -0,0 +1,140 @@
+// 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.
+
+import React from 'react';
+import ReactDOM from "react-dom";
+import PropTypes from 'prop-types';
+import app from '../../../../app';
+import ReactComponents from "../../../components/react-components";
+import ConflictingRevisionsDropDown from './conflictingrevisiondropdown';
+import ConfirmModal from './confirmmodal';
+
+const ConfirmButton = ReactComponents.ConfirmButton;
+const storageKeyDeleteConflictsModal = 'deleteConflictsHideModal';
+
+export default class RevisionBrowserControls extends React.Component {
+
+  constructor (props) {
+    super(props);
+
+    this.state = {showModal: false};
+  }
+
+  onRevisionClick (revTheirs) {
+    this.props.chooseLeaves(this.props.ours, revTheirs.value);
+  }
+
+  onForwardClick () {
+    const conflictingRevs = this.props.conflictingRevs;
+    const index = conflictingRevs.indexOf(this.props.theirs._rev);
+
+    const next = conflictingRevs[index + 1];
+
+    if (!next) {
+      return;
+    }
+
+    this.props.chooseLeaves(this.props.ours, next);
+  }
+
+  onBackwardClick () {
+    const conflictingRevs = this.props.conflictingRevs;
+    const index = conflictingRevs.indexOf(this.props.theirs._rev);
+
+    const next = conflictingRevs[index - 1];
+
+    if (!next) {
+      return;
+    }
+
+    this.props.chooseLeaves(this.props.ours, next);
+  }
+
+  selectAsWinner (docToWin, doNotShowModalAgain) {
+    if (doNotShowModalAgain) {
+      app.utils.localStorageSet(storageKeyDeleteConflictsModal, true);
+    }
+
+    this.props.selectRevAsWinner(docToWin._id, docToWin._rev, this.props.tree);
+  }
+
+  onSelectAsWinnerClick (docToWin) {
+    if (app.utils.localStorageGet(storageKeyDeleteConflictsModal) !== true) {
+      this.props.toggleConfirmModal(true, docToWin);
+      return;
+    }
+
+    this.selectAsWinner(docToWin);
+  }
+
+  render () {
+    const {tree} = this.props;
+    const cellStyle = {paddingRight: '30px'};
+
+    return (
+      <div className="revision-browser-controls">
+        <ConfirmModal
+          toggleConfirmModal={this.props.toggleConfirmModal}
+          onConfirm={this.selectAsWinner.bind(this)}
 
 Review comment:
   Again, binding should be in constructor ( There are other binding in this 
file that should be moved too)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to