From fb2022fb1cb3c8023efd22316d570d9b26facbd1 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 4 Aug 2017 14:05:33 -0400 Subject: PLT-6924 Added ability to disable file uploads/downloads on old mobile apps (#7117) --- webapp/components/file_upload.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'webapp/components/file_upload.jsx') diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx index 0eb12a097..3e28f11df 100644 --- a/webapp/components/file_upload.jsx +++ b/webapp/components/file_upload.jsx @@ -8,6 +8,7 @@ import Constants from 'utils/constants.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import DelayedAction from 'utils/delayed_action.jsx'; import * as UserAgent from 'utils/user_agent.jsx'; +import * as FileUtils from 'utils/file_utils'; import * as Utils from 'utils/utils.jsx'; import {intlShape, injectIntl, defineMessages} from 'react-intl'; @@ -135,7 +136,7 @@ class FileUpload extends React.Component { } handleDrop(e) { - if (global.window.mm_config.EnableFileAttachments === 'false') { + if (!FileUtils.canUploadFiles()) { this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.')); return; } @@ -172,7 +173,7 @@ class FileUpload extends React.Component { }); let dragsterActions = {}; - if (global.window.mm_config.EnableFileAttachments === 'true') { + if (FileUtils.canUploadFiles()) { dragsterActions = { enter(dragsterEvent, e) { var files = e.originalEvent.dataTransfer; @@ -263,7 +264,7 @@ class FileUpload extends React.Component { // This looks redundant, but must be done this way due to // setState being an asynchronous call if (items && items.length > 0) { - if (global.window.mm_config.EnableFileAttachments === 'false') { + if (!FileUtils.canUploadFiles()) { this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.')); return; } @@ -326,7 +327,7 @@ class FileUpload extends React.Component { if (Utils.cmdOrCtrlPressed(e) && e.keyCode === Constants.KeyCodes.U) { e.preventDefault(); - if (global.window.mm_config.EnableFileAttachments === 'false') { + if (!FileUtils.canUploadFiles()) { this.props.onUploadError(Utils.localizeMessage('file_upload.disabled', 'File attachments are disabled.')); return; } @@ -377,7 +378,7 @@ class FileUpload extends React.Component { const uploadsRemaining = Constants.MAX_UPLOAD_FILES - this.props.getFileCount(channelId); let fileDiv; - if (global.window.mm_config.EnableFileAttachments === 'true') { + if (FileUtils.canUploadFiles()) { fileDiv = (