Skip to content

Commit

Permalink
feat(office): Preview PDF rep if using internet explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan committed Aug 4, 2021
1 parent 9de12f4 commit 49f9697
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/i18n/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import {
API_HOST,
APP_HOST,
BROWSERS,
CLASS_NAVIGATION_VISIBILITY,
ERROR_CODE_403_FORBIDDEN_BY_POLICY,
PERMISSION_PREVIEW,
Expand Down Expand Up @@ -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');
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/lib/viewers/doc/DocLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions src/lib/viewers/doc/OfficeExcelViewer.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 49f9697

Please sign in to comment.