summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/admin_console/storage_settings.jsx20
-rw-r--r--webapp/components/create_post.jsx7
-rw-r--r--webapp/components/file_upload.jsx100
3 files changed, 93 insertions, 34 deletions
diff --git a/webapp/components/admin_console/storage_settings.jsx b/webapp/components/admin_console/storage_settings.jsx
index 3b634dc53..1400b673c 100644
--- a/webapp/components/admin_console/storage_settings.jsx
+++ b/webapp/components/admin_console/storage_settings.jsx
@@ -25,6 +25,7 @@ export default class StorageSettings extends AdminSettings {
}
getConfigFromState(config) {
+ config.FileSettings.EnableFileAttachments = this.state.enableFileAttachments;
config.FileSettings.MaxFileSize = this.parseInt(this.state.maxFileSize) * 1024 * 1024;
config.FileSettings.DriverName = this.state.driverName;
config.FileSettings.Directory = this.state.directory;
@@ -39,6 +40,7 @@ export default class StorageSettings extends AdminSettings {
getStateFromConfig(config) {
return {
+ enableFileAttachments: config.FileSettings.EnableFileAttachments,
maxFileSize: config.FileSettings.MaxFileSize / 1024 / 1024,
driverName: config.FileSettings.DriverName,
directory: config.FileSettings.Directory,
@@ -199,6 +201,23 @@ export default class StorageSettings extends AdminSettings {
onChange={this.handleChange}
disabled={this.state.driverName !== DRIVER_S3}
/>
+ <BooleanSetting
+ id='enableFileAttachments'
+ label={
+ <FormattedMessage
+ id='admin.file.enableFileAttachments'
+ defaultMessage='Enable File Attachments:'
+ />
+ }
+ helpText={
+ <FormattedMessage
+ id='admin.file.enableFileAttachmentsDesc'
+ defaultMessage='When false, disable file and image uploads on messages.'
+ />
+ }
+ value={this.state.enableFileAttachments}
+ onChange={this.handleChange}
+ />
<TextSetting
id='maxFileSize'
label={
@@ -216,6 +235,7 @@ export default class StorageSettings extends AdminSettings {
}
value={this.state.maxFileSize}
onChange={this.handleChange}
+ disabled={!this.state.enableFileAttachments}
/>
</SettingsGroup>
);
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index 390940914..6e59b88b1 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -630,6 +630,11 @@ export default class CreatePost extends React.Component {
);
}
+ let attachmentsDisabled = '';
+ if (global.window.mm_config.EnableFileAttachments === 'false') {
+ attachmentsDisabled = ' post-create--attachment-disabled';
+ }
+
return (
<form
id='create_post'
@@ -638,7 +643,7 @@ export default class CreatePost extends React.Component {
className={centerClass}
onSubmit={this.handleSubmit}
>
- <div className='post-create'>
+ <div className={'post-create' + attachmentsDisabled}>
<div className='post-create-body'>
<div className='post-body__cell'>
<Textbox
diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx
index af5d76829..4ef8cd28c 100644
--- a/webapp/components/file_upload.jsx
+++ b/webapp/components/file_upload.jsx
@@ -132,6 +132,11 @@ class FileUpload extends React.Component {
}
handleDrop(e) {
+ if (global.window.mm_config.EnableFileAttachments === 'false') {
+ this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.'));
+ return;
+ }
+
this.props.onUploadError(null);
var files = e.originalEvent.dataTransfer.files;
@@ -163,36 +168,47 @@ class FileUpload extends React.Component {
}
});
- $(containerSelector).dragster({
- enter(dragsterEvent, e) {
- var files = e.originalEvent.dataTransfer;
-
- if (Utils.isFileTransfer(files)) {
- $(overlaySelector).removeClass('hidden');
+ let dragsterActions = {};
+ if (global.window.mm_config.EnableFileAttachments === 'true') {
+ dragsterActions = {
+ enter(dragsterEvent, e) {
+ var files = e.originalEvent.dataTransfer;
+
+ if (Utils.isFileTransfer(files)) {
+ $(overlaySelector).removeClass('hidden');
+ }
+ },
+ leave(dragsterEvent, e) {
+ var files = e.originalEvent.dataTransfer;
+
+ if (Utils.isFileTransfer(files) && !overlay.hasClass('hidden')) {
+ overlay.addClass('hidden');
+ }
+
+ dragTimeout.cancel();
+ },
+ over() {
+ dragTimeout.fireAfter(OverlayTimeout);
+ },
+ drop(dragsterEvent, e) {
+ if (!overlay.hasClass('hidden')) {
+ overlay.addClass('hidden');
+ }
+
+ dragTimeout.cancel();
+
+ self.handleDrop(e);
}
- },
- leave(dragsterEvent, e) {
- var files = e.originalEvent.dataTransfer;
-
- if (Utils.isFileTransfer(files) && !overlay.hasClass('hidden')) {
- overlay.addClass('hidden');
- }
-
- dragTimeout.cancel();
- },
- over() {
- dragTimeout.fireAfter(OverlayTimeout);
- },
- drop(dragsterEvent, e) {
- if (!overlay.hasClass('hidden')) {
- overlay.addClass('hidden');
+ };
+ } else {
+ dragsterActions = {
+ drop(dragsterEvent, e) {
+ self.handleDrop(e);
}
+ };
+ }
- dragTimeout.cancel();
-
- self.handleDrop(e);
- }
- });
+ $(containerSelector).dragster(dragsterActions);
this.props.onFileUploadChange();
}
@@ -247,7 +263,12 @@ class FileUpload extends React.Component {
// This looks redundant, but must be done this way due to
// setState being an asynchronous call
- if (items) {
+ if (items && items.length > 0) {
+ if (global.window.mm_config.EnableFileAttachments === 'false') {
+ this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.'));
+ return;
+ }
+
var numToUpload = Math.min(Constants.MAX_UPLOAD_FILES - this.props.getFileCount(ChannelStore.getCurrentId()), items.length);
if (items.length > numToUpload) {
@@ -305,6 +326,12 @@ class FileUpload extends React.Component {
keyUpload(e) {
if (Utils.cmdOrCtrlPressed(e) && e.keyCode === Constants.KeyCodes.U) {
e.preventDefault();
+
+ if (global.window.mm_config.EnableFileAttachments === 'false') {
+ this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.'));
+ return;
+ }
+
if ((this.props.postType === 'post' && document.activeElement.id === 'post_textbox') ||
(this.props.postType === 'comment' && document.activeElement.id === 'reply_textbox')) {
$(this.refs.fileInput).focus().trigger('click');
@@ -361,11 +388,9 @@ class FileUpload extends React.Component {
);
}
- return (
- <span
- ref='input'
- className={'btn btn-file' + (uploadsRemaining <= 0 ? ' btn-file__disabled' : '')}
- >
+ let fileDiv;
+ if (global.window.mm_config.EnableFileAttachments === 'true') {
+ fileDiv = (
<div className='icon--attachment'>
<span
className='icon'
@@ -380,6 +405,15 @@ class FileUpload extends React.Component {
accept={accept}
/>
</div>
+ );
+ }
+
+ return (
+ <span
+ ref='input'
+ className={'btn btn-file' + (uploadsRemaining <= 0 ? ' btn-file__disabled' : '')}
+ >
+ {fileDiv}
{emojiSpan}
</span>
);