mirror of
https://github.com/strapi/strapi.git
synced 2025-10-18 11:32:42 +00:00
Update generators to the new architecture
This commit is contained in:
parent
67099a676a
commit
0cd5473675
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Initializer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
|
class Initializer extends React.PureComponent {
|
||||||
|
// eslint-disable-line react/prefer-stateless-function
|
||||||
|
componentDidMount() {
|
||||||
|
// Emit the event 'pluginReady'
|
||||||
|
this.props.updatePlugin(pluginId, 'isReady', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Initializer.propTypes = {
|
||||||
|
updatePlugin: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Initializer;
|
@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount, shallow } from 'enzyme';
|
||||||
|
|
||||||
|
import Initializer from '../index';
|
||||||
|
|
||||||
|
describe('<Initializer />', () => {
|
||||||
|
it('Should not crash', () => {
|
||||||
|
const updatePlugin = jest.fn();
|
||||||
|
const renderedComponent = shallow(<Initializer updatePlugin={updatePlugin} />);
|
||||||
|
|
||||||
|
expect(renderedComponent.children()).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call the updatePlugin props when mounted', () => {
|
||||||
|
const updatePlugin = jest.fn();
|
||||||
|
|
||||||
|
const wrapper = mount(<Initializer updatePlugin={updatePlugin} />);
|
||||||
|
|
||||||
|
expect(wrapper.prop('updatePlugin')).toHaveBeenCalledWith('upload', 'isReady', true);
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* SET THE HOOKS TO ENABLE THE MAGIC OF STRAPI.
|
||||||
|
* -------------------------------------------
|
||||||
|
*
|
||||||
|
* Secure, customise and enhance your project by setting
|
||||||
|
* the hooks via this file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = function lifecycles() {
|
||||||
|
// Set hooks for the AdminPage container.
|
||||||
|
// Note: we don't need to specify the first argument because we already know what "willSecure" refers to.
|
||||||
|
this.setHooks({
|
||||||
|
didGetSecuredData: () => console.log('do something'),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set hooks for the App container of the Content Manager.
|
||||||
|
// Note: we have to specify the first argument to select a specific container which is located in a plugin, or not.
|
||||||
|
// this.setHooks('content-manager.App', {
|
||||||
|
// willSomething: () => { console.log("Do Something"); }
|
||||||
|
// });
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user