1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 02:10:24 +00:00

add file-diff (#2398)

This commit is contained in:
cainiao222
2018-09-26 02:27:14 -07:00
committed by Daniel Pan
parent 7da4642806
commit 2d490b09cd
7 changed files with 63 additions and 33 deletions

View File

@@ -39,7 +39,7 @@ class HistoryListItem extends React.Component {
return;
}
this.setState({isShowOperationIcon: false}); //restore to default state
this.props.onHistoryItemClick(this.props.item);
this.props.onHistoryItemClick(this.props.item, this.props.preCommitID);
}
onMenuControlClick = (e) => {

View File

@@ -2,6 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import HisotyListItem from './history-list-item';
import Loading from '../loading';
import axios from 'axios';
import editUtilties from '../../utils/editor-utilties';
import URLDecorator from '../../utils/url-decorator';
import { filePath } from '../constants';
const propTypes = {
hasMore: PropTypes.bool.isRequired,
@@ -27,15 +31,42 @@ class HistoryListView extends React.Component {
}
}
componentDidMount() {
let historyList = this.props.historyList;
if (historyList.length > 1) {
let downLoadURL = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: historyList[0].rev_file_id});
let downLoadURL1 = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: historyList[1].rev_file_id});
axios.all([
editUtilties.getFileContent(downLoadURL),
editUtilties.getFileContent(downLoadURL1)
]).then(axios.spread((res1, res2) => {
this.props.setDiffContent(res1.data, res2.data);
}));
} else {
let downLoadURL = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: historyList[0].rev_file_id});
axios.all([
editUtilties.getFileContent(downLoadURL),
]).then(axios.spread((res1) => {
this.props.setDiffContent(res1.data, '');
}));
}
}
render() {
return (
<ul className="history-list-container" onScroll={this.onScrollHandler}>
{this.props.historyList.map((item, index) => {
{this.props.historyList.map((item, index, historyList) => {
let preItemIndex = index + 1;
if (preItemIndex === historyList.length) {
preItemIndex = index;
}
return (
<HisotyListItem
key={index}
item={item}
isFirstItem={index === 0}
preCommitID={historyList[preItemIndex].rev_file_id}
currentItem={this.props.currentItem}
isItemFrezeed={this.props.isItemFrezeed}
onMenuControlClick={this.props.onMenuControlClick}