Merge pull request #2789 from paulkaplan/report-thumbnailing

Get thumbnails from the project for reporting
This commit is contained in:
Paul Kaplan 2019-02-20 13:39:49 -05:00 committed by GitHub
commit 656ab3ce3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View file

@ -954,9 +954,8 @@ module.exports.shareProject = (projectId, token) => (dispatch => {
module.exports.reportProject = (id, jsonData, token) => (dispatch => {
dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHING));
// scratchr2 will fail if no thumbnail base64 string provided. We don't yet have
// a way to get the actual project thumbnail in www/gui, so for now just submit
// a minimal base64 png string.
// scratchr2 will fail if no thumbnail base64 string provided. If there is not one
// included for any reason, include this minimal blank image.
defaults(jsonData, {
thumbnail: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC' +
'0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII='

View file

@ -106,6 +106,7 @@ const PreviewPresentation = ({
onRestoreComment,
onSeeAllComments,
onSeeInside,
onSetProjectThumbnailer,
onShare,
onToggleComments,
onToggleStudio,
@ -341,6 +342,7 @@ const PreviewPresentation = ({
onGreenFlag={onGreenFlag}
onProjectLoaded={onProjectLoaded}
onRemixing={onRemixing}
onSetProjectThumbnailer={onSetProjectThumbnailer}
onUpdateProjectId={onUpdateProjectId}
onUpdateProjectThumbnail={onUpdateProjectThumbnail}
/>
@ -709,6 +711,7 @@ PreviewPresentation.propTypes = {
onRestoreComment: PropTypes.func,
onSeeAllComments: PropTypes.func,
onSeeInside: PropTypes.func,
onSetProjectThumbnailer: PropTypes.func,
onShare: PropTypes.func,
onToggleComments: PropTypes.func,
onToggleStudio: PropTypes.func,

View file

@ -79,6 +79,7 @@ class Preview extends React.Component {
'handleRemix',
'handleSeeAllComments',
'handleSeeInside',
'handleSetProjectThumbnailer',
'handleShare',
'handleUpdateProjectId',
'handleUpdateProjectTitle',
@ -381,7 +382,18 @@ class Preview extends React.Component {
this.setState({addToStudioOpen: false});
}
handleReportSubmit (formData) {
this.props.reportProject(this.state.projectId, formData, this.props.user.token);
const submit = data => this.props.reportProject(this.state.projectId, data, this.props.user.token);
if (this.getProjectThumbnail) {
this.getProjectThumbnail(thumbnail => {
const data = Object.assign({}, formData, {thumbnail});
submit(data);
});
} else {
submit(formData);
}
}
handleSetProjectThumbnailer (fn) {
this.getProjectThumbnail = fn;
}
handleGreenFlag () {
if (!this.state.greenFlagRecorded) {
@ -690,6 +702,7 @@ class Preview extends React.Component {
onRestoreComment={this.handleRestoreComment}
onSeeAllComments={this.handleSeeAllComments}
onSeeInside={this.handleSeeInside}
onSetProjectThumbnailer={this.handleSetProjectThumbnailer}
onShare={this.handleShare}
onToggleComments={this.handleToggleComments}
onToggleStudio={this.handleToggleStudio}