diff --git a/src/lib/extensions.js b/src/lib/extensions.js index 75961e8dc..e6556dc6b 100644 --- a/src/lib/extensions.js +++ b/src/lib/extensions.js @@ -56,6 +56,7 @@ export const CODE_EXTENSIONS = [ export const EXCEL_EXTENSIONS = ['xls', 'xlsm', 'xlsx']; export const EXCLUDED_EXTENSIONS = EXCEL_EXTENSIONS.concat(['numbers']); export const INDESIGN_EXTENSIONS = ['indb', 'indd', 'indl', 'indt', 'idml', 'inx', 'pmd']; +export const OFFICE_ONLINE_EXTENSIONS = ['xlsx', 'xlsm', 'xlsb']; export const DOCUMENT_EXTENSIONS = CODE_EXTENSIONS.concat(NON_CODE_EXTENSIONS) .concat(HTML_EXTENSIONS) diff --git a/src/lib/viewers/doc/DocumentViewer.js b/src/lib/viewers/doc/DocumentViewer.js index 503fa9181..02a0b1edb 100644 --- a/src/lib/viewers/doc/DocumentViewer.js +++ b/src/lib/viewers/doc/DocumentViewer.js @@ -2,7 +2,7 @@ import Browser from '../../Browser'; import DocBaseViewer from './DocBaseViewer'; import DocPreloader from './DocPreloader'; import fullscreen from '../../Fullscreen'; -import { EXCEL_EXTENSIONS } from '../../extensions'; +import { OFFICE_ONLINE_EXTENSIONS } from '../../extensions'; import './Document.scss'; class DocumentViewer extends DocBaseViewer { @@ -42,9 +42,9 @@ class DocumentViewer extends DocBaseViewer { super.load(); const { extension } = this.options.file; - const isExcelExtension = EXCEL_EXTENSIONS.includes(extension); + const isOfficeOnlineExtension = OFFICE_ONLINE_EXTENSIONS.includes(extension); - if (isExcelExtension && Browser.isIE()) { + if (isOfficeOnlineExtension && Browser.isIE()) { this.options.ui.showNotification(__('error_internet_explorer_office_online'), null, true); } } diff --git a/src/lib/viewers/doc/__tests__/DocumentViewer-test.js b/src/lib/viewers/doc/__tests__/DocumentViewer-test.js index b82a31c0e..550707e6c 100644 --- a/src/lib/viewers/doc/__tests__/DocumentViewer-test.js +++ b/src/lib/viewers/doc/__tests__/DocumentViewer-test.js @@ -6,6 +6,7 @@ import DocBaseViewer from '../DocBaseViewer'; import BaseViewer from '../../BaseViewer'; import DocPreloader from '../DocPreloader'; import fullscreen from '../../../Fullscreen'; +import { OFFICE_ONLINE_EXTENSIONS } from '../../../extensions'; let containerEl; let doc; @@ -107,7 +108,7 @@ describe('lib/viewers/doc/DocumentViewer', () => { Object.defineProperty(DocBaseViewer.prototype, 'load', { value: docBaseLoadFunc }); }); - test.each(['xls', 'xlsm', 'xlsx'])( + test.each(OFFICE_ONLINE_EXTENSIONS)( 'should show notification if file has excel extension %s and is internet explorer', extension => { const showNotification = jest.fn(); @@ -121,7 +122,7 @@ describe('lib/viewers/doc/DocumentViewer', () => { }, ); - test.each(['xls', 'xlsm', 'xlsx'])( + test.each(OFFICE_ONLINE_EXTENSIONS)( 'should not show notification if file has excel extension %s but is not internet explorer', extension => { const showNotification = jest.fn(); diff --git a/src/lib/viewers/office/OfficeLoader.js b/src/lib/viewers/office/OfficeLoader.js index 93dd3dc83..4b186225b 100644 --- a/src/lib/viewers/office/OfficeLoader.js +++ b/src/lib/viewers/office/OfficeLoader.js @@ -3,6 +3,7 @@ import AssetLoader from '../AssetLoader'; import Browser from '../../Browser'; import OfficeViewer from './OfficeViewer'; import { checkPermission } from '../../file'; +import { OFFICE_ONLINE_EXTENSIONS } from '../../extensions'; import { ORIGINAL_REP_NAME, PERMISSION_DOWNLOAD } from '../../constants'; const FIVE_MB = 5242880; @@ -14,7 +15,7 @@ const VIEWERS = [ NAME: 'Office', CONSTRUCTOR: OfficeViewer, REP: ORIGINAL_REP_NAME, - EXT: ['xlsx', 'xlsm', 'xlsb'], + EXT: OFFICE_ONLINE_EXTENSIONS, }, ];