2018-09-12 09:01:48 +00:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import editUtilties from './utils/editor-utilties';
|
2018-10-09 02:56:59 +00:00
|
|
|
import { filePath } from './utils/constants';
|
2018-09-12 09:01:48 +00:00
|
|
|
import URLDecorator from './utils/url-decorator';
|
|
|
|
import SidePanel from './pages/file-history/side-panel';
|
|
|
|
import MainPanel from './pages/file-history/main-panel';
|
2018-09-26 09:27:14 +00:00
|
|
|
import axios from 'axios';
|
2018-09-12 09:01:48 +00:00
|
|
|
import './assets/css/fa-solid.css';
|
|
|
|
import './assets/css/fa-regular.css';
|
|
|
|
import './assets/css/fontawesome.css';
|
|
|
|
import './css/layout.css';
|
|
|
|
import './css/file-history.css';
|
2018-09-19 01:57:17 +00:00
|
|
|
import './css/toolbar.css';
|
2018-09-20 02:19:11 +00:00
|
|
|
import './css/search.css';
|
2018-09-12 09:01:48 +00:00
|
|
|
|
|
|
|
class FileHistory extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
content: '',
|
|
|
|
renderingContent: true,
|
|
|
|
fileOwner: '',
|
2018-09-26 09:27:14 +00:00
|
|
|
markdownContent: '',
|
|
|
|
markdownContentOld: ''
|
2018-09-12 09:01:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-09-26 09:27:14 +00:00
|
|
|
|
|
|
|
setDiffContent = (markdownContent, markdownContentOld)=> {
|
|
|
|
this.setState({
|
|
|
|
renderingContent: false,
|
|
|
|
markdownContent: markdownContent,
|
|
|
|
markdownContentOld: markdownContentOld
|
2018-09-12 09:01:48 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-26 09:27:14 +00:00
|
|
|
|
|
|
|
onHistoryItemClick = (item, preCommitID)=> {
|
2018-09-12 09:01:48 +00:00
|
|
|
let objID = item.rev_file_id;
|
|
|
|
let downLoadURL = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: objID});
|
2018-09-26 09:27:14 +00:00
|
|
|
let downLoadURL1 = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: preCommitID});
|
2018-09-12 09:01:48 +00:00
|
|
|
this.setState({renderingContent: true});
|
2018-09-26 09:27:14 +00:00
|
|
|
axios.all([
|
|
|
|
editUtilties.getFileContent(downLoadURL),
|
|
|
|
editUtilties.getFileContent(downLoadURL1)
|
|
|
|
]).then(axios.spread((res1, res2) => {
|
|
|
|
this.setDiffContent(res1.data, res2.data);
|
|
|
|
}));
|
2018-09-12 09:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<div id="main" className="history-main">
|
|
|
|
<SidePanel
|
|
|
|
fileOwner={this.state.fileOwner}
|
|
|
|
onHistoryItemClick={this.onHistoryItemClick}
|
2018-09-26 09:27:14 +00:00
|
|
|
setDiffContent={this.setDiffContent}
|
2018-09-12 09:01:48 +00:00
|
|
|
/>
|
|
|
|
<MainPanel
|
2018-09-26 09:27:14 +00:00
|
|
|
markdownContent={this.state.markdownContent}
|
|
|
|
markdownContentOld={this.state.markdownContentOld}
|
2018-09-12 09:01:48 +00:00
|
|
|
renderingContent={this.state.renderingContent}
|
|
|
|
/>
|
2018-09-26 09:27:14 +00:00
|
|
|
|
2018-09-12 09:01:48 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render (
|
|
|
|
<FileHistory />,
|
|
|
|
document.getElementById('wrapper')
|
|
|
|
);
|