Apply feedback

This commit is contained in:
Aurelsicoko 2017-09-25 15:35:27 +02:00
parent b8accc03b9
commit cb00ac2a31
15 changed files with 72 additions and 71 deletions

View File

@ -30,16 +30,15 @@ export default class NotFound extends React.Component { // eslint-disable-line r
<FormattedMessage {...messages.description} /> <FormattedMessage {...messages.description} />
</h2> </h2>
<Button <Button
label="Back to home page" label="app.components.NotFoundPage.back"
handlei18n
buttonBackground="back" buttonBackground="back"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
this.props.history.goBack(); this.props.history.goBack();
}} }}
> />
Back to home page.
</Button>
</div> </div>
); );
} }

View File

@ -9,5 +9,6 @@
"app.components.LeftMenuLinkContainer.listPlugins": "List plugins", "app.components.LeftMenuLinkContainer.listPlugins": "List plugins",
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "No plugins installed yet", "app.components.LeftMenuLinkContainer.noPluginsInstalled": "No plugins installed yet",
"app.components.LeftMenuLinkContainer.plugins": "Plugins", "app.components.LeftMenuLinkContainer.plugins": "Plugins",
"app.components.NotFoundPage.description": "" "app.components.NotFoundPage.description": "Not Found",
"app.components.NotFoundPage.back": "Back to homepage"
} }

View File

@ -9,5 +9,6 @@
"app.components.LeftMenuLinkContainer.listPlugins": "Liste des plugins", "app.components.LeftMenuLinkContainer.listPlugins": "Liste des plugins",
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "Aucun plugin installé", "app.components.LeftMenuLinkContainer.noPluginsInstalled": "Aucun plugin installé",
"app.components.LeftMenuLinkContainer.plugins": "Plugins", "app.components.LeftMenuLinkContainer.plugins": "Plugins",
"app.components.NotFoundPage.description": "Page introuvable" "app.components.NotFoundPage.description": "Page introuvable",
"app.components.NotFoundPage.back": "Retourner à la page d'accueil"
} }

View File

@ -33,12 +33,12 @@
"eslint": "^4.7.2", "eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0", "eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2", "eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0", "eslint-config-prettier": "^2.6.0",
"eslint-import-resolver-webpack": "^0.8.3", "eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-babel": "^4.1.2", "eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^2.7.0", "eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.3.0", "eslint-plugin-react": "^7.4.0",
"eslint-plugin-redux-saga": "^0.4.0", "eslint-plugin-redux-saga": "^0.4.0",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^1.0.1",
"html-loader": "^0.4.3", "html-loader": "^0.4.3",

View File

@ -1,19 +1,13 @@
import { isArray } from 'lodash'; import { isArray, isObject } from 'lodash';
function cleanData(value, key, secondKey) { const cleanData = (value, key, secondKey) => {
if (isArray(value)) { if (isArray(value)) {
return value.map(obj => { return value.map(obj => obj[key] ? obj[key] : obj);
if (obj[key]) { } else if (isObject(value)) {
return obj[key];
}
return obj;
});
} else if (_.isObject(value)) {
return value[key] || value[secondKey]; return value[key] || value[secondKey];
} } else {
return value; return value;
}
} }
export default cleanData; export default cleanData;

View File

@ -8,12 +8,7 @@ import 'whatwg-fetch';
* @return {object} The parsed JSON from the request * @return {object} The parsed JSON from the request
*/ */
function parseJSON(response) { function parseJSON(response) {
if (response.json) { return response.json : response.json() : response;
return response.json();
}
return response;
}
/** /**
* Checks if a network request came back fine, and throws an error if not * Checks if a network request came back fine, and throws an error if not

View File

@ -55,6 +55,9 @@ class SelectMany extends React.Component { // eslint-disable-line react/prefer-s
}]; }];
return { options }; return { options };
})
.catch(() => {
window.Strapi.notification.error('An error occurred during relationship fetch.');
}); });
} }

View File

@ -55,6 +55,9 @@ class SelectOne extends React.Component { // eslint-disable-line react/prefer-st
}]; }];
return {options}; return {options};
})
.catch(() => {
window.Strapi.notification.error('An error occurred during relationship fetch.');
}); });
} }

View File

@ -9,7 +9,6 @@ import { LOAD_MODELS, LOADED_MODELS } from './constants';
import { makeSelectModels } from './selectors'; import { makeSelectModels } from './selectors';
export const generateMenu = function () { export const generateMenu = function () {
try {
return request(`${window.Strapi.apiUrl}/content-manager/models`, { return request(`${window.Strapi.apiUrl}/content-manager/models`, {
method: 'GET', method: 'GET',
}) })
@ -22,12 +21,10 @@ export const generateMenu = function () {
destination: key, destination: key,
})), })),
}]; }];
})
.catch(() => {
window.Strapi.notification.error('error.model.fetch');
}); });
} catch (err) {
window.Strapi.notification.error(
'An error occurred during models config fetch.'
);
}
} }
export function* getModels() { export function* getModels() {
@ -39,9 +36,7 @@ export function* getModels() {
yield put(loadedModels(response)); yield put(loadedModels(response));
} catch (err) { } catch (err) {
window.Strapi.notification.error( window.Strapi.notification.error('error.model.fetch');
'An error occurred during models config fetch.'
);
} }
} }
@ -52,9 +47,7 @@ export function* modelsLoaded() {
try { try {
schema = generateSchema(models); schema = generateSchema(models);
} catch (err) { } catch (err) {
window.Strapi.notification.error( window.Strapi.notification.error('error.schema.generation');
'An error occurred during schema generation.'
);
throw new Error(err); throw new Error(err);
} }

View File

@ -32,7 +32,7 @@ export function* getRecord(params) {
yield put(recordLoaded(response)); yield put(recordLoaded(response));
} catch (err) { } catch (err) {
window.Strapi.notification.error('An error occurred during record fetch.'); window.Strapi.notification.error('error.record.fetch');
} }
} }
@ -60,14 +60,10 @@ export function* editRecord() {
}); });
yield put(recordEdited()); yield put(recordEdited());
window.Strapi.notification.success( window.Strapi.notification.success('content-manager.success.record.save');
`Saved`
);
} catch (err) { } catch (err) {
yield put(recordEditError()); yield put(recordEditError());
window.Strapi.notification.error( window.Strapi.notification.error(isCreating ? 'content-manager.error.record.create' : 'content-manager.error.record.update');
`An error occurred during record ${isCreating ? 'creation' : 'update'}.`
);
} }
} }
@ -82,17 +78,13 @@ export function* deleteRecord({ id, modelName }) {
}); });
yield put(recordDeleted(id)); yield put(recordDeleted(id));
window.Strapi.notification.success( window.Strapi.notification.success('success.record.delete');
'Deleted'
);
// Redirect to the list page. // Redirect to the list page.
router.push(`/plugins/content-manager/${modelName}`); router.push(`/plugins/content-manager/${modelName}`);
} catch (err) { } catch (err) {
yield put(recordDeleteError()); yield put(recordDeleteError());
window.Strapi.notification.error( window.Strapi.notification.error('error.record.delete');
'An error occurred during record deletion.'
);
} }
} }

View File

@ -50,7 +50,7 @@ export function* getRecords() {
yield put(loadedRecord(response)); yield put(loadedRecord(response));
} catch (err) { } catch (err) {
window.Strapi.notification.error('An error occurred during records fetch.'); window.Strapi.notification.error('error.records.fetch');
} }
} }
@ -65,9 +65,7 @@ export function* getCount() {
yield put(loadedCount(response.count)); yield put(loadedCount(response.count));
} catch (err) { } catch (err) {
window.Strapi.notification.error( window.Strapi.notification.error('error.records.count');
'An error occurred during count records fetch.'
);
} }
} }

View File

@ -12,6 +12,14 @@
"components.LimitSelect.itemsPerPage": "Items per page", "components.LimitSelect.itemsPerPage": "Items per page",
"containers.List.errorFetchRecords": "Error", "containers.List.errorFetchRecords": "Error",
"error.schema.generation": "An error occurred during schema generation.",
"error.records.count": "An error occurred during count records fetch.",
"error.records.fetch": "An error occurred during records fetch.",
"error.record.fetch": "An error occurred during record fetch.",
"error.record.create": "An error occurred during record creation.",
"error.record.update": "An error occurred during record update.",
"error.record.delete": "An error occurred during record deletion.",
"error.model.fetch": "An error occurred during models config fetch.",
"error.validation.required": "This value input is required.", "error.validation.required": "This value input is required.",
"error.validation.regex": "The value not match the regex.", "error.validation.regex": "The value not match the regex.",
"error.validation.max": "The value is too high.", "error.validation.max": "The value is too high.",
@ -24,6 +32,9 @@
"error.attribute.sameKeyAndName": "Can't be equals", "error.attribute.sameKeyAndName": "Can't be equals",
"error.validation.minSupMax": "Can't be superior", "error.validation.minSupMax": "Can't be superior",
"success.record.delete": "Deleted",
"success.record.save": "Saved",
"pageNotFound": "Page not found", "pageNotFound": "Page not found",
"popUpWarning.button.cancel": "Cancel", "popUpWarning.button.cancel": "Cancel",

View File

@ -13,6 +13,14 @@
"components.LimitSelect.itemsPerPage": "Éléments par page", "components.LimitSelect.itemsPerPage": "Éléments par page",
"containers.List.errorFetchRecords": "Erreur", "containers.List.errorFetchRecords": "Erreur",
"error.schema.generation": "Une erreur est survenue lors de la génération du schéma.",
"error.records.count": "Une erreur est survenue lors de la réception du nombre d'entrées.",
"error.records.fetch": "Une erreur est survenue lors de la réception des entrées.",
"error.record.fetch": "Une erreur est survenue lors de la réception de l'entrée.",
"error.record.create": "Une erreur est survenue lors de la création de l'entrée.",
"error.record.update": "Une erreur est survenue lors de la modification de l'entrée.",
"error.record.delete": "Une erreur est survenue lors de la suppression de l'entrée.",
"error.model.fetch": "Une erreur est survenue lors de la réception des modèles.",
"error.validation.required": "Ce champ est obligatoire.", "error.validation.required": "Ce champ est obligatoire.",
"error.validation.regex": "La valeur ne correspond pas au format attendu.", "error.validation.regex": "La valeur ne correspond pas au format attendu.",
"error.validation.max": "La valeur est trop grande.", "error.validation.max": "La valeur est trop grande.",
@ -25,6 +33,9 @@
"error.attribute.sameKeyAndName": "Ne peuvent pas être égaux", "error.attribute.sameKeyAndName": "Ne peuvent pas être égaux",
"error.validation.minSupMax": "Ne peut pas être plus grand", "error.validation.minSupMax": "Ne peut pas être plus grand",
"success.record.delete": "Supprimé",
"success.record.save": "Sauvegardé",
"popUpWarning.button.cancel": "Annuler", "popUpWarning.button.cancel": "Annuler",
"popUpWarning.button.confirm": "Confirmer", "popUpWarning.button.confirm": "Confirmer",
"popUpWarning.title": "Confirmation requise", "popUpWarning.title": "Confirmation requise",

View File

@ -52,12 +52,12 @@
"eslint": "^4.7.2", "eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0", "eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2", "eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0", "eslint-config-prettier": "^2.6.0",
"eslint-import-resolver-webpack": "^0.8.3", "eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-babel": "^4.1.2", "eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^2.7.0", "eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.3.0", "eslint-plugin-react": "^7.4.0",
"eslint-plugin-redux-saga": "^0.4.0", "eslint-plugin-redux-saga": "^0.4.0",
"plop": "^1.8.1", "plop": "^1.8.1",
"prettier": "^1.7.0", "prettier": "^1.7.0",

View File

@ -38,12 +38,12 @@
"eslint": "^4.7.2", "eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0", "eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2", "eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0", "eslint-config-prettier": "^2.6.0",
"eslint-import-resolver-webpack": "^0.8.3", "eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-babel": "^4.1.2", "eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^2.7.0", "eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.3.0", "eslint-plugin-react": "^7.4.0",
"eslint-plugin-redux-saga": "^0.4.0", "eslint-plugin-redux-saga": "^0.4.0",
"plop": "^1.8.1", "plop": "^1.8.1",
"prettier": "^1.7.0", "prettier": "^1.7.0",