forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update generators to the new architecture
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/strapi-generate-plugin/files/admin/src/containers/Initializer/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
25 changes: 25 additions & 0 deletions
25
packages/strapi-generate-plugin/files/admin/src/containers/Initializer/tests/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
packages/strapi-generate-plugin/files/admin/src/lifecycles.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); } | ||
// }); | ||
}; |