From 6645d12f33151ae52657d72327aff04fe415f90a Mon Sep 17 00:00:00 2001 From: cyril lopez Date: Thu, 12 Oct 2017 19:35:32 +0200 Subject: [PATCH] Use strapi helper plugin PoPUpWarning component in content type builder --- .../admin/src/translations/en.json | 7 +++++-- .../admin/src/translations/fr.json | 7 ++++++- .../lib/src/components/PopUpWarning/index.js | 20 ++++++++++++++----- .../src/components/AttributeRow/index.js | 6 +++--- .../index.js | 0 .../styles.scss | 0 .../src/components/TableListRow/index.js | 6 +++--- 7 files changed, 32 insertions(+), 14 deletions(-) rename packages/strapi-plugin-content-type-builder/admin/src/components/{PopUpWarning => OldPopUpWarning}/index.js (100%) rename packages/strapi-plugin-content-type-builder/admin/src/components/{PopUpWarning => OldPopUpWarning}/styles.scss (100%) diff --git a/packages/strapi-admin/admin/src/translations/en.json b/packages/strapi-admin/admin/src/translations/en.json index a83776608a..f6c25b214a 100755 --- a/packages/strapi-admin/admin/src/translations/en.json +++ b/packages/strapi-admin/admin/src/translations/en.json @@ -14,6 +14,9 @@ "components.AutoReloadBlocker.header": "Reload feature is required for this plugin.", "components.AutoReloadBlocker.description": "Open the following file and enable the feature.", "components.ProductionBlocker.header": "This plugin is only available in development.", - "components.ProductionBlocker.description": "For safety we have to disable this plugin in other environments." - + "components.ProductionBlocker.description": "For safety we have to disable this plugin in other environments.", + "components.popUpWarning.button.cancel": "Cancel", + "components.popUpWarning.button.confirm": "Confirm", + "components.popUpWarning.title": "Please confirm", + "components.popUpWarning.message": "Are you sure you want to delete this?" } diff --git a/packages/strapi-admin/admin/src/translations/fr.json b/packages/strapi-admin/admin/src/translations/fr.json index 015d6b0f99..45ba197216 100755 --- a/packages/strapi-admin/admin/src/translations/fr.json +++ b/packages/strapi-admin/admin/src/translations/fr.json @@ -14,5 +14,10 @@ "components.AutoReloadBlocker.header": "L'autoReload doit être activé pour ce plugin.", "components.AutoReloadBlocker.description": "Ouvrez le fichier suivant pour activer cette fonctionnalité.", "components.ProductionBlocker.header": "Ce plugin est disponible uniquement en développement.", - "components.ProductionBlocker.description": "Pour des raisons de sécurité il est désactivé dans les autres environnements." + "components.ProductionBlocker.description": "Pour des raisons de sécurité il est désactivé dans les autres environnements.", + "comonents.popUpWarning.button.cancel": "Annuler", + "comonents.popUpWarning.button.confirm": "Confirmer", + "components.popUpWarning.title": "Merci de confirmer", + "components.popUpWarning.message": "Etes-vous sure de vouloir le supprimer?" + } diff --git a/packages/strapi-helper-plugin/lib/src/components/PopUpWarning/index.js b/packages/strapi-helper-plugin/lib/src/components/PopUpWarning/index.js index 5044629bdc..c6ab2699b9 100644 --- a/packages/strapi-helper-plugin/lib/src/components/PopUpWarning/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/PopUpWarning/index.js @@ -35,25 +35,25 @@ class PopUpWarning extends React.Component { // eslint-disable-line react/prefer
- +
icon - + {(message) => (

{message}

)}
- + {(message) => ( )} - + {(message) => ( )} @@ -68,11 +68,21 @@ class PopUpWarning extends React.Component { // eslint-disable-line react/prefer } PopUpWarning.propTypes = { - bodyMessage: PropTypes.string, + content: PropTypes.shape({ + confirm: PropTypes.string, + message: PropTypes.string, + title: PropTypes.string, + }), isOpen: PropTypes.bool.isRequired, onConfirm: PropTypes.func, popUpWarningType: PropTypes.string, toggleModal: PropTypes.func.isRequired, } +PopUpWarning.defaultProps = { + content: { + message: 'components.popUpWarning.message', + }, +} + export default PopUpWarning; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/AttributeRow/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/AttributeRow/index.js index 2deab92251..d84d00eb5e 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/AttributeRow/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/AttributeRow/index.js @@ -48,7 +48,7 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer this.props.onEditAttribute(this.props.row.name); } - delete = () => { + handleDelete = () => { this.props.onDelete(this.props.row.name); this.setState({ showWarning: false }); } @@ -98,9 +98,9 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer ); diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpWarning/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/OldPopUpWarning/index.js similarity index 100% rename from packages/strapi-plugin-content-type-builder/admin/src/components/PopUpWarning/index.js rename to packages/strapi-plugin-content-type-builder/admin/src/components/OldPopUpWarning/index.js diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpWarning/styles.scss b/packages/strapi-plugin-content-type-builder/admin/src/components/OldPopUpWarning/styles.scss similarity index 100% rename from packages/strapi-plugin-content-type-builder/admin/src/components/PopUpWarning/styles.scss rename to packages/strapi-plugin-content-type-builder/admin/src/components/OldPopUpWarning/styles.scss diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/TableListRow/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/TableListRow/index.js index b02fba38f0..006475a691 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/TableListRow/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/TableListRow/index.js @@ -27,7 +27,7 @@ class TableListRow extends React.Component { // eslint-disable-line react/prefer router.push(`/plugins/content-type-builder/#edit${this.props.rowItem.name}::contentType::baseSettings`); } - delete = (e) => { + handleDelete = (e) => { e.preventDefault(); e.stopPropagation(); this.props.onDelete(this.props.rowItem.name) @@ -72,9 +72,9 @@ class TableListRow extends React.Component { // eslint-disable-line react/prefer );