Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(doc): Show IE11 banner for office online exts #1420

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/viewers/doc/DocumentViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/viewers/doc/__tests__/DocumentViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/office/OfficeLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,7 +15,7 @@ const VIEWERS = [
NAME: 'Office',
CONSTRUCTOR: OfficeViewer,
REP: ORIGINAL_REP_NAME,
EXT: ['xlsx', 'xlsm', 'xlsb'],
EXT: OFFICE_ONLINE_EXTENSIONS,
},
];

Expand Down