mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 14:21:23 +00:00
[shared file view] added modification for 'preview only' (#3867)
This commit is contained in:
@@ -15,7 +15,7 @@ const propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let loginUser = window.app.pageOptions.name;
|
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 {
|
class SharedFileView extends React.Component {
|
||||||
|
|
||||||
@@ -50,6 +50,21 @@ class SharedFileView extends React.Component {
|
|||||||
duration: 3
|
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 = () => {
|
renderPath = () => {
|
||||||
@@ -91,7 +106,7 @@ class SharedFileView extends React.Component {
|
|||||||
<p className="share-by ellipsis">{gettext('Shared by:')}{' '}{sharedBy}</p>
|
<p className="share-by ellipsis">{gettext('Shared by:')}{' '}{sharedBy}</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{download &&
|
{canDownload &&
|
||||||
<div className="float-right">
|
<div className="float-right">
|
||||||
{(loginUser && loginUser !== sharedBy) &&
|
{(loginUser && loginUser !== sharedBy) &&
|
||||||
<Button color="secondary" id="save"
|
<Button color="secondary" id="save"
|
||||||
|
@@ -35,6 +35,18 @@
|
|||||||
{% elif filetype == 'Unknown' %}
|
{% elif filetype == 'Unknown' %}
|
||||||
{% render_bundle 'sharedFileViewUnknown' 'css' %}
|
{% render_bundle 'sharedFileViewUnknown' 'css' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if not permissions.can_download %}
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
user-select:none;
|
||||||
|
}
|
||||||
|
@media print {
|
||||||
|
html {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
@@ -51,7 +63,7 @@
|
|||||||
sharedBy: '{{ shared_by|email2nickname }}',
|
sharedBy: '{{ shared_by|email2nickname }}',
|
||||||
siteName: '{{ site_name }}',
|
siteName: '{{ site_name }}',
|
||||||
enableWatermark: {% if enable_watermark %}true{% else %}false{% endif %},
|
enableWatermark: {% if enable_watermark %}true{% else %}false{% endif %},
|
||||||
download: '{{ permissions.can_download }}' == 'True',
|
canDownload: {% if permissions.can_download %}true{% else %}false{% endif %},
|
||||||
fileContent: '{{ file_content|escapejs }}',
|
fileContent: '{{ file_content|escapejs }}',
|
||||||
err: {% if err %}'{{ err }}'{% else %}''{% endif %},
|
err: {% if err %}'{{ err }}'{% else %}''{% endif %},
|
||||||
fileType: '{{ filetype }}',
|
fileType: '{{ filetype }}',
|
||||||
|
Reference in New Issue
Block a user