diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index bac4f7f828..ff118fbbb2 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -55,4 +55,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-helper-plugin/lib/src/commonPropTypes/router/index.js b/packages/strapi-helper-plugin/lib/src/commonPropTypes/router/index.js index 6ee08f7cd1..40b0929428 100644 --- a/packages/strapi-helper-plugin/lib/src/commonPropTypes/router/index.js +++ b/packages/strapi-helper-plugin/lib/src/commonPropTypes/router/index.js @@ -1,6 +1,24 @@ import PropTypes from 'prop-types'; -const propTypes = (params) => ({ +const propTypes = (params = {}) => ({ + history: PropTypes.shape({ + action: PropTypes.string, + block: PropTypes.func, + createHref: PropTypes.func, + go: PropTypes.func, + goBack: PropTypes.func, + goForward: PropTypes.func, + length: PropTypes.number, + listen: PropTypes.func, + location: PropTypes.shape({ + pathname: PropTypes.string, + search: PropTypes.string, + hash: PropTypes.string, + key: PropTypes.string, + }), + push: PropTypes.func, + replace: PropTypes.func, + }).isRequired, match: PropTypes.shape({ isExact: PropTypes.bool, params: PropTypes.shape(params), diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index e1c72123b6..87205bf477 100644 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -52,4 +52,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/TableList/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/TableList/index.js index 442aabcde7..b0d4fa6d56 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/TableList/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/TableList/index.js @@ -15,6 +15,8 @@ import styles from './styles.scss'; class TableList extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { + const { push } = this.props; + return (
@@ -49,6 +51,7 @@ class TableList extends React.Component { // eslint-disable-line react/prefer-st ))} @@ -66,6 +69,7 @@ TableList.propTypes = { buttonLabel: PropTypes.string.isRequired, onButtonClick: PropTypes.func.isRequired, onHandleDelete: PropTypes.func.isRequired, + push: PropTypes.func.isRequired, rowItems: PropTypes.array.isRequired, title: PropTypes.string.isRequired, }; 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 1d1f7fd13e..5ed8bced0b 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 @@ -11,7 +11,6 @@ import { FormattedMessage } from 'react-intl'; import IcoContainer from 'components/IcoContainer'; import ListRow from 'components/ListRow'; import PopUpWarning from 'components/PopUpWarning'; -import { router } from 'app'; import styles from '../TableList/styles.scss'; /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable react/jsx-curly-brace-presence */ @@ -26,7 +25,8 @@ class TableListRow extends React.Component { } handleEdit = () => { - router.push( + const { push } = this.props; + push( `/plugins/content-type-builder/#edit${this.props.rowItem.name}::contentType::baseSettings`, ); }; @@ -39,7 +39,8 @@ class TableListRow extends React.Component { }; handleGoTo = () => { - router.push( + const { push } = this.props; + push( `/plugins/content-type-builder/models/${this.props.rowItem.name}${ this.props.rowItem.source ? `&source=${this.props.rowItem.source}` : '' }`, @@ -109,6 +110,7 @@ class TableListRow extends React.Component { TableListRow.propTypes = { onDelete: PropTypes.func.isRequired, + push: PropTypes.func.isRequired, rowItem: PropTypes.object.isRequired, }; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/index.js index e6bd575c39..a1dbdd3898 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/index.js @@ -11,6 +11,9 @@ import { createStructuredSelector } from 'reselect'; import { bindActionCreators, compose } from 'redux'; import PluginHeader from 'components/PluginHeader'; + +import { routerPropTypes } from 'commonPropTypes'; + import EmptyContentTypeView from '../../components/EmptyContentTypeView'; import TableList from '../../components/TableList'; @@ -24,13 +27,17 @@ import saga from './saga'; export class HomePage extends React.Component { // eslint-disable-line react/prefer-stateless-function - handleDeleteModel = (modelName) => { this.props.deleteModel(modelName); } render() { - const { models } = this.props; + const { + history: { + push, + }, + models, + } = this.props; const availableNumber = models.length; const title = availableNumber > 1 ? `${pluginId}.table.contentType.title.plural` : `${pluginId}.table.contentType.title.singular`; @@ -45,6 +52,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre onButtonClick={() => {}} onHandleDelete={this.handleDeleteModel} rowItems={this.props.models} + push={push} /> ); @@ -69,6 +77,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre } HomePage.propTypes = { + ...routerPropTypes().history, deleteModel: PropTypes.func.isRequired, models: PropTypes.array.isRequired, }; diff --git a/packages/strapi-plugin-content-type-builder/package.json b/packages/strapi-plugin-content-type-builder/package.json index fcffcf23aa..8efdd3a40a 100644 --- a/packages/strapi-plugin-content-type-builder/package.json +++ b/packages/strapi-plugin-content-type-builder/package.json @@ -51,4 +51,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-email/package.json b/packages/strapi-plugin-email/package.json index ccefcf32f1..fd1f722587 100644 --- a/packages/strapi-plugin-email/package.json +++ b/packages/strapi-plugin-email/package.json @@ -50,4 +50,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-graphql/package.json b/packages/strapi-plugin-graphql/package.json index 5729cb670f..8caf52677e 100644 --- a/packages/strapi-plugin-graphql/package.json +++ b/packages/strapi-plugin-graphql/package.json @@ -54,4 +54,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-settings-manager/package.json b/packages/strapi-plugin-settings-manager/package.json index 22c22f3674..7894dc912b 100644 --- a/packages/strapi-plugin-settings-manager/package.json +++ b/packages/strapi-plugin-settings-manager/package.json @@ -53,4 +53,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-upload/package.json b/packages/strapi-plugin-upload/package.json index 1be374e166..f256d568f3 100644 --- a/packages/strapi-plugin-upload/package.json +++ b/packages/strapi-plugin-upload/package.json @@ -46,4 +46,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-users-permissions/package.json b/packages/strapi-plugin-users-permissions/package.json index c47eac6e33..0101ada403 100644 --- a/packages/strapi-plugin-users-permissions/package.json +++ b/packages/strapi-plugin-users-permissions/package.json @@ -56,4 +56,4 @@ "npm": ">= 6.0.0" }, "license": "MIT" -} +} \ No newline at end of file