split admin and non-admin project studios endpoints

This commit is contained in:
Ben Wheeler 2019-03-22 16:47:41 -04:00
parent 986c608136
commit 49df9a6386
2 changed files with 9 additions and 11 deletions

View file

@ -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));
const apiOpts = {
uri: `/users/${username}/projects/${id}/studios`
};
if (token) {
apiOpts.authentication = token;
}
api(apiOpts, (err, body, res) => {
api({
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`,
authentication: token
}, (err, body, res) => {
if (err) {
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
dispatch(module.exports.setError(err));

View file

@ -159,9 +159,10 @@ class Preview extends React.Component {
if (typeof this.props.projectInfo.id === 'undefined') {
this.initCounts(0, 0);
} else {
const token = this.props.user ? this.props.user.token : null;
this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves);
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) {
this.props.getParentInfo(this.props.projectInfo.remix.parent);
}
@ -980,8 +981,8 @@ const mapDispatchToProps = dispatch => ({
getRemixes: id => {
dispatch(previewActions.getRemixes(id));
},
getProjectStudios: (id, username, token) => {
dispatch(previewActions.getProjectStudios(id, username, token));
getProjectStudios: (id, ownerUsername, isAdmin, token) => {
dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token));
},
getCuratedStudios: (username, token) => {
dispatch(previewActions.getCuratedStudios(username, token));