mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-28 01:56:00 -05:00
Handle more types of project add errors
This commit is contained in:
parent
b6baedcbab
commit
efe961e103
2 changed files with 19 additions and 3 deletions
|
@ -26,7 +26,11 @@
|
||||||
"studio.projectsEmpty1": "This studio has no projects yet.",
|
"studio.projectsEmpty1": "This studio has no projects yet.",
|
||||||
"studio.projectsEmpty2": "Suggest projects you want to add in the comments!",
|
"studio.projectsEmpty2": "Suggest projects you want to add in the comments!",
|
||||||
"studio.browseProjects": "Browse Projects",
|
"studio.browseProjects": "Browse Projects",
|
||||||
"studio.projectErrors.checkUrl": "Could not add project. Check the URL and try again.",
|
"studio.projectErrors.checkUrl": "Could not find that project. Check the URL and try again.",
|
||||||
|
"studio.projectErrors.generic": "Could not add project",
|
||||||
|
"studio.projectErrors.tooFast": "You are adding projects too quickly",
|
||||||
|
"studio.projectErrors.permission": "You do not have permission to add that project",
|
||||||
|
"studio.projectErrors.duplicate": "That project is already in this studio",
|
||||||
|
|
||||||
"studio.creatorRole": "Studio Creator",
|
"studio.creatorRole": "Studio Creator",
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,22 @@ import {connect} from 'react-redux';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {FormattedMessage, intlShape, injectIntl} from 'react-intl';
|
import {FormattedMessage, intlShape, injectIntl} from 'react-intl';
|
||||||
|
|
||||||
import {addProject} from './lib/studio-project-actions';
|
import {Errors, addProject} from './lib/studio-project-actions';
|
||||||
import UserProjectsModal from './modals/user-projects-modal.jsx';
|
import UserProjectsModal from './modals/user-projects-modal.jsx';
|
||||||
import ValidationMessage from '../../components/forms/validation-message.jsx';
|
import ValidationMessage from '../../components/forms/validation-message.jsx';
|
||||||
|
|
||||||
|
const errorToMessageId = error => {
|
||||||
|
switch (error) {
|
||||||
|
case Errors.NETWORK: return 'studio.projectErrors.generic';
|
||||||
|
case Errors.SERVER: return 'studio.projectErrors.generic';
|
||||||
|
case Errors.PERMISSION: return 'studio.projectErrors.permission';
|
||||||
|
case Errors.DUPLICATE: return 'studio.projectErrors.duplicate';
|
||||||
|
case Errors.RATE_LIMIT: return 'studio.projectErrors.tooFast';
|
||||||
|
case Errors.UNKNOWN_PROJECT: return 'studio.projectErrors.checkUrl';
|
||||||
|
default: return 'studio.projectErrors.generic';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const StudioProjectAdder = ({intl, onSubmit}) => {
|
const StudioProjectAdder = ({intl, onSubmit}) => {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
@ -30,7 +42,7 @@ const StudioProjectAdder = ({intl, onSubmit}) => {
|
||||||
<ValidationMessage
|
<ValidationMessage
|
||||||
mode="error"
|
mode="error"
|
||||||
className="validation-left"
|
className="validation-left"
|
||||||
message={<FormattedMessage id="studio.projectErrors.checkUrl" />}
|
message={<FormattedMessage id={errorToMessageId(error)} />}
|
||||||
/>
|
/>
|
||||||
</div>}
|
</div>}
|
||||||
<input
|
<input
|
||||||
|
|
Loading…
Reference in a new issue