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_attachment.jsx | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'webapp/components/file_attachment.jsx') diff --git a/webapp/components/file_attachment.jsx b/webapp/components/file_attachment.jsx index 9459c44ef..3d7f936c8 100644 --- a/webapp/components/file_attachment.jsx +++ b/webapp/components/file_attachment.jsx @@ -1,15 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import Constants from 'utils/constants.jsx'; -import {getFileUrl, getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils'; -import * as Utils from 'utils/utils.jsx'; - +import PropTypes from 'prop-types'; +import React from 'react'; import {Tooltip, OverlayTrigger} from 'react-bootstrap'; -import PropTypes from 'prop-types'; +import Constants from 'utils/constants.jsx'; +import * as FileUtils from 'utils/file_utils'; +import * as Utils from 'utils/utils.jsx'; -import React from 'react'; +import {getFileUrl, getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils'; export default class FileAttachment extends React.Component { constructor(props) { @@ -101,6 +101,8 @@ export default class FileAttachment extends React.Component { trimmedFilename = fileName; } + const canDownloadFiles = FileUtils.canDownloadFiles(); + let filenameOverlay; if (this.props.compactDisplay) { filenameOverlay = ( @@ -124,7 +126,7 @@ export default class FileAttachment extends React.Component { ); - } else { + } else if (canDownloadFiles) { filenameOverlay = ( ); + } else { + filenameOverlay = ( + + {trimmedFilename} + + ); + } + + let downloadButton = null; + if (canDownloadFiles) { + downloadButton = ( + + + + ); } return ( @@ -157,15 +180,7 @@ export default class FileAttachment extends React.Component {
{filenameOverlay}
- - - + {downloadButton} {fileInfo.extension.toUpperCase()} {Utils.fileSizeToString(fileInfo.size)}
-- cgit v1.2.3-1-g7c22