mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 01:41:39 +00:00
New file history (#2359)
This commit is contained in:
committed by
Daniel Pan
parent
5924c65d08
commit
ca0110e996
@@ -0,0 +1,63 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { gettext, filePath } from '../constance';
|
||||
import URLDecorator from '../../utils/url-decorator';
|
||||
|
||||
const propTypes = {
|
||||
isFirstItem: PropTypes.bool.isRequired,
|
||||
isListMenuShow: PropTypes.bool.isRequired,
|
||||
menuPosition: PropTypes.object.isRequired,
|
||||
currentItem: PropTypes.object,
|
||||
onDownloadFile: PropTypes.func.isRequired,
|
||||
onRestoreFile: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class HistoryListMenu extends React.Component {
|
||||
|
||||
onDownloadFile = () => {
|
||||
this.props.onDownloadFile();
|
||||
}
|
||||
|
||||
onRestoreFile = () => {
|
||||
this.props.onRestoreFile();
|
||||
}
|
||||
|
||||
render() {
|
||||
let style = {};
|
||||
let position = this.props.menuPosition;
|
||||
if (this.props.isListMenuShow) {
|
||||
style = {position: 'fixed',left: position.left + 'px',top: position.top + 'px',display: 'block'};
|
||||
}
|
||||
|
||||
if (!this.props.currentItem) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let objID = this.props.currentItem.rev_file_id;
|
||||
let url = URLDecorator.getUrl({type: 'download_historic_file', filePath: filePath, objID: objID});
|
||||
|
||||
if (this.props.isFirstItem) {
|
||||
return (
|
||||
<ul className="dropdown-menu" style={style}>
|
||||
<li className="dropdown-item" onClick={this.onDownloadFile}>
|
||||
<a href={url}>{gettext('Download')}</a>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="dropdown-menu" style={style}>
|
||||
<li className="dropdown-item" onClick={this.onRestoreFile}>{gettext('Restore')}</li>
|
||||
<li className="dropdown-item" onClick={this.onDownloadFile}>
|
||||
<a href={url}>{gettext('Download')}</a>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HistoryListMenu.propTypes = propTypes;
|
||||
|
||||
export default HistoryListMenu;
|
Reference in New Issue
Block a user