diff --git a/frontend/src/components/shared-file-view/shared-file-view.js b/frontend/src/components/shared-file-view/shared-file-view.js index 34fcf7edd4..fc4b61cc05 100644 --- a/frontend/src/components/shared-file-view/shared-file-view.js +++ b/frontend/src/components/shared-file-view/shared-file-view.js @@ -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 {
{gettext('Shared by:')}{' '}{sharedBy}
} - {download && + {canDownload &&