Remove all context api in all plugins except users

This commit is contained in:
soupette 2019-09-13 17:05:21 +02:00
parent 823cd24771
commit c971ab5ada
17 changed files with 34 additions and 721 deletions

View File

@ -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({

View File

@ -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',

View File

@ -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,

View File

@ -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,
};

View File

@ -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 (
<Tr
key={name}
onClick={e => {
e.stopPropagation();
const to = uid || name;
onClickGoTo(to, source);
}}
>
<td>
<p>
{name}
{source && (
<FormattedMessage id={`${pluginId}.from`}>
{message => (
<span
style={{
textTransform: 'initial',
fontStyle: 'italic',
color: '#787E8F',
fontWeight: '500',
}}
>
&nbsp;({message}: {source})
</span>
)}
</FormattedMessage>
)}
&nbsp; &nbsp; &nbsp;
{isTemporary && (
<FormattedMessage id={`${pluginId}.contentType.temporaryDisplay`} />
)}
</p>
</td>
<td>
<p>{description}</p>
</td>
<td>
{!source && (
<>
<button
type="button"
onClick={e => {
e.stopPropagation();
const to = uid || name;
onClickGoTo(to, source, canOpenModal || isTemporary);
}}
>
<i className="fa fa-pencil link-icon" />
</button>
<button
type="button"
onClick={e => {
e.stopPropagation();
if (canOpenModal || isTemporary) {
setIsOpen(true);
} else {
strapi.notification.info(
`${pluginId}.notification.info.work.notSaved`
);
}
}}
>
<i className="fa fa-trash link-icon" />
</button>
</>
)}
<PopUpWarning
isOpen={isOpen}
toggleModal={() => 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);
}}
/>
</td>
</Tr>
);
}
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;

View File

@ -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;

View File

@ -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 (
<div className={styles.homePage}>
<PluginHeader
title={{
id: `${pluginId}.home.contentTypeBuilder.name`,
}}
description={{
id: `${pluginId}.home.contentTypeBuilder.description`,
}}
actions={[]}
/>
<HeaderNav links={this.headerNavLinks} />
{availableNumber === 0 ? (
<EmptyContentTypeView
handleButtonClick={this.handleClick}
type={type}
/>
) : (
<ListWrapper>
<ListHeader
title={title}
titleValues={{ number: availableNumber }}
button={{
kind: 'secondaryHotlineAdd',
label: `${pluginId}.button.${type}.create`,
onClick: this.handleClick,
style: { right: 10 },
}}
style={{ paddingBottom: '0.8rem' }}
/>
<List>
<table>
<tbody>
{displayedData.map(data => (
<Row
key={data.name}
canOpenModal={canOpenModal}
context={this.context}
deleteGroup={deleteGroup}
deleteModel={deleteModel}
deleteTemporaryGroup={deleteTemporaryGroup}
deleteTemporaryModel={deleteTemporaryModel}
onClickGoTo={this.handleGoTo}
{...data}
viewType={type}
/>
))}
</tbody>
</table>
</List>
</ListWrapper>
)}
</div>
);
}
}
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;

View File

@ -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;
}
}
}
}
}

View File

@ -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 <HomePage />', () => {
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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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(<HomePage {...props} />, { 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`
);
});
});
});

View File

@ -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',

View File

@ -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,

View File

@ -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',

View File

@ -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',

View File

@ -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);

View File

@ -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,

View File

@ -139,8 +139,6 @@ class ConfigPage extends React.Component {
}
}
ConfigPage.contextTypes = {};
ConfigPage.defaultProps = {
appEnvironments: [],
formErrors: [],

View File

@ -164,10 +164,6 @@ HomePage.childContextTypes = {
deleteData: PropTypes.func.isRequired,
};
HomePage.contextTypes = {
router: PropTypes.object,
};
HomePage.defaultProps = {
params: {
_limit: 10,