Skip to content

Commit

Permalink
feat(preview-error): Display file icon based on extension for errors (#…
Browse files Browse the repository at this point in the history
…1536)

* Remove restriction such that preview will fetch the icon based on the extension from box-ui-elements when there is a preview error. Will rely on the logic there to return a default icon when one does not exist for the extension.

See: https://github.com/box/box-ui-elements/blob/1850977829e4888139462a6f65794b1cffc52a08/src/components/preview/previewIcons.ts#L183
  • Loading branch information
patlm authored Oct 4, 2024
1 parent 0cdea26 commit d0b10cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib/viewers/error/PreviewErrorViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class PreviewErrorViewer extends BaseViewer {

const { displayMessage, details, message } = error;
const { file } = this.options;
const { extension } = file || {};
const iconExtension = extension === 'flv' || extension === 'tgz' || extension === 'zip' ? extension : undefined;
const { extension: iconExtension } = file || {};

// Display the default or file-specific error icon
this.errorIcon = new ErrorIcon({ containerEl: this.iconEl });
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/error/__tests__/PreviewErrorViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ describe('lib/viewers/error/PreviewErrorViewer', () => {
['zip', 'zip'],
['tgz', 'tgz'],
['flv', 'flv'],
['blah', undefined],
['pdf', 'pdf'],
['pptx', 'pptx'],
])('should set appropriate icon', (fileExtension, iconExtension) => {
const err = new PreviewError('some_code');
error.options.file.extension = fileExtension;
Expand Down

0 comments on commit d0b10cb

Please sign in to comment.