Skip to content

Commit

Permalink
feat(viewer): remove traces of boxdicom support (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
JChan106 authored Feb 17, 2022
1 parent 1edbfff commit 6c39352
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 86 deletions.
20 changes: 0 additions & 20 deletions src/lib/viewers/iframe/IFrameLoader.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import getProp from 'lodash/get';
import AssetLoader from '../AssetLoader';
import IFrameViewer from './IFrameViewer';
import { ORIGINAL_REP_NAME } from '../../constants';

// Order of the viewers matters. Prefer original before others. Go from specific to general.
const VIEWERS = [
{
NAME: 'IFrame',
CONSTRUCTOR: IFrameViewer,
REP: ORIGINAL_REP_NAME,
EXT: ['boxdicom'],
},
{
NAME: 'IFrame',
CONSTRUCTOR: IFrameViewer,
Expand All @@ -29,19 +22,6 @@ class IFrameLoader extends AssetLoader {
super();
this.viewers = VIEWERS;
}

/**
* @inheritdoc
*/
determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const disableDicom = getProp(viewerOptions, 'IFrame.disableDicom');
// Removes boxdicom as a supported extension when the disableDicom viewer option is enabled
if (disableDicom) {
this.viewers = this.viewers.filter(viewer => !viewer.EXT.includes('boxdicom'));
}

return super.determineViewer(file, disabledViewers);
}
}

export default new IFrameLoader();
4 changes: 1 addition & 3 deletions src/lib/viewers/iframe/IFrameViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IFrameViewer extends BaseViewer {
}

/**
* Loads a boxnote or boxdicom file
* Loads a boxnote
*
* @return {void}
*/
Expand All @@ -40,8 +40,6 @@ class IFrameViewer extends BaseViewer {
const sharedName = sharedLink.substr(sharedNameIndex + 3); // shared name starts after /s/
src = `${src}&s=${sharedName}`;
}
} else if (extension === 'boxdicom') {
src = `${appHost}/dicom_viewer/${file.id}`;
}

// Note that the load time for this will be negligible
Expand Down
22 changes: 11 additions & 11 deletions src/lib/viewers/iframe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ The iframe viewer embeds an iframe to show content rendered from an external sou

## Behavior

The iframe viewer is used for previews of Box Notes and Box DICOM files, and these previews currently only work from within the Box Web Application. Platform customers should use the [Box DICOM Viewer] (https://boxdicom.com/#viewer) to preview DICOM studies over the API.
The iframe viewer is used for previews of Box Notes, and these previews currently only work from within the Box Web Application.

Both Box Notes and Box DICOM have full-featured viewers within the main Box Web Application, but these full viewers are not initialized when users navigate from previews of other files that may be in the same directory as the Notes and DICOM files. In this situation, the iframe viewer embeds an view-only render of the Box Note or Box DICOM file.
Box Notes has a full-featured viewer within the main Box Web Application, but this full viewer is not initialized when users navigate from previews of other files that may be in the same directory as the Notes files. In this situation, the iframe viewer embeds an view-only render of the Box Note file.

## Supported File Extensions

`boxnote, boxdicom`
`boxnote`

## Events

The iframe viewer fires the following events

| Event Name | Explanation | Event Data |
| --- | --- | --- |
| destroy | The preview is intentionally destroyed ||
| load | The preview loads | 1. {string} **error** (optional): error message 2. {object} **file**: current file 3. {object} **metrics**: information from the logger 4. {object} **viewer**: current viewer |
| notification | A notification is displayed ||
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| Event Name | Explanation | Event Data |
| ------------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| destroy | The preview is intentionally destroyed | |
| load | The preview loads | 1. {string} **error** (optional): error message 2. {object} **file**: current file 3. {object} **metrics**: information from the logger 4. {object} **viewer**: current viewer |
| notification | A notification is displayed | |
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads | |
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
41 changes: 0 additions & 41 deletions src/lib/viewers/iframe/__tests__/IFrameLoader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,9 @@ import IFrameLoader from '../IFrameLoader';
import IFrameViewer from '../IFrameViewer';

describe('lib/viewers/iframe/IFrameLoader', () => {
const iframe = new IFrameViewer({
file: {
id: '123',
extension: 'boxnote',
representations: {
entries: [
{
representation: 'ORIGINAL',
},
],
},
},
});

test('should have the correct viewers', () => {
const iframeViewers = IFrameLoader.viewers;
expect(iframeViewers).toEqual([
{
NAME: 'IFrame',
CONSTRUCTOR: IFrameViewer,
REP: 'ORIGINAL',
EXT: ['boxdicom'],
},
{
NAME: 'IFrame',
CONSTRUCTOR: IFrameViewer,
Expand All @@ -33,25 +13,4 @@ describe('lib/viewers/iframe/IFrameLoader', () => {
},
]);
});

test.each`
disableDicom | fileType | viewerInstance
${false} | ${'boxdicom'} | ${IFrameLoader.viewers.find(v => v.EXT.includes('boxdicom'))}
${true} | ${'boxdicom'} | ${undefined}
${true} | ${'boxnote'} | ${IFrameLoader.viewers.find(v => v.EXT.includes('boxnote'))}
`(
'should return correct result depending on the disableDicom viewer option and file type',
({ disableDicom, fileType, viewerInstance }) => {
iframe.options.file.extension = fileType;

const viewerOptions = {
IFrame: {
disableDicom,
},
};
const viewer = IFrameLoader.determineViewer(iframe.options.file, [], viewerOptions);
expect(viewer).toEqual(viewerInstance);
expect(IFrameLoader.getViewers().some(v => v.EXT.includes('boxdicom'))).toEqual(!disableDicom);
},
);
});
11 changes: 0 additions & 11 deletions src/lib/viewers/iframe/__tests__/IFrameViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@ describe('lib/viewers/iframe/IFrameViewer', () => {
iframe.load();
});

test('should load a boxdicom and fire load event', done => {
iframe.options.file.extension = 'boxdicom';

iframe.on('load', () => {
expect(iframe.iframeEl.src).toEqual('https://app.box.com/dicom_viewer/123');
done();
});

iframe.load();
});

test('should invoke startLoadTimer()', () => {
const stub = jest.spyOn(iframe, 'startLoadTimer');
iframe.load();
Expand Down

0 comments on commit 6c39352

Please sign in to comment.