1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 13:50:07 +00:00

[shared file view] added modification for 'preview only' (#3867)

This commit is contained in:
llj
2019-07-17 17:34:22 +08:00
committed by Daniel Pan
parent accb814d22
commit 694900e82b
2 changed files with 30 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ const propTypes = {
};
let loginUser = window.app.pageOptions.name;
const { repoID, sharedToken, trafficOverLimit, fileName, fileSize, sharedBy, siteName, enableWatermark, download, zipped, filePath } = window.shared.pageOptions;
const { repoID, sharedToken, trafficOverLimit, fileName, fileSize, sharedBy, siteName, enableWatermark, canDownload, zipped, filePath } = window.shared.pageOptions;
class SharedFileView extends React.Component {
@@ -50,6 +50,21 @@ class SharedFileView extends React.Component {
duration: 3
});
}
if (!canDownload) {
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
return false;
});
document.addEventListener('keydown', function(e) {
// prevent ctrl + s/p/a/c, i.e, 'save', 'print', 'select all', 'copy'
// metaKey: for mac
if ((e.ctrlKey || e.metaKey) && (e.which == 83 || e.which == 80 || e.which == 65 || e.which == 67)) {
e.preventDefault();
e.stopPropagation();
return false;
}
});
}
}
renderPath = () => {
@@ -91,7 +106,7 @@ class SharedFileView extends React.Component {
<p className="share-by ellipsis">{gettext('Shared by:')}{' '}{sharedBy}</p>
}
</div>
{download &&
{canDownload &&
<div className="float-right">
{(loginUser && loginUser !== sharedBy) &&
<Button color="secondary" id="save"