mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	Fix tests that wasn't working with the router import
This commit is contained in:
		
							parent
							
								
									bac6dad0a6
								
							
						
					
					
						commit
						f344e33341
					
				@ -55,4 +55,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -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),
 | 
			
		||||
 | 
			
		||||
@ -52,4 +52,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -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 (
 | 
			
		||||
      <div className={styles.tableListContainer}>
 | 
			
		||||
        <div className="container-fluid">
 | 
			
		||||
@ -49,6 +51,7 @@ class TableList extends React.Component { // eslint-disable-line react/prefer-st
 | 
			
		||||
                  <TableListRow
 | 
			
		||||
                    key={key}
 | 
			
		||||
                    onDelete={this.props.onHandleDelete}
 | 
			
		||||
                    push={push}
 | 
			
		||||
                    rowItem={rowItem}
 | 
			
		||||
                  />
 | 
			
		||||
                ))}
 | 
			
		||||
@ -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,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -51,4 +51,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -50,4 +50,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -54,4 +54,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -53,4 +53,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -46,4 +46,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@ -56,4 +56,4 @@
 | 
			
		||||
    "npm": ">= 6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user