Skip to content

Commit

Permalink
Add thumbnails for application/json subjects (#7019)
Browse files Browse the repository at this point in the history
Show a small `FileViewer` as the thumbnail for data subjects, with the MIME type `application/json`.
  • Loading branch information
eatyourgreens authored Jan 17, 2024
1 parent 44da424 commit 00e35dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/components/file-viewer/canvas-viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ CanvasViewer.propTypes = {
}),
onLoad: PropTypes.func
};
const DEFAULT_HANDLER = () => true;
/* eslint-enable react/forbid-prop-types */
CanvasViewer.defaultProps = {
onLoad: DEFAULT_HANDLER,
viewBoxDimensions: { height: 512, width: 512, x: 0, y: 0 }
};

Expand Down
14 changes: 12 additions & 2 deletions app/components/thumbnail.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import PropTypes from 'prop-types';
import React from 'react';

import FileViewer from './file-viewer'

export default class Thumbnail extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -61,11 +63,19 @@ export default class Thumbnail extends React.Component {
}

if (this.props.type === 'application') {
return null;
const fakeSubject = {
locations: [{ 'application/json': this.props.src }],
metadata: {}
};
return (
<div style={style}>
<FileViewer type='application' format='json' src={this.props.src} subject={fakeSubject} />
</div>
);
}

return (
<div style={style}>
<div style={style}>
<img alt="" {...this.props} src={src} {...dimensions} onError={this.handleError} />
</div>
);
Expand Down

0 comments on commit 00e35dc

Please sign in to comment.