Commit ce8e2703 authored by Karishma Chadha's avatar Karishma Chadha

Set up state, tracking the number of managers the limits used to display info...

Set up state, tracking the number of managers the limits used to display info to the user. Handle new error response when trying to promote a curator.
parent f495fbc0
......@@ -12,6 +12,9 @@ const Status = keyMirror({
ERROR: null
});
const STUDIO_MANAGER_LIMIT = 40;
const STUDIO_MANAGER_THRESHOLD = 30;
const getInitialState = () => ({
infoStatus: Status.FETCHING,
title: '',
......@@ -20,6 +23,7 @@ const getInitialState = () => ({
commentsAllowed: false,
image: '',
followers: 0,
managers: 0,
owner: null,
// BEWARE: classroomId is only loaded if the user is an educator
......@@ -98,6 +102,9 @@ const selectStudioLastUpdated = state => state.studio.updated;
const selectStudioLoadFailed = state => state.studio.infoStatus === Status.ERROR;
const selectStudioCommentCount = state => state.studio.commentCount;
const selectStudioFollowerCount = state => state.studio.followers;
const selectStudioManagerCount = state => state.studio.managers;
const selectStudioHasReachedManagerThreshold = state => state.studio.managers >= STUDIO_MANAGER_THRESHOLD;
const selectStudioHasReachedManagerLimit = state => state.studio.managers >= STUDIO_MANAGER_LIMIT;
const selectStudioProjectCount = state => state.studio.projectCount;
const selectIsFetchingInfo = state => state.studio.infoStatus === Status.FETCHING;
const selectIsFollowing = state => state.studio.following;
......@@ -121,6 +128,7 @@ const getInfo = () => ((dispatch, getState) => {
updated: new Date(body.history.modified),
commentCount: body.stats.comments,
followers: body.stats.followers,
managers: body.stats.managers,
projectCount: body.stats.projects,
owner: body.owner
}));
......@@ -169,6 +177,10 @@ module.exports = {
setInfo,
setRoles,
// Constants
STUDIO_MANAGER_LIMIT,
STUDIO_MANAGER_THRESHOLD,
// Selectors
selectStudioId,
selectStudioTitle,
......@@ -180,6 +192,9 @@ module.exports = {
selectStudioLoadFailed,
selectStudioCommentCount,
selectStudioFollowerCount,
selectStudioManagerCount,
selectStudioHasReachedManagerThreshold,
selectStudioHasReachedManagerLimit,
selectStudioProjectCount,
selectIsFetchingInfo,
selectIsFetchingRoles,
......
......@@ -11,11 +11,15 @@ const Errors = keyMirror({
PERMISSION: null,
DUPLICATE: null,
UNKNOWN_USERNAME: null,
RATE_LIMIT: null
RATE_LIMIT: null,
MANAGER_LIMIT: null
});
const normalizeError = (err, body, res) => {
if (err) return Errors.NETWORK;
if (res.statusCode === 400 && body.message === 'too many owners') {
return Errors.MANAGER_LIMIT;
}
if (res.statusCode === 401 || res.statusCode === 403) return Errors.PERMISSION;
if (res.statusCode === 404) return Errors.UNKNOWN_USERNAME;
if (res.statusCode === 429) return Errors.RATE_LIMIT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment