diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/Main/index.js b/packages/strapi-plugin-content-manager/admin/src/containers/Main/index.js
index 653eb22635..10dc8078fd 100644
--- a/packages/strapi-plugin-content-manager/admin/src/containers/Main/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/containers/Main/index.js
@@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { Switch, Route } from 'react-router-dom';
-import { LoadingIndicatorPage, getQueryParameters } from 'strapi-helper-plugin';
+import {
+ LoadingIndicatorPage,
+ getQueryParameters,
+ useGlobalContext,
+} from 'strapi-helper-plugin';
import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
@@ -22,7 +26,6 @@ import saga from './saga';
import makeSelectMain from './selectors';
function Main({
- emitEvent,
getData,
getLayout,
groups,
@@ -36,6 +39,7 @@ function Main({
}) {
strapi.useInjectReducer({ key: 'main', reducer, pluginId });
strapi.useInjectSaga({ key: 'main', saga, pluginId });
+ const { emitEvent } = useGlobalContext();
const slug = pathname.split('/')[3];
const source = getQueryParameters(search, 'source');
const getDataRef = useRef();
@@ -106,7 +110,6 @@ function Main({
}
Main.propTypes = {
- emitEvent: PropTypes.func.isRequired,
getData: PropTypes.func.isRequired,
getLayout: PropTypes.func.isRequired,
global: PropTypes.shape({
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js
index 3b771aba78..d0f9ebba7d 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, isEmpty } from 'lodash';
-import { InputsIndex as Input } from 'strapi-helper-plugin';
+import { InputsIndex as Input, GlobalContext } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -35,6 +35,8 @@ const NAVLINKS = [{ id: 'base' }, { id: 'advanced' }];
class AttributeForm extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
+
state = { didCheckErrors: false, formErrors: {}, showForm: false };
getCurrentForm = () => {
@@ -387,10 +389,6 @@ class AttributeForm extends React.Component {
}
}
-AttributeForm.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
AttributeForm.defaultProps = {
actionType: 'create',
activeTab: 'base',
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributesPickerModal/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributesPickerModal/index.js
index a408df838c..45e51f1617 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributesPickerModal/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributesPickerModal/index.js
@@ -7,6 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
+import { GlobalContext } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -24,6 +25,8 @@ import attributes from './attributes.json';
class AttributesPickerModal extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
+
state = { isDisplayed: false, nodeToFocus: 0 };
componentDidMount() {
@@ -194,11 +197,6 @@ class AttributesPickerModal extends React.Component {
}
}
-AttributesPickerModal.contextTypes = {
- emitEvent: PropTypes.func,
- plugins: PropTypes.object,
-};
-
AttributesPickerModal.defaultProps = {
isOpen: false,
featureName: null,
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js
index 32a0d96235..2495331a7a 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js
@@ -6,6 +6,7 @@ import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { get, isEqual } from 'lodash';
import { Prompt } from 'react-router';
+import { GlobalContext } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -53,6 +54,8 @@ import {
/* eslint-disable no-extra-boolean-cast */
export class GroupPage extends React.Component {
+ static contextType = GlobalContext;
+
state = {
attrToDelete: null,
removePrompt: false,
@@ -689,10 +692,6 @@ export class GroupPage extends React.Component {
}
}
-GroupPage.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
GroupPage.defaultProps = {
canOpenModal: true,
};
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Row.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Row.js
deleted file mode 100644
index a6eaf06917..0000000000
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Row.js
+++ /dev/null
@@ -1,148 +0,0 @@
-import React, { useState } from 'react';
-import PropTypes from 'prop-types';
-import { PopUpWarning } from 'strapi-helper-plugin';
-
-import { FormattedMessage } from 'react-intl';
-import pluginId from '../../pluginId';
-import Tr from './Tr';
-
-function Row({
- canOpenModal,
- context,
- description,
- deleteModel,
- deleteGroup,
- deleteTemporaryModel,
- deleteTemporaryGroup,
- isTemporary,
- name,
- onClickGoTo,
- source,
- uid,
- viewType,
-}) {
- const [isOpen, setIsOpen] = useState(false);
-
- return (
-
{
- e.stopPropagation();
-
- const to = uid || name;
- onClickGoTo(to, source);
- }}
- >
-
-
- {name}
- {source && (
-
- {message => (
-
- ({message}: {source})
-
- )}
-
- )}
-
- {isTemporary && (
-
- )}
-
- |
-
- {description}
- |
-
- {!source && (
- <>
-
-
- >
- )}
- setIsOpen(prevState => !prevState)}
- content={{
- message: `${pluginId}.popUpWarning.bodyMessage.${
- viewType === 'models' ? 'contentType' : 'groups'
- }.delete`,
- }}
- type="danger"
- onConfirm={() => {
- if (isTemporary) {
- const action =
- viewType === 'models'
- ? deleteTemporaryModel
- : deleteTemporaryGroup;
-
- action();
- } else {
- const action = viewType === 'models' ? deleteModel : deleteGroup;
- const featureName = viewType === 'models' ? name : uid;
-
- action(featureName, context);
- }
- setIsOpen(false);
- }}
- />
- |
-
- );
-}
-
-Row.defaultProps = {
- source: null,
- uid: null,
-};
-
-Row.propTypes = {
- canOpenModal: PropTypes.bool,
- context: PropTypes.object,
- deleteGroup: PropTypes.func.isRequired,
- deleteModel: PropTypes.func.isRequired,
- deleteTemporaryGroup: PropTypes.func.isRequired,
- deleteTemporaryModel: PropTypes.func.isRequired,
- description: PropTypes.string.isRequired,
- isTemporary: PropTypes.bool.isRequired,
- name: PropTypes.string.isRequired,
- onClickGoTo: PropTypes.func.isRequired,
- source: PropTypes.string,
- uid: PropTypes.string,
- viewType: PropTypes.string.isRequired,
-};
-
-export default Row;
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Tr.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Tr.js
deleted file mode 100644
index 9eb071a8b6..0000000000
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/Tr.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * Tr
- *
- */
-
-import styled from 'styled-components';
-
-const Tr = styled.tr`
- background-color: transparent;
- cursor: pointer;
- &:hover {
- background-color: #f7f8f8;
- }
- td:first-child {
- p {
- font-weight: 500;
- text-transform: capitalize;
- }
- }
- td:last-child {
- text-align: right;
- }
- button {
- &:focus {
- outline: 0;
- }
- cursor: pointer;
- }
- p {
- margin-bottom: 0;
- }
-`;
-
-export default Tr;
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
deleted file mode 100644
index 4a7535b130..0000000000
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/index.js
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- *
- * HomePage
- *
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-import {
- HeaderNav,
- List,
- ListHeader,
- ListWrapper,
- PluginHeader,
- routerPropTypes,
-} from 'strapi-helper-plugin';
-
-import EmptyContentTypeView from '../../components/EmptyContentTypeView';
-import pluginId from '../../pluginId';
-import Row from './Row';
-import styles from './styles.scss';
-
-const getUrl = to => `/plugins/${pluginId}${to}`;
-const getNavTrad = trad =>
- `${pluginId}.home.contentTypeBuilder.headerNav.link.${trad}`;
-
-class HomePage extends React.Component {
- // eslint-disable-line react/prefer-stateless-function
- headerNavLinks = [
- {
- name: getNavTrad('models'),
- to: getUrl('/models'),
- },
- {
- name: getNavTrad('groups'),
- to: getUrl('/groups'),
- },
- ];
-
- displayNotification = () =>
- strapi.notification.info(`${pluginId}.notification.info.work.notSaved`);
-
- handleClick = () => {
- const {
- canOpenModal,
- history: { push },
- match: {
- params: { type },
- },
- } = this.props;
- const { emitEvent } = this.context;
-
- if (canOpenModal) {
- const event =
- type === 'models' ? 'willCreateContentType' : 'willCreateGroup';
- const modalType = type === 'models' ? 'model' : 'group';
- emitEvent(event);
- push({
- search: `modalType=${modalType}&settingType=base&actionType=create`,
- });
- } else {
- this.displayNotification();
- }
- };
-
- handleDelete = isTemporary => {
- const { canOpenModal } = this.props;
-
- if (canOpenModal || isTemporary) {
- this.setState({});
- }
- };
-
- handleGoTo = (to, source, shouldEdit = false) => {
- const {
- history: { push },
- match: {
- params: { type },
- },
- } = this.props;
-
- const modalType = type === 'models' ? 'model' : 'group';
- const search = shouldEdit
- ? `?modalType=${modalType}&settingType=base&actionType=edit&modelName=${to}`
- : '';
- push(
- `/plugins/${pluginId}/${type}/${to.toLowerCase()}${
- source ? `&source=${source}` : ''
- }${search}`
- );
- };
-
- render() {
- const {
- canOpenModal,
- deleteGroup,
- deleteModel,
- deleteTemporaryGroup,
- deleteTemporaryModel,
- groups,
- match: {
- params: { type },
- },
- models,
- } = this.props;
- const displayedData = type === 'groups' ? groups : models;
- const availableNumber = type === 'groups' ? groups.length : models.length;
- const titleType = type === 'groups' ? type : 'contentType';
- const title = `${pluginId}.table.${titleType}.title.${
- availableNumber > 1 ? 'plural' : 'singular'
- }`;
-
- return (
-
-
-
-
- {availableNumber === 0 ? (
-
- ) : (
-
-
-
-
-
- {displayedData.map(data => (
-
- ))}
-
-
-
-
- )}
-
- );
- }
-}
-
-HomePage.contextTypes = {
- emitEvent: PropTypes.func.isRequired,
- plugins: PropTypes.object,
- updatePlugin: PropTypes.func,
-};
-
-HomePage.defaultProps = {
- canOpenModal: true,
- connections: ['default'],
- models: [],
- modifiedData: {},
-};
-
-HomePage.propTypes = {
- cancelNewContentType: PropTypes.func.isRequired,
- canOpenModal: PropTypes.bool,
- connections: PropTypes.array,
- createTempContentType: PropTypes.func.isRequired,
- deleteGroup: PropTypes.func.isRequired,
- deleteModel: PropTypes.func.isRequired,
- deleteTemporaryGroup: PropTypes.func.isRequired,
- models: PropTypes.array,
- modifiedData: PropTypes.object,
- newContentType: PropTypes.shape({
- collectionName: PropTypes.string,
- connection: PropTypes.string,
- description: PropTypes.string,
- mainField: PropTypes.string,
- name: PropTypes.string,
- attributes: PropTypes.object,
- }).isRequired,
- onChangeNewContentTypeMainInfos: PropTypes.func.isRequired,
- ...routerPropTypes().history.isRequired,
-};
-
-export default HomePage;
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss
deleted file mode 100644
index d60d1fba90..0000000000
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss
+++ /dev/null
@@ -1,16 +0,0 @@
-.homePage {
- /* stylelint-disable */
- padding: 1.8rem 3rem;
- background: rgba(14, 22, 34, 0.02);
- min-height: calc(100vh - 6rem); // TODO shoukd be variable
- :not(table) {
- div {
- button {
- top: 2.3rem;
- & + p:first-of-type {
- margin-top: 4px;
- }
- }
- }
- }
-}
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/tests/index.test.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/tests/index.test.js
deleted file mode 100644
index cafde65a14..0000000000
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/tests/index.test.js
+++ /dev/null
@@ -1,245 +0,0 @@
-import React from 'react';
-import { shallow } from 'enzyme';
-
-import pluginId from '../../../pluginId';
-import { ListHeader } from 'strapi-helper-plugin';
-import EmptyContentTypeView from '../../../components/EmptyContentTypeView';
-
-import HomePage from '../index';
-
-describe('CTB ', () => {
- let props;
-
- beforeEach(() => {
- props = {
- cancelNewContentType: jest.fn(),
- canOpenModal: true,
- createTempContentType: jest.fn(),
- deleteModel: jest.fn(),
- deleteGroup: jest.fn(),
- deleteTemporaryModel: jest.fn(),
- deleteTemporaryGroup: jest.fn(),
- groups: [],
- models: [
- {
- icon: 'fa-cube',
- name: 'permission',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- {
- icon: 'fa-cube',
- name: 'user',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- {
- icon: 'fa-cube',
- name: 'role',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- {
- icon: 'fa-cube',
- name: 'product',
- description: 'super api',
- fields: 6,
- isTemporary: false,
- },
- ],
- match: { params: { type: 'models' } },
- modifiedData: {},
- newContentType: {
- collectionName: '',
- connection: 'default',
- description: '',
- mainField: '',
- name: '',
- attributes: {},
- },
- onChangeNewContentTypeMainInfos: jest.fn(),
- history: {
- push: jest.fn(),
- },
- location: {
- search: '',
- pathname: `/plugins/${pluginId}/models`,
- },
- };
- });
-
- it('should not crash', () => {
- const context = { emitEvent: jest.fn() };
-
- shallow(, { context });
- });
-
- describe('render', () => {
- it('should display the EmptyContentTypeView if there is no model in the application', () => {
- props.models = [];
-
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const emptyView = wrapper.find(EmptyContentTypeView);
-
- expect(emptyView).toHaveLength(1);
- });
-
- it('should display the EmptyContentTypeView if there is no model in the application', () => {
- props.match.params.type = 'groups';
-
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const emptyView = wrapper.find(EmptyContentTypeView);
-
- expect(emptyView).toHaveLength(1);
- });
-
- it('Should handle the listheader title correctly if there is more than 1 model', () => {
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const list = wrapper.find(ListHeader);
-
- expect(list).toHaveLength(1);
- expect(list.prop('title')).toContain('table.contentType.title.plural');
- });
-
- it('Should handle the listheader title correctly if there is more than 1 group', () => {
- props.groups = props.models;
- props.match.params.type = 'groups';
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const list = wrapper.find(ListHeader);
-
- expect(list).toHaveLength(1);
- expect(list.prop('title')).toContain('table.groups.title.plural');
- });
-
- it('Should handle the listheader title correctly if there is less than 2 groups', () => {
- props.groups = [
- {
- icon: 'fa-cube',
- name: 'user',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- ];
- props.match.params.type = 'groups';
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const list = wrapper.find(ListHeader);
-
- expect(list).toHaveLength(1);
-
- expect(list.prop('title')).toContain('table.groups.title.singular');
- });
-
- it('Should handle the listheader title correctly if there is less than 2 models', () => {
- props.models = [
- {
- icon: 'fa-cube',
- name: 'user',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- ];
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const list = wrapper.find(ListHeader);
-
- expect(list).toHaveLength(1);
- expect(list.prop('title')).toContain('table.contentType.title.singular');
- });
- });
-
- describe('workflow', () => {
- it('should open the modelForm for the model if there is no saved content type', () => {
- props.canOpenModal = true;
- props.history.push = jest.fn(({ search }) => {
- props.location.search = `?${search}`;
- });
-
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const spyOnClick = jest.spyOn(wrapper.instance(), 'handleClick');
-
- wrapper.instance().forceUpdate();
- // Simulate the click on button
- wrapper
- .find(ListHeader)
- .prop('button')
- .onClick();
- wrapper.instance().forceUpdate();
-
- expect(spyOnClick).toHaveBeenCalled();
- expect(context.emitEvent).toHaveBeenCalledWith('willCreateContentType');
- expect(props.history.push).toHaveBeenCalledWith({
- search: 'modalType=model&settingType=base&actionType=create',
- });
- });
-
- it('should open the modelForm for groups if there is no is no saved content type', () => {
- props.canOpenModal = true;
- props.groups = [
- {
- icon: 'fa-cube',
- name: 'user',
- description: '',
- fields: 6,
- source: 'users-permissions',
- isTemporary: false,
- },
- ];
- props.location.pathname = `/plugins/${pluginId}/groups`;
- props.history.push = jest.fn(({ search }) => {
- props.location.search = `?${search}`;
- });
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
- const spyOnClick = jest.spyOn(wrapper.instance(), 'handleClick');
-
- wrapper.instance().forceUpdate();
- // Simulate the click on button
- wrapper
- .find(ListHeader)
- .prop('button')
- .onClick();
- wrapper.instance().forceUpdate();
-
- expect(spyOnClick).toHaveBeenCalled();
- expect(context.emitEvent).toHaveBeenCalledWith('willCreateContentType');
- expect(props.history.push).toHaveBeenCalledWith({
- search: 'modalType=model&settingType=base&actionType=create',
- });
- });
-
- it('should not open the modal if there is one not saved content type and display a notification', () => {
- props.canOpenModal = false;
- const context = { emitEvent: jest.fn() };
- const wrapper = shallow(, { context });
-
- wrapper
- .find(ListHeader)
- .prop('button')
- .onClick();
- wrapper.instance().forceUpdate();
-
- expect(context.emitEvent).not.toHaveBeenCalled();
- expect(props.history.push).not.toHaveBeenCalled();
- expect(strapi.notification.info).toHaveBeenCalled();
- expect(strapi.notification.info).toHaveBeenCalledWith(
- `${pluginId}.notification.info.work.notSaved`
- );
- });
- });
-});
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelForm/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelForm/index.js
index 9f074e0474..4c30a2a3ac 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelForm/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelForm/index.js
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, isEmpty, upperFirst } from 'lodash';
-import { InputsIndex as Input } from 'strapi-helper-plugin';
+import { GlobalContext, InputsIndex as Input } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -32,6 +32,8 @@ const NAVLINKS = [{ id: 'base' }, { id: 'advanced' }];
class ModelForm extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
+
state = { didCheckErrors: false, formErrors: {}, isVisible: false };
handleCancel = () => {
@@ -282,10 +284,6 @@ class ModelForm extends React.Component {
}
}
-ModelForm.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
ModelForm.defaultProps = {
actionType: 'create',
activeTab: 'base',
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js
index 1cd43347f9..03c2f339e7 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js
@@ -16,6 +16,7 @@ import { Prompt } from 'react-router';
import {
Button,
EmptyAttributesBlock,
+ GlobalContext,
List,
ListHeader,
ListTitle,
@@ -55,6 +56,8 @@ import styles from './styles.scss';
/* eslint-disable no-extra-boolean-cast */
export class ModelPage extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
+
state = {
attrToDelete: null,
removePrompt: false,
@@ -108,19 +111,6 @@ export class ModelPage extends React.Component {
getAttributeType = () =>
getQueryParameters(this.getSearch(), 'attributeType');
- // getFormData = () => {
- // const { modifiedData, newContentType } = this.props;
-
- // if (
- // this.getActionType() === 'create' ||
- // this.isUpdatingTemporaryContentType()
- // ) {
- // return newContentType;
- // }
-
- // return get(modifiedData, this.getModelName());
- // };
-
getModalType = () => getQueryParameters(this.getSearch(), 'modalType');
getModel = () => {
@@ -762,13 +752,6 @@ export class ModelPage extends React.Component {
}
}
-ModelPage.contextTypes = {
- emitEvent: PropTypes.func,
- plugins: PropTypes.object,
- router: PropTypes.object,
- updatePlugin: PropTypes.func,
-};
-
ModelPage.defaultProps = {
connections: ['default'],
canOpenModal: true,
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationForm/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationForm/index.js
index fcafd67b2c..ff90f3ba9f 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationForm/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationForm/index.js
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, isEmpty } from 'lodash';
-import { InputsIndex as Input } from 'strapi-helper-plugin';
+import { GlobalContext, InputsIndex as Input } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -40,6 +40,7 @@ const NAVLINKS = [{ id: 'base', custom: 'relation' }, { id: 'advanced' }];
class RelationForm extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
state = { didCheckErrors: false, formErrors: {}, showForm: false };
@@ -354,10 +355,6 @@ class RelationForm extends React.Component {
}
}
-RelationForm.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
RelationForm.defaultProps = {
actionType: 'create',
activeTab: 'base',
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationFormGroup/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationFormGroup/index.js
index 81f0dc757f..0b3abc8728 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationFormGroup/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/RelationFormGroup/index.js
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, isEmpty } from 'lodash';
-import { InputsIndex as Input } from 'strapi-helper-plugin';
+import { GlobalContext, InputsIndex as Input } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@@ -37,6 +37,7 @@ const NAVLINKS = [{ id: 'base', custom: 'relation' }, { id: 'advanced' }];
class RelationFormGroup extends React.Component {
// eslint-disable-line react/prefer-stateless-function
+ static contextType = GlobalContext;
state = { didCheckErrors: false, formErrors: {}, showForm: false };
@@ -364,10 +365,6 @@ class RelationFormGroup extends React.Component {
}
}
-RelationFormGroup.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
RelationFormGroup.defaultProps = {
actionType: 'create',
activeTab: 'base',
diff --git a/packages/strapi-plugin-email/admin/src/containers/ConfigPage/index.js b/packages/strapi-plugin-email/admin/src/containers/ConfigPage/index.js
index 2882ee16ba..c86d143be6 100644
--- a/packages/strapi-plugin-email/admin/src/containers/ConfigPage/index.js
+++ b/packages/strapi-plugin-email/admin/src/containers/ConfigPage/index.js
@@ -40,7 +40,7 @@ class ConfigPage extends React.Component {
// Redirect the user to the email list after modifying is provider
if (prevProps.submitSuccess !== this.props.submitSuccess) {
this.props.history.push(
- `/plugins/email/configurations/${this.props.match.params.env}`,
+ `/plugins/email/configurations/${this.props.match.params.env}`
);
}
}
@@ -85,8 +85,8 @@ class ConfigPage extends React.Component {
get(
this.props.settings,
['providers', this.getSelectedProviderIndex(), 'auth'],
- {},
- ),
+ {}
+ )
).reduce((acc, current) => {
if (isEmpty(get(this.props.modifiedData, current, ''))) {
acc.push({
@@ -145,8 +145,6 @@ class ConfigPage extends React.Component {
}
}
-ConfigPage.contextTypes = {};
-
ConfigPage.defaultProps = {
appEnvironments: [],
formErrors: [],
@@ -180,7 +178,7 @@ function mapDispatchToProps(dispatch) {
setErrors,
submit,
},
- dispatch,
+ dispatch
);
}
@@ -188,7 +186,7 @@ const mapStateToProps = selectConfigPage();
const withConnect = connect(
mapStateToProps,
- mapDispatchToProps,
+ mapDispatchToProps
);
const withReducer = strapi.injectReducer({
@@ -201,5 +199,5 @@ const withSaga = strapi.injectSaga({ key: 'configPage', saga, pluginId });
export default compose(
withReducer,
withSaga,
- withConnect,
+ withConnect
)(ConfigPage);
diff --git a/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js
index 6945c0fe53..19a18c0ceb 100644
--- a/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js
+++ b/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js
@@ -27,7 +27,7 @@ import {
import { FormattedMessage } from 'react-intl';
import Helmet from 'react-helmet';
-import { InputSelect } from 'strapi-helper-plugin';
+import { GlobalContext, InputSelect } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
// design
@@ -94,6 +94,8 @@ export class HomePage extends React.Component {
this.sendUpdatedParams = sendUpdatedParams.bind(this);
}
+ static contextType = GlobalContext;
+
componentDidMount() {
if (this.props.match.params.slug) {
this.handleFetch(this.props);
@@ -648,10 +650,6 @@ function mapDispatchToProps(dispatch) {
);
}
-HomePage.contextTypes = {
- emitEvent: PropTypes.func,
-};
-
HomePage.propTypes = {
cancelChanges: PropTypes.func.isRequired,
changeDefaultLanguage: PropTypes.func.isRequired,
diff --git a/packages/strapi-plugin-upload/admin/src/containers/ConfigPage/index.js b/packages/strapi-plugin-upload/admin/src/containers/ConfigPage/index.js
index 8886eca04d..963dcd42ee 100644
--- a/packages/strapi-plugin-upload/admin/src/containers/ConfigPage/index.js
+++ b/packages/strapi-plugin-upload/admin/src/containers/ConfigPage/index.js
@@ -139,8 +139,6 @@ class ConfigPage extends React.Component {
}
}
-ConfigPage.contextTypes = {};
-
ConfigPage.defaultProps = {
appEnvironments: [],
formErrors: [],
diff --git a/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js
index eb0cf70661..ded67a94e9 100644
--- a/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js
+++ b/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js
@@ -164,10 +164,6 @@ HomePage.childContextTypes = {
deleteData: PropTypes.func.isRequired,
};
-HomePage.contextTypes = {
- router: PropTypes.object,
-};
-
HomePage.defaultProps = {
params: {
_limit: 10,