From 49f9697a4a1fcffb806db2306422eab1350d7744 Mon Sep 17 00:00:00 2001 From: Conrad Chan Date: Wed, 4 Aug 2021 16:38:15 -0700 Subject: [PATCH] feat(office): Preview PDF rep if using internet explorer --- src/i18n/en-US.properties | 2 ++ src/lib/Preview.js | 16 ++++++++++++++++ src/lib/viewers/doc/DocLoader.js | 7 +++++++ src/lib/viewers/doc/OfficeExcelViewer.js | 14 ++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 src/lib/viewers/doc/OfficeExcelViewer.js diff --git a/src/i18n/en-US.properties b/src/i18n/en-US.properties index a25a2fad54..38dc4e7d99 100644 --- a/src/i18n/en-US.properties +++ b/src/i18n/en-US.properties @@ -88,6 +88,8 @@ error_bad_file=We’re sorry the preview didn’t load. This file could not be c error_not_downloadable=Oops! It looks like something is wrong with this file. We apologize for the inconvenience and recommend that you upload a new version of this file or roll back to a previous version. Please contact us for more details. # Preview error message shown when flash is not enabled on their browser error_flash_not_enabled=We’re sorry, the preview didn’t load because Flash is not enabled on your browser. If possible, please enable Flash and refresh the page. +# Preview error message shown when loading what would be an Office Excel Online file extension in Internet Explorer +error_internet_explorer_office_online=Microsoft 365 apps and services no longer support Internet Explorer 11, therefore, Box users may have a degraded experience. # Archive Preview # Label for filename column name diff --git a/src/lib/Preview.js b/src/lib/Preview.js index a71b71da79..ceec9a93f6 100644 --- a/src/lib/Preview.js +++ b/src/lib/Preview.js @@ -43,6 +43,7 @@ import { import { API_HOST, APP_HOST, + BROWSERS, CLASS_NAVIGATION_VISIBILITY, ERROR_CODE_403_FORBIDDEN_BY_POLICY, PERMISSION_PREVIEW, @@ -1009,6 +1010,21 @@ class Preview extends EventEmitter { this.enableViewers(viewerName); } }); + + // Disable office online if browser is IE + this.forceDisableOfficeOnline(); + } + + /** + * Adds Office viewer to the disabled viewer list if browser is IE + * @returns {void} + */ + forceDisableOfficeOnline() { + const isIE = this.browserInfo.name === BROWSERS.INTERNET_EXPLORER; + + if (isIE) { + this.disableViewers('Office'); + } } /** diff --git a/src/lib/viewers/doc/DocLoader.js b/src/lib/viewers/doc/DocLoader.js index e02740e128..3e61e245ce 100644 --- a/src/lib/viewers/doc/DocLoader.js +++ b/src/lib/viewers/doc/DocLoader.js @@ -2,6 +2,7 @@ import AssetLoader from '../AssetLoader'; import { getRepresentation } from '../../file'; import AutoCADViewer from './AutoCADViewer'; import DocumentViewer from './DocumentViewer'; +import OfficeExcelViewer from './OfficeExcelViewer'; import PresentationViewer from './PresentationViewer'; import SinglePageViewer from './SinglePageViewer'; import RepStatus from '../../RepStatus'; @@ -18,6 +19,12 @@ const VIEWERS = [ REP: 'pdf', EXT: ['gslide', 'gslides', 'odp', 'ppt', 'pptx', 'key'], }, + { + NAME: 'OfficeExcel', + CONSTRUCTOR: OfficeExcelViewer, + REP: 'pdf', + EXT: ['xlsx', 'xlsm', 'xlsb'], + }, { NAME: 'AutoCAD', CONSTRUCTOR: AutoCADViewer, diff --git a/src/lib/viewers/doc/OfficeExcelViewer.js b/src/lib/viewers/doc/OfficeExcelViewer.js new file mode 100644 index 0000000000..78dc12ae86 --- /dev/null +++ b/src/lib/viewers/doc/OfficeExcelViewer.js @@ -0,0 +1,14 @@ +import DocumentViewer from './DocumentViewer'; + +class OfficeExcelViewer extends DocumentViewer { + /** + * @inheritdoc + */ + load() { + super.load(); + + this.options.ui.showNotification(__('error_internet_explorer_office_online'), null, true); + } +} + +export default OfficeExcelViewer;