-
Create Folder
+ {this.props.t('NewFolderModal.Title')}
@@ -32,23 +34,24 @@ class NewFolderModal extends React.Component {
}
NewFolderModal.propTypes = {
- closeModal: PropTypes.func.isRequired
+ closeModal: PropTypes.func.isRequired,
+ t: PropTypes.func.isRequired
};
function validate(formProps) {
const errors = {};
if (!formProps.name) {
- errors.name = 'Please enter a name';
+ errors.name = i18n.t('NewFolderModal.EnterName');
} else if (formProps.name.trim().length === 0) {
- errors.name = 'Folder name cannot contain only spaces';
+ errors.name = i18n.t('NewFolderModal.EmptyName');
} else if (formProps.name.match(/\.+/i)) {
- errors.name = 'Folder name cannot contain an extension';
+ errors.name = i18n.t('NewFolderModal.InvalidExtension');
}
return errors;
}
-export default reduxForm({
+export default withTranslation()(reduxForm({
form: 'new-folder',
fields: ['name'],
validate
-})(NewFolderModal);
+})(NewFolderModal));
diff --git a/package-lock.json b/package-lock.json
index 04592b99..8abec584 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "p5.js-web-editor",
- "version": "1.0.6",
+ "version": "1.0.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index ba2680a8..01f558f9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "p5.js-web-editor",
- "version": "1.0.6",
+ "version": "1.0.7",
"description": "The web editor for p5.js.",
"scripts": {
"clean": "rimraf dist",
diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js
index 7f118c23..2a83aa6a 100644
--- a/server/controllers/project.controller.js
+++ b/server/controllers/project.controller.js
@@ -30,14 +30,15 @@ export function updateProject(req, res) {
$set: req.body
},
{
- new: true
+ new: true,
+ runValidators: true
}
)
.populate('user', 'username')
.exec((updateProjectErr, updatedProject) => {
if (updateProjectErr) {
console.log(updateProjectErr);
- res.json({ success: false });
+ res.status(400).json({ success: false });
return;
}
if (req.body.files && updatedProject.files.length !== req.body.files.length) {
@@ -50,7 +51,7 @@ export function updateProject(req, res) {
updatedProject.save((innerErr, savedProject) => {
if (innerErr) {
console.log(innerErr);
- res.json({ success: false });
+ res.status(400).json({ success: false });
return;
}
res.json(savedProject);
diff --git a/server/controllers/project.controller/createProject.js b/server/controllers/project.controller/createProject.js
index e4040268..74529c0d 100644
--- a/server/controllers/project.controller/createProject.js
+++ b/server/controllers/project.controller/createProject.js
@@ -9,7 +9,7 @@ export default function createProject(req, res) {
projectValues = Object.assign(projectValues, req.body);
function sendFailure() {
- res.json({ success: false });
+ res.status(400).json({ success: false });
}
function populateUserData(newProject) {
diff --git a/server/models/project.js b/server/models/project.js
index bf8c992e..3581e998 100644
--- a/server/models/project.js
+++ b/server/models/project.js
@@ -29,7 +29,7 @@ fileSchema.set('toJSON', {
const projectSchema = new Schema(
{
- name: { type: String, default: "Hello p5.js, it's the server" },
+ name: { type: String, default: "Hello p5.js, it's the server", maxlength: 128 },
user: { type: Schema.Types.ObjectId, ref: 'User' },
serveSecure: { type: Boolean, default: false },
files: { type: [fileSchema] },
diff --git a/translations/locales/en-US/translations.json b/translations/locales/en-US/translations.json
index 56a898f5..d0868580 100644
--- a/translations/locales/en-US/translations.json
+++ b/translations/locales/en-US/translations.json
@@ -173,5 +173,26 @@
},
"IDEView": {
"SubmitFeedback": "Submit Feedback"
+ },
+ "NewFileModal": {
+ "Title": "Create File",
+ "CloseButtonARIA": "Close New File Modal",
+ "EnterName": "Please enter a name",
+ "InvalidType": "Invalid file type. Valid extensions are .js, .css, .json, .txt, .csv, .tsv, .frag, and .vert."
+ },
+ "NewFileForm": {
+ "AddFileSubmit": "Add File",
+ "Placeholder": "Name"
+},
+ "NewFolderModal": {
+ "Title": "Create Folder",
+ "CloseButtonARIA": "Close New Folder Modal",
+ "EnterName": "Please enter a name",
+ "EmptyName": "Folder name cannot contain only spaces",
+ "InvalidExtension": "Folder name cannot contain an extension"
+ },
+ "NewFolderForm": {
+ "AddFolderSubmit": "Add Folder",
+ "Placeholder": "Name"
}
}
diff --git a/translations/locales/es-419/translations.json b/translations/locales/es-419/translations.json
index 8b8d8f87..398da8dc 100644
--- a/translations/locales/es-419/translations.json
+++ b/translations/locales/es-419/translations.json
@@ -172,6 +172,27 @@
},
"IDEView": {
"SubmitFeedback": "Enviar retroalimentación"
+ },
+ "NewFileModal": {
+ "Title": "Crear Archivo",
+ "CloseButtonARIA": "Cerrar diálogo de crear archivo",
+ "EnterName": "Por favor introduce un nombre",
+ "InvalidType": "Tipo de archivo inválido. Las extensiones válidas son .js, .css, .json, .txt, .csv, .tsv, .frag y .vert."
+ },
+ "NewFileForm": {
+ "AddFileSubmit": "Agregar Archivo",
+ "Placeholder": "Nombre"
+ },
+ "NewFolderModal": {
+ "Title": "Crear Directorio",
+ "CloseButtonARIA": "Cerrar Diálogo de Nuevo Directorio",
+ "EnterName": "Por favor introduce un nombre",
+ "EmptyName": " El nombre del directorio no debe contener solo espacios vacíos",
+ "InvalidExtension": "El nombre del directorio no debe contener una extensión"
+},
+ "NewFolderForm": {
+ "AddFolderSubmit": "Agregar Directorio",
+ "Placeholder": "Nombre"
}
}