mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-28 01:56:00 -05:00
Display backend mute errors on studio edit
This commit is contained in:
parent
68460611d8
commit
91d66cd20b
12 changed files with 23 additions and 12 deletions
|
@ -21,7 +21,8 @@ const Errors = keyMirror({
|
|||
THUMBNAIL_INVALID: null,
|
||||
TEXT_TOO_LONG: null,
|
||||
REQUIRED_FIELD: null,
|
||||
UNHANDLED: null
|
||||
UNHANDLED: null,
|
||||
USER_MUTED: null
|
||||
});
|
||||
|
||||
const MAX_IMAGE_BYTES = 524288;
|
||||
|
@ -104,6 +105,7 @@ const selectCommentsAllowedMutationError = state => state.studioMutations.mutati
|
|||
*/
|
||||
const normalizeError = (err, body, res) => {
|
||||
if (err) return Errors.NETWORK;
|
||||
if (res.statusCode === 403 && body.mute_status) return Errors.USER_MUTED;
|
||||
if (res.statusCode === 401 || res.statusCode === 403) return Errors.PERMISSION;
|
||||
if (res.statusCode !== 200) return Errors.SERVER;
|
||||
try {
|
||||
|
|
|
@ -97,10 +97,11 @@
|
|||
"studio.reportThanksForLettingUsKnow": "Thanks for letting us know!",
|
||||
"studio.reportYourFeedback": "Your feedback will help us make Scratch better.",
|
||||
|
||||
"studios.mutedCurators": "You will be able to invite curators and add managers again {inDuration}.",
|
||||
"studios.mutedProjects": "You will be able to add and remove projects again {inDuration}.",
|
||||
"studios.mutedEdit": "You will be able to edit studios again {inDuration}.",
|
||||
"studios.mutedPaused": "Your account has been paused from using studios until then.",
|
||||
"studio.mutedCurators": "You will be able to invite curators and add managers again {inDuration}.",
|
||||
"studio.mutedProjects": "You will be able to add and remove projects again {inDuration}.",
|
||||
"studio.mutedEdit": "You will be able to edit studios again {inDuration}.",
|
||||
"studio.mutedPaused": "Your account has been paused from using studios until then.",
|
||||
"studio.mutedError": "Your account has been paused from using studios. Refresh for more information.",
|
||||
|
||||
"studio.alertProjectAdded": "\"{title}\" added to studio",
|
||||
"studio.alertProjectAlreadyAdded": "That project is already in this studio",
|
||||
|
|
|
@ -10,12 +10,14 @@ const Errors = keyMirror({
|
|||
SERVER: null,
|
||||
PERMISSION: null,
|
||||
DUPLICATE: null,
|
||||
USER_MUTED: null,
|
||||
UNKNOWN_USERNAME: null,
|
||||
RATE_LIMIT: null
|
||||
});
|
||||
|
||||
const normalizeError = (err, body, res) => {
|
||||
if (err) return Errors.NETWORK;
|
||||
if (res.statusCode === 403 && body.mute_status) return Errors.USER_MUTED;
|
||||
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;
|
||||
|
|
|
@ -12,11 +12,13 @@ const Errors = keyMirror({
|
|||
PERMISSION: null,
|
||||
UNKNOWN_PROJECT: null,
|
||||
RATE_LIMIT: null,
|
||||
DUPLICATE: null
|
||||
DUPLICATE: null,
|
||||
USER_MUTED: null
|
||||
});
|
||||
|
||||
const normalizeError = (err, body, res) => {
|
||||
if (err) return Errors.NETWORK;
|
||||
if (res.statusCode === 403 && body.mute_status) return Errors.USER_MUTED;
|
||||
if (res.statusCode === 401 || res.statusCode === 403) return Errors.PERMISSION;
|
||||
if (res.statusCode === 404) return Errors.UNKNOWN_PROJECT;
|
||||
if (res.statusCode === 409) return Errors.DUPLICATE;
|
||||
|
|
|
@ -16,6 +16,7 @@ const errorToMessageId = error => {
|
|||
case Errors.PERMISSION: return 'studio.curatorErrors.generic';
|
||||
case Errors.DUPLICATE: return 'studio.curatorErrors.alreadyCurator';
|
||||
case Errors.UNKNOWN_USERNAME: return 'studio.curatorErrors.unknownUsername';
|
||||
case Errors.USER_MUTED: return 'studio.mutedError';
|
||||
case Errors.RATE_LIMIT: return 'studio.curatorErrors.tooFast';
|
||||
default: return 'studio.curatorErrors.generic';
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ const errorToMessageId = error => {
|
|||
case Errors.INAPPROPRIATE: return 'studio.updateErrors.inappropriate';
|
||||
case Errors.TEXT_TOO_LONG: return 'studio.updateErrors.textTooLong';
|
||||
case Errors.REQUIRED_FIELD: return 'studio.updateErrors.requiredField';
|
||||
case Errors.USER_MUTED: return 'studio.mutedError';
|
||||
default: return 'studio.updateErrors.generic';
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@ const errorToMessageId = error => {
|
|||
switch (error) {
|
||||
case Errors.THUMBNAIL_INVALID: return 'studio.updateErrors.thumbnailInvalid';
|
||||
case Errors.THUMBNAIL_TOO_LARGE: return 'studio.updateErrors.thumbnailTooLarge';
|
||||
case Errors.USER_MUTED: return 'studio.mutedError';
|
||||
default: return 'studio.updateErrors.generic';
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ const StudioMuteEditMessage = ({
|
|||
<ValidationMessage
|
||||
mode="info"
|
||||
message={<FormattedMessage
|
||||
id="studios.mutedEdit"
|
||||
id="studio.mutedEdit"
|
||||
values={{
|
||||
inDuration: formatRelativeTime(muteExpiresAtMs, window._locale)
|
||||
}}
|
||||
|
|
|
@ -18,6 +18,7 @@ const errorToMessageId = error => {
|
|||
case Errors.DUPLICATE: return 'studio.projectErrors.duplicate';
|
||||
case Errors.RATE_LIMIT: return 'studio.projectErrors.tooFast';
|
||||
case Errors.UNKNOWN_PROJECT: return 'studio.projectErrors.checkUrl';
|
||||
case Errors.USER_MUTED: return 'studio.mutedError';
|
||||
default: return 'studio.projectErrors.generic';
|
||||
}
|
||||
};
|
||||
|
|
|
@ -38,13 +38,13 @@ const StudioProjects = ({
|
|||
<p>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
id="studios.mutedProjects"
|
||||
id="studio.mutedProjects"
|
||||
values={{
|
||||
inDuration: formatRelativeTime(muteExpiresAtMs, window._locale)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div><FormattedMessage id="studios.mutedPaused" /></div>
|
||||
<div><FormattedMessage id="studio.mutedPaused" /></div>
|
||||
</p>
|
||||
</CommentingStatus>
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ const errorToMessageId = error => {
|
|||
case Errors.INAPPROPRIATE: return 'studio.updateErrors.inappropriate';
|
||||
case Errors.TEXT_TOO_LONG: return 'studio.updateErrors.textTooLong';
|
||||
case Errors.REQUIRED_FIELD: return 'studio.updateErrors.requiredField';
|
||||
case Errors.USER_MUTED: return 'studio.mutedError';
|
||||
default: return 'studio.updateErrors.generic';
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,7 +48,6 @@ import {selectShowCuratorMuteError} from '../../redux/studio-permissions.js';
|
|||
|
||||
const StudioShell = ({showCuratorMuteError, muteExpiresAtMs, studioLoadFailed}) => {
|
||||
const match = useRouteMatch();
|
||||
|
||||
return (
|
||||
studioLoadFailed ?
|
||||
<NotAvailable /> :
|
||||
|
@ -68,13 +67,13 @@ const StudioShell = ({showCuratorMuteError, muteExpiresAtMs, studioLoadFailed})
|
|||
<p>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
id="studios.mutedCurators"
|
||||
id="studio.mutedCurators"
|
||||
values={{
|
||||
inDuration: formatRelativeTime(muteExpiresAtMs, window._locale)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div><FormattedMessage id="studios.mutedPaused" /></div>
|
||||
<div><FormattedMessage id="studio.mutedPaused" /></div>
|
||||
</p>
|
||||
</CommentingStatus>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue