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

feat(viewer): Add support for disabling .boxdicom file type #1436

Merged
merged 5 commits into from
Nov 17, 2021

Conversation

JChan106
Copy link
Contributor

Removes preview support for boxdicom files. This is a prerequisite for modifying the default behavior to opening boxdicom files with Ambra.

@JChan106 JChan106 requested a review from a team as a code owner November 17, 2021 19:20
* @inheritdoc
*/
determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const isDicomFile = file.name === 'Dicom.boxdicom' || file.extension === 'boxdicom';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension check is probably sufficient here

*/
determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const isDicomFile = file.name === 'Dicom.boxdicom' || file.extension === 'boxdicom';
const openWithAmbraEnabled = getProp(viewerOptions, 'IFrame.openWithAmbra');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of openWithAmbra, maybe the option should be disableDicom focused because preview SDK knows nothing about an Ambra integration

determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const isDicomFile = file.name === 'Dicom.boxdicom' || file.extension === 'boxdicom';
const openWithAmbraEnabled = getProp(viewerOptions, 'IFrame.openWithAmbra');
// The IFrame viewer is disabled when the file is a Boxdicom file and Open_with_Ambra FF is enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't mention FF from other codebases here

@@ -1,5 +1,6 @@
import IFrameViewer from '../IFrameViewer';
import BaseViewer from '../../BaseViewer';
import IFrameLoader from '../IFrameLoader';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort the imports

expect(viewer).toBeUndefined();
});

test('should return a viewer if file is a boxnote and open_with_ambra FF is enabled', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could lump these together with a test.each https://jestjs.io/docs/api#1-testeachtablename-fn-timeout

@jstoffan
Copy link
Collaborator

@JChan106, we'll probably want to go with feat rather than chore for the commit message and PR title since this change includes new functionality.

@JChan106 JChan106 changed the title chore(viewer): Remove support for .boxdicom file type feat(viewer): Remove support for .boxdicom file type Nov 17, 2021
@jstoffan jstoffan self-requested a review November 17, 2021 21:57
@@ -1,3 +1,4 @@
import IFrameLoader from '../IFrameLoader';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these tests IFrameLoader-test.js, please?

},
};
const viewer = IFrameLoader.determineViewer(iframe.options.file, [], viewerOptions);
if (viewerDefined) {
Copy link
Collaborator

@jstoffan jstoffan Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically want to avoid having logic and conditions in our tests. We could do something like this, though:

test.each`
    disableDicom    | fileType        | viewerInstance
    ${false}        | ${'boxdicom'}   | ${IFrameViewer}
    ${true}         | ${'boxdicom'}   | ${undefined}
`

@jstoffan jstoffan self-requested a review November 17, 2021 22:02
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes to cancel the prior approval. Sorry for the confusion.

@JChan106 JChan106 requested a review from jstoffan November 17, 2021 22:54
jstoffan
jstoffan previously approved these changes Nov 17, 2021
@@ -18,4 +31,24 @@ describe('lib/viewers/iframe/IFrameLoader', () => {
EXT: ['boxnote', 'boxdicom'],
});
});

test.each([
// disableDicom, fileType, viewerInstance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, consider using the tagged template literal syntax to incorporate these variable names directly into the inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, my bad I didn't know that actual syntax. Will update.

},
},
});

afterEach(() => {
sandbox.verifyAndRestore();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't directly related to your change, but we should remove these when we edit a test file, if possible. It's not actually being used in any tests in this case, either.

ConradJChan
ConradJChan previously approved these changes Nov 17, 2021
Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of Remove support... in the PR title, it is Add support for disabling .boxdicom

@JChan106 JChan106 changed the title feat(viewer): Remove support for .boxdicom file type feat(viewer): Add support for disabling .boxdicom file type Nov 17, 2021
@JChan106 JChan106 dismissed stale reviews from ConradJChan and jstoffan via 314cbcd November 17, 2021 23:38
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for working through the feedback!

@JChan106 JChan106 merged commit 8b9a4a8 into box:master Nov 17, 2021
@JChan106 JChan106 deleted the remove-boxdicom-support-based-on-ff branch November 17, 2021 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants