diff --git a/app/components/file_attachment_list/file_attachment.js b/app/components/file_attachment_list/file_attachment.js index 4fe3e5b8c..271eb65b7 100644 --- a/app/components/file_attachment_list/file_attachment.js +++ b/app/components/file_attachment_list/file_attachment.js @@ -20,6 +20,7 @@ import FileAttachmentImage from './file_attachment_image'; export default class FileAttachment extends PureComponent { static propTypes = { + canDownloadFiles: PropTypes.bool.isRequired, deviceWidth: PropTypes.number.isRequired, file: PropTypes.object.isRequired, index: PropTypes.number.isRequired, @@ -80,6 +81,7 @@ export default class FileAttachment extends PureComponent { render() { const { + canDownloadFiles, deviceWidth, file, onInfoPress, @@ -103,6 +105,7 @@ export default class FileAttachment extends PureComponent { } else if (isDocument(data)) { fileAttachmentComponent = ( { - const {file} = this.props; + const {canDownloadFiles, file} = this.props; const {downloading, progress} = this.state; + if (!canDownloadFiles) { + this.showDownloadDisabledAlert(); + return; + } + if (downloading && progress < 100) { this.cancelDownload(); } else if (downloading) { @@ -290,6 +296,27 @@ export default class FileAttachmentDocument extends PureComponent { ); }; + showDownloadDisabledAlert = () => { + const {intl} = this.context; + + Alert.alert( + intl.formatMessage({ + id: 'mobile.downloader.disabled_title', + defaultMessage: 'Download disabled', + }), + intl.formatMessage({ + id: 'mobile.downloader.disabled_description', + defaultMessage: 'File downloads are disabled on this server. Please contact your System Admin for more details.\n', + }), + [{ + text: intl.formatMessage({ + id: 'mobile.server_upgrade.button', + defaultMessage: 'OK', + }), + }] + ); + }; + showDownloadFailedAlert = () => { const {intl} = this.context; diff --git a/app/components/file_attachment_list/file_attachment_list.js b/app/components/file_attachment_list/file_attachment_list.js index b2be2e4ed..6316096cf 100644 --- a/app/components/file_attachment_list/file_attachment_list.js +++ b/app/components/file_attachment_list/file_attachment_list.js @@ -25,6 +25,7 @@ import FileAttachment from './file_attachment'; export default class FileAttachmentList extends Component { static propTypes = { actions: PropTypes.object.isRequired, + canDownloadFiles: PropTypes.bool.isRequired, deviceHeight: PropTypes.number.isRequired, deviceWidth: PropTypes.number.isRequired, fileIds: PropTypes.array.isRequired, @@ -144,12 +145,13 @@ export default class FileAttachmentList extends Component { }; renderItems = () => { - const {deviceWidth, fileIds, files, navigator} = this.props; + const {canDownloadFiles, deviceWidth, fileIds, files, navigator} = this.props; if (!files.length && fileIds.length > 0) { return fileIds.map((id, idx) => (