mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
split admin and non-admin project studios endpoints
This commit is contained in:
parent
986c608136
commit
49df9a6386
2 changed files with 9 additions and 11 deletions
|
@ -763,15 +763,12 @@ module.exports.getRemixes = id => (dispatch => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports.getProjectStudios = (id, username, token) => (dispatch => {
|
module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => {
|
||||||
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING));
|
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING));
|
||||||
const apiOpts = {
|
api({
|
||||||
uri: `/users/${username}/projects/${id}/studios`
|
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`,
|
||||||
};
|
authentication: token
|
||||||
if (token) {
|
}, (err, body, res) => {
|
||||||
apiOpts.authentication = token;
|
|
||||||
}
|
|
||||||
api(apiOpts, (err, body, res) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
|
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
|
||||||
dispatch(module.exports.setError(err));
|
dispatch(module.exports.setError(err));
|
||||||
|
|
|
@ -159,9 +159,10 @@ class Preview extends React.Component {
|
||||||
if (typeof this.props.projectInfo.id === 'undefined') {
|
if (typeof this.props.projectInfo.id === 'undefined') {
|
||||||
this.initCounts(0, 0);
|
this.initCounts(0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
const token = this.props.user ? this.props.user.token : null;
|
||||||
this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves);
|
this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves);
|
||||||
this.props.getProjectStudios(this.props.projectInfo.id,
|
this.props.getProjectStudios(this.props.projectInfo.id,
|
||||||
this.props.authorUsername, this.props.user.token);
|
this.props.authorUsername, this.props.isAdmin, token);
|
||||||
if (this.props.projectInfo.remix.parent !== null) {
|
if (this.props.projectInfo.remix.parent !== null) {
|
||||||
this.props.getParentInfo(this.props.projectInfo.remix.parent);
|
this.props.getParentInfo(this.props.projectInfo.remix.parent);
|
||||||
}
|
}
|
||||||
|
@ -980,8 +981,8 @@ const mapDispatchToProps = dispatch => ({
|
||||||
getRemixes: id => {
|
getRemixes: id => {
|
||||||
dispatch(previewActions.getRemixes(id));
|
dispatch(previewActions.getRemixes(id));
|
||||||
},
|
},
|
||||||
getProjectStudios: (id, username, token) => {
|
getProjectStudios: (id, ownerUsername, isAdmin, token) => {
|
||||||
dispatch(previewActions.getProjectStudios(id, username, token));
|
dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token));
|
||||||
},
|
},
|
||||||
getCuratedStudios: (username, token) => {
|
getCuratedStudios: (username, token) => {
|
||||||
dispatch(previewActions.getCuratedStudios(username, token));
|
dispatch(previewActions.getCuratedStudios(username, token));
|
||||||
|
|
Loading…
Reference in a new issue