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): use unsupported file type error message for .boxdicom #1437

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

JChan106
Copy link
Contributor

Uses the unsupported file type error message instead of the account error message for Box Dicom files.

@JChan106 JChan106 requested a review from a team as a code owner November 19, 2021 00:13
@@ -33,6 +33,12 @@ class IFrameLoader extends AssetLoader {
// The IFrame viewer is disabled when the file is a Boxdicom file and the disableDicom viewer option is enabled
if (disableDicom && isDicomFile) {
disabledViewers.push('IFrame');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need this logic now that the extension is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I don't think we need it anymore, will remove.

@@ -33,6 +33,12 @@ class IFrameLoader extends AssetLoader {
// The IFrame viewer is disabled when the file is a Boxdicom file and the disableDicom viewer option is enabled
if (disableDicom && isDicomFile) {
disabledViewers.push('IFrame');

// Removes boxdicom as a supported extension
const iframeViewer = this.viewers[0].EXT;
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 simplify things a bit by breaking out the viewers into multiple entries? Maybe something like:

const VIEWERS = [
    {
        NAME: 'IFrame',
        CONSTRUCTOR: IFrameViewer,
        REP: ORIGINAL_REP_NAME,
        EXT: ['boxdicom'],
    },
    {
        NAME: 'IFrame',
        CONSTRUCTOR: IFrameViewer,
        REP: ORIGINAL_REP_NAME,
        EXT: ['boxnote'],
    },
];

...

if (disableDicom && isDicomFile) {
    this.viewers = this.viewers.filter(viewer => !viewer.EXT.includes('boxdicom'));
}

jstoffan
jstoffan previously approved these changes Nov 19, 2021
@@ -43,6 +51,7 @@ describe('lib/viewers/iframe/IFrameLoader', () => {
};
const viewer = IFrameLoader.determineViewer(iframe.options.file, [], viewerOptions);
expect(viewer).toEqual(viewerInstance);
expect(IFrameLoader.getViewers().some(v => v.EXT.includes('boxdicom'))).toEqual(!disableDicom);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this assertion if we already have the one above it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, the assertion checks if the list of viewers is correct based on the disableDicom viewer option. While the above assertion checks if the viewer instance is correct.

@@ -30,9 +36,9 @@ class IFrameLoader extends AssetLoader {
determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const isDicomFile = file.extension === 'boxdicom';
const disableDicom = getProp(viewerOptions, 'IFrame.disableDicom');
// The IFrame viewer is disabled when the file is a Boxdicom file and the disableDicom viewer option is enabled
// Removes boxdicom as a supported extension when the file is a Boxdicom file and the disableDicom viewer option 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.

Do we even need to check if isDicomFile is true anymore? If disableDicom option is passed in, would it work if we just remove it from the this.viewers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right, it doesn't really matter about the current file, we should just remove the dicom viewer from the supported viewers if the disableDicom is true.

Copy link
Contributor

Choose a reason for hiding this comment

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

May want to update the comment as well to be consistent with the code

ConradJChan
ConradJChan previously approved these changes Nov 19, 2021
@@ -30,9 +36,9 @@ class IFrameLoader extends AssetLoader {
determineViewer(file, disabledViewers = [], viewerOptions = {}) {
const isDicomFile = file.extension === 'boxdicom';
const disableDicom = getProp(viewerOptions, 'IFrame.disableDicom');
// The IFrame viewer is disabled when the file is a Boxdicom file and the disableDicom viewer option is enabled
// Removes boxdicom as a supported extension when the file is a Boxdicom file and the disableDicom viewer option 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.

May want to update the comment as well to be consistent with the code

@JChan106 JChan106 merged commit 7af11c4 into box:master Nov 19, 2021
@JChan106 JChan106 deleted the unsupported-file-error-boxdicom branch November 19, 2021 21:12
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