mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Add project thumbnail update action
This commit is contained in:
parent
42f5674a74
commit
172915f9d9
2 changed files with 26 additions and 0 deletions
|
@ -863,3 +863,24 @@ module.exports.reportProject = (id, jsonData, token) => (dispatch => {
|
||||||
dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHED));
|
dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHED));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module.exports.updateProjectThumbnail = (id, blob) => (dispatch => {
|
||||||
|
dispatch(module.exports.setFetchStatus('project-thumbnail', module.exports.Status.FETCHING));
|
||||||
|
api({
|
||||||
|
uri: `/internalapi/project/thumbnail/${id}/set/`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'image/png'
|
||||||
|
},
|
||||||
|
withCredentials: true,
|
||||||
|
useCsrf: true,
|
||||||
|
body: blob,
|
||||||
|
host: '' // Not handled by the API, use existing infrastructure
|
||||||
|
}, (err, body, res) => {
|
||||||
|
if (err || res.statusCode !== 200) {
|
||||||
|
dispatch(module.exports.setFetchStatus('project-thumbnail', module.exports.Status.ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch(module.exports.setFetchStatus('project-thumbnail', module.exports.Status.FETCHED));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -519,6 +519,7 @@ class Preview extends React.Component {
|
||||||
onShare={this.handleShare}
|
onShare={this.handleShare}
|
||||||
onToggleLoginOpen={this.props.handleToggleLoginOpen}
|
onToggleLoginOpen={this.props.handleToggleLoginOpen}
|
||||||
onUpdateProjectId={this.handleUpdateProjectId}
|
onUpdateProjectId={this.handleUpdateProjectId}
|
||||||
|
onUpdateProjectThumbnail={this.props.handleUpdateProjectThumbnail}
|
||||||
onUpdateProjectTitle={this.handleUpdateProjectTitle}
|
onUpdateProjectTitle={this.handleUpdateProjectTitle}
|
||||||
/>
|
/>
|
||||||
<Registration />
|
<Registration />
|
||||||
|
@ -569,6 +570,7 @@ Preview.propTypes = {
|
||||||
handleRestoreComment: PropTypes.func,
|
handleRestoreComment: PropTypes.func,
|
||||||
handleSeeAllComments: PropTypes.func,
|
handleSeeAllComments: PropTypes.func,
|
||||||
handleToggleLoginOpen: PropTypes.func,
|
handleToggleLoginOpen: PropTypes.func,
|
||||||
|
handleUpdateProjectThumbnail: PropTypes.func,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
isEditable: PropTypes.bool,
|
isEditable: PropTypes.bool,
|
||||||
isLoggedIn: PropTypes.bool,
|
isLoggedIn: PropTypes.bool,
|
||||||
|
@ -717,6 +719,9 @@ const mapDispatchToProps = dispatch => ({
|
||||||
dispatch(previewActions.resetComments());
|
dispatch(previewActions.resetComments());
|
||||||
dispatch(previewActions.getTopLevelComments(id, 0, isAdmin, token));
|
dispatch(previewActions.getTopLevelComments(id, 0, isAdmin, token));
|
||||||
},
|
},
|
||||||
|
handleUpdateProjectThumbnail: (id, blob) => {
|
||||||
|
dispatch(previewActions.updateProjectThumbnail(id, blob));
|
||||||
|
},
|
||||||
getOriginalInfo: id => {
|
getOriginalInfo: id => {
|
||||||
dispatch(previewActions.getOriginalInfo(id));
|
dispatch(previewActions.getOriginalInfo(id));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue