mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 11:27:18 +00:00
copy_file_from_history (#5486)
* copy_file_from_history * fix SeadocCopyHistoryFile
This commit is contained in:
@@ -48,6 +48,11 @@ class HistoryVersion extends React.Component {
|
||||
// nothing todo
|
||||
}
|
||||
|
||||
onItemCopy = () => {
|
||||
const { historyVersion } = this.props;
|
||||
this.props.onCopy(historyVersion);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { currentVersion, historyVersion } = this.props;
|
||||
if (!currentVersion || !historyVersion) return null;
|
||||
@@ -80,6 +85,7 @@ class HistoryVersion extends React.Component {
|
||||
<DropdownMenu>
|
||||
{(this.props.index !== 0) && <DropdownItem onClick={this.onItemRestore}>{gettext('Restore')}</DropdownItem>}
|
||||
<DropdownItem tag='a' href={url} onClick={this.onItemDownLoad}>{gettext('Download')}</DropdownItem>
|
||||
{(this.props.index !== 0) && <DropdownItem onClick={this.onItemCopy}>{gettext('Copy')}</DropdownItem>}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
</div>
|
||||
@@ -94,6 +100,7 @@ HistoryVersion.propTypes = {
|
||||
historyVersion: PropTypes.object,
|
||||
onSelectHistoryVersion: PropTypes.func.isRequired,
|
||||
onRestore: PropTypes.func.isRequired,
|
||||
onCopy: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default HistoryVersion;
|
||||
|
@@ -115,6 +115,19 @@ class SidePanel extends Component {
|
||||
this.props.onSelectHistoryVersion(historyVersion, historyVersions[historyVersionIndex + 1]);
|
||||
}
|
||||
|
||||
copyHistoryFile = (historyVersion) => {
|
||||
const { path, revFileId, ctime } = historyVersion;
|
||||
seafileAPI.sdocCopyHistoryFile(historyRepoID, path, revFileId, ctime).then(res => {
|
||||
let message = gettext('Successfully copied %(name)s.');
|
||||
let filename = res.data.file_name;
|
||||
message = message.replace('%(name)s', filename);
|
||||
toaster.success(message);
|
||||
}).catch(error => {
|
||||
const errorMessage = Utils.getErrorMsg(error, true);
|
||||
toaster.danger(gettext(errorMessage));
|
||||
});
|
||||
}
|
||||
|
||||
renderHistoryVersions = () => {
|
||||
const { isLoading, historyVersions, errorMessage } = this.state;
|
||||
if (historyVersions.length === 0) {
|
||||
@@ -150,6 +163,7 @@ class SidePanel extends Component {
|
||||
historyVersion={historyVersion}
|
||||
onSelectHistoryVersion={this.onSelectHistoryVersion}
|
||||
onRestore={this.restoreVersion}
|
||||
onCopy={this.copyHistoryFile}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
Reference in New Issue
Block a user