From d1356fa3eaf9c39fa4b981d0b44f9bcce0cbcc43 Mon Sep 17 00:00:00 2001 From: soupette Date: Thu, 10 Oct 2019 11:45:26 +0200 Subject: [PATCH 1/6] Update plugin generators to add front-end files --- .../files/admin/src/containers/App/actions.js | 5 - .../admin/src/containers/App/constants.js | 5 - .../files/admin/src/containers/App/index.js | 111 +++++++++--------- .../files/admin/src/containers/App/reducer.js | 18 --- .../admin/src/containers/App/selectors.js | 10 -- .../src/containers/ExamplePage/actions.js | 20 ---- .../src/containers/ExamplePage/constants.js | 10 -- .../admin/src/containers/ExamplePage/index.js | 98 ---------------- .../src/containers/ExamplePage/reducer.js | 27 ----- .../admin/src/containers/ExamplePage/saga.js | 34 ------ .../src/containers/ExamplePage/selectors.js | 25 ---- .../src/containers/ExamplePage/styles.scss | 3 - .../admin/src/containers/HomePage/actions.js | 13 -- .../src/containers/HomePage/constants.js | 9 -- .../admin/src/containers/HomePage/index.js | 65 ++-------- .../admin/src/containers/HomePage/reducer.js | 22 ---- .../admin/src/containers/HomePage/saga.js | 9 -- .../src/containers/HomePage/selectors.js | 18 --- .../admin/src/containers/HomePage/styles.scss | 3 - .../admin/src/containers/Initializer/index.js | 21 ++-- .../Initializer/tests/index.test.js | 25 ---- .../src/containers/NotFoundPage/index.js | 20 ---- .../files/admin/src/index.js | 34 ++++++ .../files/admin/src/initializer.js | 0 .../files/admin/src/lifecycles.js | 24 +--- .../files/admin/src/translations/index.js | 35 ++++++ .../files/admin/src/translations/ru.json | 1 + .../files/admin/src/translations/zh-Hans.json | 1 + packages/strapi-generate-plugin/lib/before.js | 6 + 29 files changed, 154 insertions(+), 518 deletions(-) delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/App/actions.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/App/constants.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/App/reducer.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/App/selectors.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/actions.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/constants.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/index.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/reducer.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/saga.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/selectors.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/styles.scss delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/actions.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/constants.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/reducer.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/saga.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/selectors.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/HomePage/styles.scss delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/Initializer/tests/index.test.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/containers/NotFoundPage/index.js create mode 100644 packages/strapi-generate-plugin/files/admin/src/index.js delete mode 100644 packages/strapi-generate-plugin/files/admin/src/initializer.js create mode 100644 packages/strapi-generate-plugin/files/admin/src/translations/index.js diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/actions.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/actions.js deleted file mode 100644 index a5002ad023..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/actions.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * - * App actions - * - */ diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/constants.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/constants.js deleted file mode 100644 index f62c609507..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/constants.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * - * App constants - * - */ diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js index ff6369ae2f..290b4abe15 100644 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js +++ b/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js @@ -1,3 +1,44 @@ +///////////////////////////////////////////////////// +// DISPLAY YOUR PLUGIN IN THE ADMINISTRATION PANEL // +///////////////////////////////////////////////////// +/* +1. Check the installed plugin in your package.json you will need to require them manually +2. Copy the following code in my-app/admin/src/plugins.js (don't forget to add the other installed plugins) + +``` +const injectReducer = require('./utils/injectReducer').default; +const useInjectReducer = require('./utils/injectReducer').useInjectReducer; +const injectSaga = require('./utils/injectSaga').default; +const useInjectSaga = require('./utils/injectSaga').useInjectSaga; +const { languages } = require('./i18n'); + +window.strapi = Object.assign(window.strapi || {}, { + node: MODE || 'host', + env: NODE_ENV, + backendURL: BACKEND_URL === '/' ? window.location.origin : BACKEND_URL, + languages, + currentLanguage: + window.localStorage.getItem('strapi-admin-language') || + window.navigator.language || + window.navigator.userLanguage || + 'en', + injectReducer, + injectSaga, + useInjectReducer, + useInjectSaga, +}); + +module.exports = { + 'strapi-plugin-users-permissions': require('../../plugins/strapi-plugin-users-permissions/admin/src') + .default, + // Add the other plugins here + // ..., + // Add your newly created plugin here (the path is different than the others) + 'my-plugin': require('../../../plugins/my-plugin/admin/src').default, +}; +``` +*/ + /** * * This component is the skeleton around the actual pages, and should only @@ -6,66 +47,22 @@ */ import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; import { Switch, Route } from 'react-router-dom'; -import { bindActionCreators, compose } from 'redux'; - +import { NotFound } from 'strapi-helper-plugin'; // Utils -import pluginId from 'pluginId'; - +import pluginId from '../../pluginId'; // Containers -import HomePage from 'containers/HomePage'; -import NotFoundPage from 'containers/NotFoundPage'; -// When you're done studying the ExamplePage container, remove the following line and delete the ExamplePage container -import ExamplePage from 'containers/ExamplePage'; +import HomePage from '../HomePage'; -import reducer from './reducer'; - -class App extends React.Component { - // When you're done studying the ExamplePage container, remove the following lines and delete the ExamplePage container - componentDidMount() { - this.props.history.push(`/plugins/${pluginId}/example`); - } - - render() { - return ( -
- - - {/* When you're done studying the ExamplePage container, remove the following line and delete the ExamplePage container */} - - - -
- ); - } -} - -App.contextTypes = { - plugins: PropTypes.object, - updatePlugin: PropTypes.func, -}; - -App.propTypes = { - history: PropTypes.object.isRequired, -}; - -export function mapDispatchToProps(dispatch) { - return bindActionCreators( - {}, - dispatch, +const App = () => { + return ( +
+ + + + +
); -} +}; -const mapStateToProps = createStructuredSelector({}); - -// Wrap the component to inject dispatch and state into it -const withConnect = connect(mapStateToProps, mapDispatchToProps); -const withReducer = strapi.injectReducer({ key: 'global', reducer, pluginId }); - -export default compose( - withReducer, - withConnect, -)(App); +export default App; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/reducer.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/reducer.js deleted file mode 100644 index 38026c39cd..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/reducer.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * App reducer - * - */ - -import { fromJS } from 'immutable'; - -const initialState = fromJS({}); - -function appReducer(state = initialState, action) { - switch (action.type) { - default: - return state; - } -} - -export default appReducer; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/selectors.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/selectors.js deleted file mode 100644 index 66ab2b4e3f..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/selectors.js +++ /dev/null @@ -1,10 +0,0 @@ -// import { createSelector } from 'reselect'; -// import pluginId from 'pluginId'; - -/** - * Direct selector to the list state domain - */ - -// const selectGlobalDomain = () => state => state.get(`${pluginId}_global`); - -export {}; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/actions.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/actions.js deleted file mode 100644 index 7ee9e0c287..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/actions.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * - * ExamplePage actions - * - */ - -import { LOAD_DATA, LOADED_DATA } from './constants'; - -export function loadData() { - return { - type: LOAD_DATA, - }; -} - -export function loadedData(data) { - return { - type: LOADED_DATA, - data, - }; -} diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/constants.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/constants.js deleted file mode 100644 index 115ee3bbd1..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/constants.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - * - * ExamplePage constants - * - */ - -import pluginId from 'pluginId'; - -export const LOAD_DATA = `${pluginId}/ExamplePage/LOAD_DATA`; -export const LOADED_DATA = `${pluginId}/ExamplePage/LOADED_DATA`; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/index.js deleted file mode 100644 index 54fd0530f4..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/index.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * ExamplePage - * - */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { injectIntl } from 'react-intl'; -import { bindActionCreators, compose } from 'redux'; -import pluginId from 'pluginId'; - -import Button from 'components/Button'; - -import styles from './styles.scss'; -import { loadData } from './actions'; -import { makeSelectLoading, makeSelectData } from './selectors'; -import reducer from './reducer'; -import saga from './saga'; - -export class ExamplePage extends React.Component { - generateDataBlock() { - if (this.props.data) { - const items = this.props.data.map((item, i) =>
  • {item}
  • ); - return ( -
    -

    Data:

    - -
    - ); - } - return; - } - - render() { - console.log('Don\'t forget to delete the ExampleContainer when you\'re done studying it'); - // Generate the data block - const dataBlock = this.generateDataBlock(); - - return ( -
    -
    -
    -

    This is an example of a fake API call.

    -

    Loading: {this.props.loading ? 'yes' : 'no'}.

    - {dataBlock} -
    -
    -
    - ); - } -} - -ExamplePage.contextTypes = { - router: PropTypes.object, -}; - -ExamplePage.propTypes = { - data: PropTypes.oneOfType([ - PropTypes.bool, - PropTypes.object, - ]).isRequired, - loadData: PropTypes.func.isRequired, - loading: PropTypes.bool.isRequired, -}; - -function mapDispatchToProps(dispatch) { - return bindActionCreators( - { - loadData, - }, - dispatch, - ); -} - -const mapStateToProps = createStructuredSelector({ - loading: makeSelectLoading(), - data: makeSelectData(), -}); - -const withConnect = connect(mapStateToProps, mapDispatchToProps); - -const withReducer = strapi.injectReducer({ key: 'examplePage', reducer, pluginId }); -const withSaga = strapi.injectSaga({ key: 'examplePage', saga, pluginId }); - -export default compose( - withReducer, - withSaga, - withConnect, -)(injectIntl(ExamplePage)); diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/reducer.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/reducer.js deleted file mode 100644 index b4d15c18f3..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/reducer.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * ExamplePage reducer - * - */ - -import { fromJS } from 'immutable'; - -import { LOAD_DATA, LOADED_DATA } from './constants'; - -const initialState = fromJS({ - loading: false, - data: false, -}); - -function examplePageReducer(state = initialState, action) { - switch (action.type) { - case LOAD_DATA: - return state.set('loading', true); - case LOADED_DATA: - return state.set('loading', false).set('data', fromJS(action.data)); - default: - return state; - } -} - -export default examplePageReducer; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/saga.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/saga.js deleted file mode 100644 index c7c1a8fe48..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/saga.js +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-disable */ -import { LOCATION_CHANGE } from 'react-router-redux'; -import { takeLatest, put, fork, take, cancel } from 'redux-saga/effects'; - -import { loadedData } from './actions'; -import { LOAD_DATA } from './constants'; - -export function* loadData() { - // Fake API request delay - yield new Promise(resolve => { - setTimeout(() => { - resolve(); - }, 1000); - }); - - // Generate a random array - const data = Array(4) - .fill(0) - .map(() => Math.floor(Math.random() * 100)); - - yield put(loadedData(data)); -} - -// Individual exports for testing -export function* defaultSaga() { - const loadDataWatcher = yield fork(takeLatest, LOAD_DATA, loadData); - - // Suspend execution until location changes - yield take(LOCATION_CHANGE); - yield cancel(loadDataWatcher); -} - -// All sagas to be loaded -export default defaultSaga; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/selectors.js b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/selectors.js deleted file mode 100644 index e0a8cccbe9..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/selectors.js +++ /dev/null @@ -1,25 +0,0 @@ -import { createSelector } from 'reselect'; -import pluginId from 'pluginId'; - -/** - * Direct selector to the examplePage state domain - */ -const selectExamplePageDomain = () => state => state.get(`${pluginId}_examplePage`); - -/** - * Default selector used by HomePage - */ - -const makeSelectLoading = () => - createSelector( - selectExamplePageDomain(), - substate => substate.get('loading'), - ); - -const makeSelectData = () => - createSelector( - selectExamplePageDomain(), - substate => substate.get('data'), - ); - -export { makeSelectLoading, makeSelectData }; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/styles.scss b/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/styles.scss deleted file mode 100644 index 72be3f7fa8..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/ExamplePage/styles.scss +++ /dev/null @@ -1,3 +0,0 @@ -.examplePage { - -} diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/actions.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/actions.js deleted file mode 100644 index 233d030606..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/actions.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * - * HomePage actions - * - */ - -import { DEFAULT_ACTION } from './constants'; - -export function defaultAction() { - return { - type: DEFAULT_ACTION, - }; -} diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/constants.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/constants.js deleted file mode 100644 index 6adcb7014c..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/constants.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * - * HomePage constants - * - */ - -import pluginId from 'pluginId'; - -export const DEFAULT_ACTION = `${pluginId}/HomePage/DEFAULT_ACTION`; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/index.js index 70cad54fe4..05c5a6a377 100644 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/index.js +++ b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/index.js @@ -4,60 +4,17 @@ * */ -import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { injectIntl } from 'react-intl'; -import { bindActionCreators, compose } from 'redux'; -import pluginId from 'pluginId'; +import React, { memo } from 'react'; +// import PropTypes from 'prop-types'; +import pluginId from '../../pluginId'; -// Selectors -import selectHomePage from './selectors'; - -// Styles -import styles from './styles.scss'; - -import reducer from './reducer'; -import saga from './saga'; - -export class HomePage extends React.Component { - render() { - return ( -
    -
    - ); - } -} - -HomePage.contextTypes = { - router: PropTypes.object, -}; - -HomePage.propTypes = { - // homePage: PropTypes.object, -}; - -function mapDispatchToProps(dispatch) { - return bindActionCreators( - { - // Your actions here - }, - dispatch, +const HomePage = () => { + return ( +
    +

    {pluginId}'s HomePage

    +

    Happy coding

    +
    ); -} +}; -const mapStateToProps = createStructuredSelector({ - homePage: selectHomePage(), -}); - -const withConnect = connect(mapStateToProps, mapDispatchToProps); - -const withReducer = strapi.injectReducer({ key: 'homePage', reducer, pluginId }); -const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId }); - -export default compose( - withReducer, - withSaga, - withConnect, -)(injectIntl(HomePage)); +export default memo(HomePage); diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/reducer.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/reducer.js deleted file mode 100644 index 554a71e0e4..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/reducer.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * - * HomePage reducer - * - */ - -import { fromJS } from 'immutable'; - -import { DEFAULT_ACTION } from './constants'; - -const initialState = fromJS({}); - -function homePageReducer(state = initialState, action) { - switch (action.type) { - case DEFAULT_ACTION: - return state; - default: - return state; - } -} - -export default homePageReducer; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/saga.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/saga.js deleted file mode 100644 index b7e6203def..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/saga.js +++ /dev/null @@ -1,9 +0,0 @@ -// import { LOCATION_CHANGE } from 'react-router-redux'; -// import { takeLatest, put, fork, take, cancel } from 'redux-saga/effects'; - -// Individual exports for testing -export function* defaultSaga() { -} - -// All sagas to be loaded -export default defaultSaga; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/selectors.js b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/selectors.js deleted file mode 100644 index 7dddab17d1..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/selectors.js +++ /dev/null @@ -1,18 +0,0 @@ -import { createSelector } from 'reselect'; -import pluginId from 'pluginId'; -/** - * Direct selector to the homePage state domain - */ -const selectHomePageDomain = () => state => state.get(`${pluginId}_homePage`); - -/** - * Default selector used by HomePage - */ - -const selectHomePage = () => - createSelector( - selectHomePageDomain(), - substate => substate.toJS(), - ); - -export default selectHomePage; diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/styles.scss b/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/styles.scss deleted file mode 100644 index abd13152b4..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/HomePage/styles.scss +++ /dev/null @@ -1,3 +0,0 @@ -.homePage { - -} diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/index.js index 6e8f49cdca..06b5488a9d 100644 --- a/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/index.js +++ b/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/index.js @@ -4,21 +4,20 @@ * */ -import React from 'react'; +import { useEffect, useRef } 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); - } +const Initializer = ({ updatePlugin }) => { + const ref = useRef(); + ref.current = updatePlugin; - render() { - return null; - } -} + useEffect(() => { + ref.current(pluginId, 'isReady', true); + }, []); + + return null; +}; Initializer.propTypes = { updatePlugin: PropTypes.func.isRequired, diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/tests/index.test.js b/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/tests/index.test.js deleted file mode 100644 index 28563d12ba..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/Initializer/tests/index.test.js +++ /dev/null @@ -1,25 +0,0 @@ -// import React from 'react'; -// import { mount, shallow } from 'enzyme'; -// import pluginId from '../../pluginId'; - -// import Initializer from '../index'; - -describe('', () => { - // it('Should not crash', () => { - // const updatePlugin = jest.fn(); - // const renderedComponent = shallow(); - - // expect(renderedComponent.children()).toHaveLength(0); - // }); - - // it('should call the updatePlugin props when mounted', () => { - // const updatePlugin = jest.fn(); - - // const wrapper = mount(); - - // expect(wrapper.prop('updatePlugin')).toHaveBeenCalledWith(pluginId, 'isReady', true); - // }); - it('should have unit tests specified', () => { - expect(true).toBe(true); - }); -}); diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/NotFoundPage/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/NotFoundPage/index.js deleted file mode 100644 index 8ca6fd2190..0000000000 --- a/packages/strapi-generate-plugin/files/admin/src/containers/NotFoundPage/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * NotFoundPage - * - * This is the page we show when the user visits a url that doesn't have a route - * - * NOTE: while this component should technically be a stateless functional - * component (SFC), hot reloading does not currently support SFCs. If hot - * reloading is not a neccessity for you then you can refactor it and remove - * the linting exception. - */ - -import React from 'react'; - -import NotFound from 'components/NotFound'; - -export default class NotFoundPage extends React.Component { - render() { - return ; - } -} diff --git a/packages/strapi-generate-plugin/files/admin/src/index.js b/packages/strapi-generate-plugin/files/admin/src/index.js new file mode 100644 index 0000000000..0d18ac5014 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/index.js @@ -0,0 +1,34 @@ +import React from 'react'; +import pluginPkg from '../../package.json'; +import pluginId from './pluginId'; +import App from './containers/App'; +import Initializer from './containers/Initializer'; +import lifecycles from './lifecycles'; +import trads from './translations'; + +const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; + +function Comp(props) { + return ; +} + +const plugin = { + blockerComponent: null, + blockerComponentProps: {}, + description: pluginDescription, + icon: pluginPkg.strapi.icon, + id: pluginId, + initializer: Initializer, + injectedComponents: [], + isReady: false, + layout: null, + lifecycles, + leftMenuLinks: [], + leftMenuSections: [], + mainComponent: Comp, + name: pluginPkg.strapi.name, + preventComponentRendering: false, + trads, +}; + +export default plugin; diff --git a/packages/strapi-generate-plugin/files/admin/src/initializer.js b/packages/strapi-generate-plugin/files/admin/src/initializer.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/strapi-generate-plugin/files/admin/src/lifecycles.js b/packages/strapi-generate-plugin/files/admin/src/lifecycles.js index 06682e7244..81b01720a8 100644 --- a/packages/strapi-generate-plugin/files/admin/src/lifecycles.js +++ b/packages/strapi-generate-plugin/files/admin/src/lifecycles.js @@ -1,23 +1,3 @@ -/* - * - * SET THE HOOKS TO ENABLE THE MAGIC OF STRAPI. - * ------------------------------------------- - * - * Secure, customise and enhance your project by setting - * the hooks via this file. - * - */ +function lifecycles() {} -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"); } - // }); -}; +export default lifecycles; diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/index.js b/packages/strapi-generate-plugin/files/admin/src/translations/index.js new file mode 100644 index 0000000000..e1277816ff --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/index.js @@ -0,0 +1,35 @@ +import ar from './ar.json'; +import de from './de.json'; +import en from './en.json'; +import es from './es.json'; +import fr from './fr.json'; +import it from './it.json'; +import ko from './ko.json'; +import nl from './nl.json'; +import pl from './pl.json'; +import ptBR from './pt-BR.json'; +import pt from './pt.json'; +import ru from './ru.json'; +import tr from './tr.json'; +import zhHans from './zh-Hans.json'; +import zh from './zh.json'; + +const trads = { + ar, + de, + en, + es, + fr, + it, + ko, + nl, + pl, + 'pt-BR': ptBR, + pt, + ru, + tr, + 'zh-Hans': zhHans, + zh, +}; + +export default trads; diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/ru.json b/packages/strapi-generate-plugin/files/admin/src/translations/ru.json index e69de29bb2..0967ef424b 100644 --- a/packages/strapi-generate-plugin/files/admin/src/translations/ru.json +++ b/packages/strapi-generate-plugin/files/admin/src/translations/ru.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/zh-Hans.json b/packages/strapi-generate-plugin/files/admin/src/translations/zh-Hans.json index e69de29bb2..0967ef424b 100644 --- a/packages/strapi-generate-plugin/files/admin/src/translations/zh-Hans.json +++ b/packages/strapi-generate-plugin/files/admin/src/translations/zh-Hans.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-generate-plugin/lib/before.js b/packages/strapi-generate-plugin/lib/before.js index 1e72f32367..67a50d3630 100644 --- a/packages/strapi-generate-plugin/lib/before.js +++ b/packages/strapi-generate-plugin/lib/before.js @@ -56,6 +56,12 @@ module.exports = (scope, cb) => { const pluginDir = path.resolve(scope.rootPath, 'plugins'); fs.ensureDirSync(pluginDir); + // Copy the admin files. + fs.copySync( + path.resolve(__dirname, '..', 'files'), + path.resolve(pluginDir, scope.humanizeId) + ); + // Trigger callback with no error to proceed. return cb.success(); }; From 5b32e32758baadeb082c510ec4bd14e3d41e3124 Mon Sep 17 00:00:00 2001 From: Virginie Ky Date: Fri, 11 Oct 2019 14:59:41 +0200 Subject: [PATCH 2/6] Some UI fixes --- .../admin/src/components/Logout/components.js | 21 +-- .../ButtonModal/StyledButtonSecondary.js | 21 +-- .../ButtonModal/StyledButtonSuccess.js | 8 +- .../lib/src/components/HeaderNav/Wrapper.js | 30 +--- .../admin/src/components/Group/components.js | 1 + .../src/components/PopUpForm/Components.js | 140 +----------------- .../admin/src/components/PopUpForm/index.js | 6 +- 7 files changed, 39 insertions(+), 188 deletions(-) diff --git a/packages/strapi-admin/admin/src/components/Logout/components.js b/packages/strapi-admin/admin/src/components/Logout/components.js index 3c31cf2f87..09658d03f3 100644 --- a/packages/strapi-admin/admin/src/components/Logout/components.js +++ b/packages/strapi-admin/admin/src/components/Logout/components.js @@ -9,10 +9,13 @@ const Wrapper = styled.div` width: 100%; line-height: 5.8rem; z-index: 999; - > button { + > button, + > button.btn { + position: relative; + z-index: 9; width: 100%; padding-right: 20px; - background: transparent; + background: white; border: none; border-radius: 0; color: #333740; @@ -27,6 +30,7 @@ const Wrapper = styled.div` &:active { color: #333740; background-color: #fafafb !important; + z-index: 9; } > i { @@ -57,6 +61,8 @@ const Wrapper = styled.div` } .dropDownContent { + z-index: 8; + top: -3px !important; left: auto !important; min-width: 100% !important; margin: 0 !important; @@ -72,7 +78,7 @@ const Wrapper = styled.div` &:before { content: ''; position: absolute; - top: -3px; + top: 0; left: -1px; width: calc(100% + 1px); height: 3px; @@ -80,21 +86,16 @@ const Wrapper = styled.div` } > button { - height: 40px; + height: 54px; padding: 0px 15px; - line-height: 40px; &:hover, &:focus, &:active { background-color: #fafafb !important; border-radius: 0px; cursor: pointer; + outline: 0; } - } - - > button { - height: 44px; - line-height: 48px; &:hover, &:active { color: #333740; diff --git a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js index cff7b2009e..ffbf9af3f0 100644 --- a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js +++ b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js @@ -2,24 +2,27 @@ import styled from 'styled-components'; import { Button } from 'reactstrap'; const StyledButtonSecondary = styled(Button)` + position: relative; + height: 3rem; font-family: Lato; - color: #f64d0a; - border: 0.1rem solid #f64d0a; + border-radius: 3px; padding-left: 1.5rem; padding-right: 1.5rem; cursor: pointer; background-color: transparent; + border: 0.1rem solid #f64d0a; + color: #f64d0a; + &:hover, - &:active { - color: #f64d0a; + &:active, + &.btn-secondary:not(:disabled):not(.disabled):active, + &.btn-secondary:not(:disabled):not(.disabled):focus, + &.btn-secondary:not(:disabled):not(.disabled):focus:active, + &.btn-secondary:hover { + color: #f64d0a !important; background-color: white; border: 0.1rem solid #f64d0a; } - height: 3rem; - color: #f64d0a; - border: 0.1rem solid #f64d0a; - position: relative; - border-radius: 3px; `; export default StyledButtonSecondary; diff --git a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js index 2e3b003271..9128496cdd 100644 --- a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js +++ b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js @@ -32,8 +32,12 @@ const StyledButtonModalSuccess = styled(Button)` height: 7px; } &:hover, - &:active { - color: ${colors.green}; + &:active, + &.btn-secondary:not(:disabled):not(.disabled):active, + &.btn-secondary:not(:disabled):not(.disabled):focus, + &.btn-secondary:not(:disabled):not(.disabled):focus:active, + &.btn-secondary:hover { + color: ${colors.green} !important; background-color: white; border: 0.1rem solid ${colors.green}; } diff --git a/packages/strapi-helper-plugin/lib/src/components/HeaderNav/Wrapper.js b/packages/strapi-helper-plugin/lib/src/components/HeaderNav/Wrapper.js index 0749f78554..175a3880c3 100644 --- a/packages/strapi-helper-plugin/lib/src/components/HeaderNav/Wrapper.js +++ b/packages/strapi-helper-plugin/lib/src/components/HeaderNav/Wrapper.js @@ -31,11 +31,9 @@ const Wrapper = styled.div` font-size: 1.3rem; color: #333740 !important; line-height: 1.6rem; - } - .linkActive { - z-index: 10; - &:not(:first-child, :last-child) { + &.linkActive { + z-index: 10; background-color: #ffffff !important; font-weight: bold; text-decoration: none !important; @@ -44,30 +42,6 @@ const Wrapper = styled.div` } } - .linkActive:first-child { - background-color: #ffffff !important; - font-weight: bold; - text-decoration: none !important; - box-shadow: 0 0 2px rgba(#dbdbdb, 0.5); - border-top: 0.2rem solid #1c5de7; - } - - .linkActive:last-child { - background-color: #ffffff !important; - font-weight: bold; - text-decoration: none !important; - box-shadow: 0 0 2px rgba(#dbdbdb, 0.5); - border-top: 0.2rem solid #1c5de7; - } - - .linkActive:not(:first-child, :last-child) { - background-color: #ffffff !important; - font-weight: bold; - text-decoration: none !important; - box-shadow: 0 0 2px rgba(#dbdbdb, 0.5); - border-top: 0.2rem solid #1c5de7; - } - .linkText { display: flex; margin: auto; diff --git a/packages/strapi-plugin-content-manager/admin/src/components/Group/components.js b/packages/strapi-plugin-content-manager/admin/src/components/Group/components.js index 0671daf4ea..d40bbff371 100644 --- a/packages/strapi-plugin-content-manager/admin/src/components/Group/components.js +++ b/packages/strapi-plugin-content-manager/admin/src/components/Group/components.js @@ -39,6 +39,7 @@ const FormWrapper = styled.div` padding-top: 27px; padding-left: 20px; padding-right: 20px; + padding-bottom: 8px; border-top: 1px solid ${({ hasErrors, isOpen }) => { if (hasErrors) { diff --git a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/Components.js b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/Components.js index a199b1538b..9339cd6ec4 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/Components.js +++ b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/Components.js @@ -1,143 +1,7 @@ import styled from 'styled-components'; const Wrapper = styled.div` - .modalHeader { - margin: 0 2.9rem; - padding: 1.4rem 0 2.8rem 0; - border-bottom: 1px solid #f6f6f6; - position: relative; - > button { - margin-right: -2.5rem !important; - color: #c3c5c8; - opacity: 1; - font-size: 1.8rem; - font-weight: 100; - z-index: 999; - &:hover, - &:focus { - color: #c3c5c8; - opacity: 1; - outline: 0 !important; - } - > span { - display: none; - } - &:before { - -webkit-font-smoothing: antialiased; - content: '\F00d'; - font-family: 'FontAwesome'; - font-weight: 400; - font-size: 1.2rem; - margin-right: 10px; - } - } - } - - .modalBody { - padding: 2.2rem 1.4rem 0 1.4rem; - } - - .modalFooter { - padding: 1.2rem 1rem 2.8rem 1rem; - border: none; - > button { - height: 3rem; - position: relative; - border-radius: 0.3rem; - text-transform: capitalize; - margin-right: 1.8rem; - cursor: pointer; - font-family: Lato; - &:focus { - outline: 0; - } - > i { - margin-right: 1.3rem; - } - &:hover { - &::after { - position: absolute; - width: 100%; - height: 100%; - top: 0; - left: 0; - border-radius: 0.3rem; - content: ''; - opacity: 0.1; - background: #ffffff; - } - } - &.primary { - width: 15rem; - height: 3rem; - margin-left: 1.9rem !important; - cursor: pointer; - font-family: Lato; - border: none !important; - font-family: Lato !important; - line-height: 1.6rem; - font-weight: 600; - border-radius: 3px; - background: linear-gradient(315deg, #0097f6 0%, #005eea 100%); - -webkit-font-smoothing: antialiased; - color: white !important; - &:hover, - &:active { - border: none !important; - background: linear-gradient(315deg, #0097f6 0%, #005eea 100%); - color: white; - } - &:focus { - outline: 0; - } - } - &.secondary { - position: relative; - min-width: 100px; - height: 3rem; - cursor: pointer; - background-color: transparent; - border: 0.1rem solid #f64d0a; - border-radius: 3px; - color: #f64d0a; - font-family: Lato; - &:hover, - &:active { - color: #f64d0a; - background-color: white; - border: 0.1rem solid #f64d0a; - } - } - } - } + padding-bottom: 20px; `; -const Header = styled.div` - position: absolute; - top: 0; - width: 100%; - display: flex; - padding: 1.6rem 2.9rem 0 2.9rem; - font-size: 1.8rem; - font-weight: bold; -`; - -const ProviderContainer = styled.div` - > div { - &:last-child { - > input { - &:disabled { - background-color: #fafafb !important; - } - } - } - } -`; - -const Separator = styled.div` - width: 100%; - margin: 14px 15px 20px 15px; - border-bottom: 2px solid #f6f6f6; -`; - -export { Header, ProviderContainer, Separator, Wrapper }; +export { Wrapper }; diff --git a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js index fb5c7e2385..6f69c3fe89 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js +++ b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js @@ -272,7 +272,11 @@ class PopUpForm extends React.Component { type={includes(value, 'object') ? 'text' : 'textarea'} validations={{ required: true }} value={get(values, value)} - inputStyle={!includes(value, 'object') ? { height: '16rem' } : {}} + inputStyle={ + !includes(value, 'object') + ? { height: '16rem', marginBottom: '-0.8rem' } + : {} + } /> ))} From e8ebc717558d6099e7dc53b81fd776e8824be649 Mon Sep 17 00:00:00 2001 From: soupette Date: Fri, 11 Oct 2019 15:16:06 +0200 Subject: [PATCH 3/6] Change deps --- packages/strapi-admin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 8565cf6a14..d3f14896df 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -28,6 +28,7 @@ "bootstrap": "^4.3.1", "chalk": "^2.4.2", "classnames": "^2.2.6", + "compression-webpack-plugin": "^3.0.0", "cross-env": "^5.0.5", "css-loader": "^2.1.1", "duplicate-package-checker-webpack-plugin": "^3.0.0", @@ -105,7 +106,6 @@ "gitHead": "c85658a19b8fef0f3164c19693a45db305dc07a9", "devDependencies": { "chokidar": "^3.1.1", - "compression-webpack-plugin": "^3.0.0", "webpack": "^4.40.1", "webpack-cli": "^3.3.2", "webpack-dev-server": "^3.4.1" From 20e7e9fcc3aed14c13a95fccac8f1f1101d11c08 Mon Sep 17 00:00:00 2001 From: soupette Date: Mon, 14 Oct 2019 08:32:37 +0200 Subject: [PATCH 4/6] Fix padding --- .../lib/src/components/ButtonModal/StyledButtonSecondary.js | 4 ++-- .../lib/src/components/ButtonModal/StyledButtonSuccess.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js index 6200a118f4..74ba496161 100644 --- a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js +++ b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSecondary.js @@ -6,8 +6,8 @@ const StyledButtonSecondary = styled(Button)` height: 3rem; font-family: Lato; border-radius: 3px; - padding-left: 1.5rem; - padding-right: 1.5rem; + padding-left: 1.5rem !important; + padding-right: 1.5rem !important; cursor: pointer; font-family: Lato; color: #f64d0a; diff --git a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js index 3f7aea61d8..70eb6eb03a 100644 --- a/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js +++ b/packages/strapi-helper-plugin/lib/src/components/ButtonModal/StyledButtonSuccess.js @@ -7,8 +7,8 @@ import colors from '../../assets/styles/colors'; const StyledButtonModalSuccess = styled(Button)` position: relative; height: 3rem; - padding-left: 1.5rem; - padding-right: 1.5rem; + padding-left: 1.5rem !important; + padding-right: 1.5rem !important; font-family: Lato; color: ${colors.green}; border: 0.1rem solid ${colors.green}; From 9b0dda7e72e9ac2dda3377f7c782fd96dbe8d0b3 Mon Sep 17 00:00:00 2001 From: soupette Date: Tue, 15 Oct 2019 12:05:08 +0200 Subject: [PATCH 5/6] Fix PR feedback --- packages/strapi-admin/index.js | 75 +++++++++++-------- .../files/admin/src/containers/App/index.js | 41 ---------- 2 files changed, 45 insertions(+), 71 deletions(-) diff --git a/packages/strapi-admin/index.js b/packages/strapi-admin/index.js index e5923f5d43..d217c18393 100644 --- a/packages/strapi-admin/index.js +++ b/packages/strapi-admin/index.js @@ -10,38 +10,45 @@ const chokidar = require('chokidar'); const getPkgPath = name => path.dirname(require.resolve(`${name}/package.json`)); -async function createPluginsJs(plugins, dest) { +async function createPluginsJs(plugins, localPlugins, dest) { const content = ` - const injectReducer = require('./utils/injectReducer').default; - const injectSaga = require('./utils/injectSaga').default; - const useInjectReducer = require('./utils/injectReducer').useInjectReducer; - const useInjectSaga = require('./utils/injectSaga').useInjectSaga; - const { languages } = require('./i18n'); +const injectReducer = require('./utils/injectReducer').default; +const injectSaga = require('./utils/injectSaga').default; +const useInjectReducer = require('./utils/injectReducer').useInjectReducer; +const useInjectSaga = require('./utils/injectSaga').useInjectSaga; +const { languages } = require('./i18n'); - window.strapi = Object.assign(window.strapi || {}, { - node: MODE || 'host', - backendURL: BACKEND_URL === '/' ? window.location.origin : BACKEND_URL, - languages, - currentLanguage: - window.localStorage.getItem('strapi-admin-language') || - window.navigator.language || - window.navigator.userLanguage || - 'en', - injectReducer, - injectSaga, - useInjectReducer, - useInjectSaga, - }); +window.strapi = Object.assign(window.strapi || {}, { + node: MODE || 'host', + backendURL: BACKEND_URL === '/' ? window.location.origin : BACKEND_URL, + languages, + currentLanguage: + window.localStorage.getItem('strapi-admin-language') || + window.navigator.language || + window.navigator.userLanguage || + 'en', + injectReducer, + injectSaga, + useInjectReducer, + useInjectSaga, +}); - module.exports = { - ${plugins - .map(name => { - const shortName = name.replace(/^strapi-plugin-/i, ''); - const req = `require('../../plugins/${name}/admin/src').default`; - return `'${shortName}': ${req}`; - }) - .join(',\n')} - } +module.exports = { + ${plugins + .map(name => { + const shortName = name.replace(/^strapi-plugin-/i, ''); + const req = `require('../../plugins/${name}/admin/src').default`; + return `'${shortName}': ${req},`; + }) + .join('\n')} + ${localPlugins + .map(name => { + const shortName = name.replace(/^strapi-plugin-/i, ''); + const req = `require('../../../plugins/${name}/admin/src').default`; + return `'${shortName}': ${req}`; + }) + .join(',\n')} +} `; return fs.writeFile( @@ -98,6 +105,14 @@ async function createCacheDir(dir) { fs.existsSync(path.resolve(getPkgPath(dep), 'admin', 'src', 'index.js')) ); + const localPluginsToCopy = fs + .readdirSync(path.join(dir, 'plugins')) + .filter(plugin => + fs.existsSync( + path.resolve(dir, 'plugins', plugin, 'admin', 'src', 'index.js') + ) + ); + // TODO: add logic to avoid copying files if not necessary // create .cache dir @@ -110,7 +125,7 @@ async function createCacheDir(dir) { await Promise.all(pluginsToCopy.map(name => copyPlugin(name, cacheDir))); // create plugins.js with plugins requires - await createPluginsJs(pluginsToCopy, cacheDir); + await createPluginsJs(pluginsToCopy, localPluginsToCopy, cacheDir); // override admin code with user customizations if (fs.pathExistsSync(path.join(dir, 'admin'))) { diff --git a/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js b/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js index 290b4abe15..819d0341cc 100644 --- a/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js +++ b/packages/strapi-generate-plugin/files/admin/src/containers/App/index.js @@ -1,44 +1,3 @@ -///////////////////////////////////////////////////// -// DISPLAY YOUR PLUGIN IN THE ADMINISTRATION PANEL // -///////////////////////////////////////////////////// -/* -1. Check the installed plugin in your package.json you will need to require them manually -2. Copy the following code in my-app/admin/src/plugins.js (don't forget to add the other installed plugins) - -``` -const injectReducer = require('./utils/injectReducer').default; -const useInjectReducer = require('./utils/injectReducer').useInjectReducer; -const injectSaga = require('./utils/injectSaga').default; -const useInjectSaga = require('./utils/injectSaga').useInjectSaga; -const { languages } = require('./i18n'); - -window.strapi = Object.assign(window.strapi || {}, { - node: MODE || 'host', - env: NODE_ENV, - backendURL: BACKEND_URL === '/' ? window.location.origin : BACKEND_URL, - languages, - currentLanguage: - window.localStorage.getItem('strapi-admin-language') || - window.navigator.language || - window.navigator.userLanguage || - 'en', - injectReducer, - injectSaga, - useInjectReducer, - useInjectSaga, -}); - -module.exports = { - 'strapi-plugin-users-permissions': require('../../plugins/strapi-plugin-users-permissions/admin/src') - .default, - // Add the other plugins here - // ..., - // Add your newly created plugin here (the path is different than the others) - 'my-plugin': require('../../../plugins/my-plugin/admin/src').default, -}; -``` -*/ - /** * * This component is the skeleton around the actual pages, and should only From 5a79208f869c38adcc04084fbddc96bdf4a58e72 Mon Sep 17 00:00:00 2001 From: soupette Date: Tue, 15 Oct 2019 12:07:27 +0200 Subject: [PATCH 6/6] Remove compression plugin --- packages/strapi-admin/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 43fa259557..8ab9949b72 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -29,7 +29,6 @@ "chalk": "^2.4.2", "chokidar": "^3.2.1", "classnames": "^2.2.6", - "compression-webpack-plugin": "^3.0.0", "cross-env": "^5.0.5", "css-loader": "^2.1.1", "duplicate-package-checker-webpack-plugin": "^3.0.0",