Skip to content

Commit

Permalink
Update generators to the new architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
soupette committed Apr 2, 2019
1 parent 67099a6 commit 3053a01
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// import React from 'react';
// import { mount, shallow } from 'enzyme';
// import pluginId from '../../pluginId';

// 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(pluginId, 'isReady', true);
// });
it('should have unit tests specified', () => {
expect(true).toBe(true);
});
});
Empty file.
23 changes: 23 additions & 0 deletions packages/strapi-generate-plugin/files/admin/src/lifecycles.js
Original file line number Diff line number Diff line change
@@ -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"); }
// });
};

0 comments on commit 3053a01

Please sign in to comment.