mirror of
https://github.com/strapi/strapi.git
synced 2025-08-28 10:45:51 +00:00
Use one webpack server to serve admin in development mode
This commit is contained in:
parent
51d936b559
commit
62f96e5c07
@ -8,6 +8,8 @@ import 'babel-polyfill';
|
||||
|
||||
// Import all the third party stuff
|
||||
import { Provider } from 'react-redux';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { ConnectedRouter } from 'react-router-redux';
|
||||
import createHistory from 'history/createBrowserHistory';
|
||||
import { merge, isFunction } from 'lodash';
|
||||
@ -20,7 +22,6 @@ import App from 'containers/App';
|
||||
import { showNotification } from 'containers/NotificationProvider/actions';
|
||||
import { pluginLoaded, updatePlugin } from 'containers/App/actions';
|
||||
|
||||
import { plugins } from '../../config/admin.json';
|
||||
import configureStore from './store';
|
||||
import { translationMessages, languages } from './i18n';
|
||||
|
||||
@ -129,23 +130,6 @@ window.Strapi = {
|
||||
languages,
|
||||
};
|
||||
|
||||
// Ping each plugins port defined in configuration
|
||||
if (window.location.hostname === 'localhost') {
|
||||
plugins.ports.forEach(pluginPort => {
|
||||
// Define plugin url
|
||||
const pluginUrl = `http://localhost:${pluginPort}/main.js`;
|
||||
|
||||
// Check that the server in running
|
||||
fetch(pluginUrl)
|
||||
.then(() => {
|
||||
// Inject `script` tag in DOM
|
||||
const script = window.document.createElement('script');
|
||||
script.src = pluginUrl;
|
||||
window.document.body.appendChild(script);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const dispatch = store.dispatch;
|
||||
export {
|
||||
dispatch,
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import styles from './styles.scss';
|
||||
|
||||
class Header extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||
|
||||
import LocaleToggle from 'containers/LocaleToggle';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
@ -4,7 +4,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { startsWith } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Link } from 'react-router-dom';
|
||||
@ -15,7 +16,7 @@ class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer
|
||||
render() {
|
||||
// We need to create our own active url checker,
|
||||
// because of the two levels router.
|
||||
const isLinkActive = _.startsWith(window.location.pathname.replace('/admin', ''), this.props.destination);
|
||||
const isLinkActive = startsWith(window.location.pathname.replace('/admin', ''), this.props.destination);
|
||||
|
||||
return (
|
||||
<li className={styles.item}>
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { map } from 'lodash';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
|
@ -4,13 +4,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
||||
|
||||
import Notification from 'components/Notification';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
||||
const { CSSTransition, TransitionGroup } = ReactTransitionGroup;
|
||||
|
||||
class NotificationsContainer extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
render() {
|
||||
if (this.props.notifications.length === 0) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import ToggleOption from 'components/ToggleOption';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape } from 'react-intl';
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
* the linting exception.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
|
@ -11,6 +11,7 @@
|
||||
* the linting exception.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Helmet from 'react-helmet';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
@ -6,6 +6,7 @@
|
||||
* IntlProvider component and i18n messages (loaded from `app/translations`)
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
@ -9,6 +9,7 @@
|
||||
* the linting exception.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
@ -12,7 +13,6 @@ import NotificationsContainer from 'components/NotificationsContainer';
|
||||
import { selectNotifications } from './selectors';
|
||||
import { hideNotification } from './actions';
|
||||
|
||||
|
||||
export class NotificationProvider extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
render() {
|
||||
return (
|
||||
|
@ -3,7 +3,8 @@
|
||||
* PluginPage
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import Helmet from 'react-helmet';
|
||||
|
@ -12,9 +12,5 @@
|
||||
<!-- The app hooks into this div -->
|
||||
<div id="app"></div>
|
||||
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-with-addons.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-transition-group/2.2.0/react-transition-group.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
"plop": "^1.8.1",
|
||||
"prettier": "^1.7.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"strapi-helper-plugin": "file:../strapi-helper-plugin",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.5.5",
|
||||
"webpack": "^3.6.0"
|
||||
},
|
||||
"author": {
|
||||
@ -66,4 +66,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"fs-extra": "^4.0.1",
|
||||
"lodash": "^4.17.4",
|
||||
"strapi-admin": "file:../strapi-admin"
|
||||
"strapi-admin": "3.0.0-alpha.5.5"
|
||||
},
|
||||
"author": {
|
||||
"email": "hi@strapi.io",
|
||||
@ -41,4 +41,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
"fs-extra": "^4.0.0",
|
||||
"get-installed-path": "^3.0.1",
|
||||
"lodash": "^4.17.4",
|
||||
"strapi-utils": "file:../strapi-utils"
|
||||
"strapi-utils": "3.0.0-alpha.5.5"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "npm prune"
|
||||
@ -46,4 +46,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
"fs-extra": "^4.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"reportback": "^2.0.1",
|
||||
"strapi-utils": "file:../strapi-utils"
|
||||
"strapi-utils": "3.0.0-alpha.5.5"
|
||||
},
|
||||
"author": {
|
||||
"name": "Strapi team",
|
||||
@ -43,4 +43,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
* COMMON WEBPACK CONFIGURATION
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const webpack = require('webpack');
|
||||
@ -9,18 +10,26 @@ const webpack = require('webpack');
|
||||
const pkg = require(path.resolve(process.cwd(), 'package.json'));
|
||||
const pluginId = pkg.name.replace(/^strapi-/i, '');
|
||||
|
||||
const plugins = process.env.IS_ADMIN === 'true' ? fs.readdirSync(path.resolve(process.env.PWD, '..', 'plugins'))
|
||||
.filter(x => x[0] !== '.') : [];
|
||||
|
||||
const pluginFolders = plugins.reduce((acc, current) => {
|
||||
acc[current] = path.resolve(process.env.PWD, '..', 'plugins', current, 'node_modules', 'strapi-helper-plugin', 'lib', 'src');
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
module.exports = (options) => ({
|
||||
entry: options.entry,
|
||||
entry: Object.assign(options.entry, plugins.reduce((acc, current) => {
|
||||
acc[current] = path.resolve(pluginFolders[current], 'app.js');
|
||||
|
||||
return acc;
|
||||
}, {})),
|
||||
output: Object.assign({ // Compile into js/build.js
|
||||
path: path.resolve(process.cwd(), 'admin', 'build'),
|
||||
publicPath: '/',
|
||||
}, options.output), // Merge with env dependent settings
|
||||
module: {
|
||||
// Comment
|
||||
noParse: [
|
||||
/\/react\//g,
|
||||
/\/react-dom\//g,
|
||||
],
|
||||
loaders: [{
|
||||
test: /\.js$/, // Transform all .js files required somewhere with Babel,
|
||||
use: {
|
||||
@ -46,11 +55,13 @@ module.exports = (options) => ({
|
||||
},
|
||||
},
|
||||
},
|
||||
include: [
|
||||
path.join(process.cwd(), 'admin', 'src'),
|
||||
// Add the `strapi-helper-plugin` folders watched by babel
|
||||
path.join(process.cwd(), 'node_modules', 'strapi-helper-plugin', 'lib', 'src'),
|
||||
],
|
||||
include: [path.join(process.cwd(), 'admin', 'src')]
|
||||
.concat(plugins.reduce((acc, current) => {
|
||||
acc.push(path.resolve(process.env.PWD, '..', 'plugins', current, 'admin', 'src'), pluginFolders[current]);
|
||||
|
||||
return acc;
|
||||
}, []))
|
||||
.concat([path.join(process.cwd(), 'node_modules', 'strapi-helper-plugin', 'lib', 'src')])
|
||||
}, {
|
||||
// Transform our own .scss files
|
||||
test: /\.scss$/,
|
||||
@ -145,9 +156,6 @@ module.exports = (options) => ({
|
||||
],
|
||||
alias: {
|
||||
moment: 'moment/moment.js',
|
||||
'react': 'react',
|
||||
'react-dom': 'react-dom',
|
||||
'react-transition-group': 'react-transition-group',
|
||||
},
|
||||
symlinks: false,
|
||||
extensions: [
|
||||
@ -161,7 +169,7 @@ module.exports = (options) => ({
|
||||
'main',
|
||||
],
|
||||
},
|
||||
externals: generateExternals(),
|
||||
externals: {},
|
||||
resolveLoader: {
|
||||
modules: [
|
||||
path.join(__dirname, '..', '..', '..', 'node_modules'),
|
||||
@ -169,13 +177,5 @@ module.exports = (options) => ({
|
||||
],
|
||||
},
|
||||
devtool: options.devtool,
|
||||
target: 'web', // Make web variables accessible to webpack, e.g. window
|
||||
target: 'web', // Make web variables accessible to webpack, e.g. window,
|
||||
});
|
||||
|
||||
function generateExternals() {
|
||||
return {
|
||||
'react': 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
'react-transition-group': 'ReactTransitionGroup',
|
||||
};
|
||||
}
|
||||
|
@ -11,24 +11,29 @@ const argv = require('minimist')(process.argv.slice(2));
|
||||
const cssnext = require('postcss-cssnext');
|
||||
const postcssFocus = require('postcss-focus');
|
||||
const postcssReporter = require('postcss-reporter');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
|
||||
const plugins = [
|
||||
new webpack.HotModuleReplacementPlugin(), // Tell webpack we want hot reloading
|
||||
// new BundleAnalyzerPlugin(),
|
||||
];
|
||||
|
||||
const isAdmin = process.env.IS_ADMIN === 'true';
|
||||
|
||||
// Build the `index.htm file`
|
||||
if (isAdmin) {
|
||||
plugins.push(new HtmlWebpackPlugin({
|
||||
// Build the `index.html file`
|
||||
plugins.push(
|
||||
new HtmlWebpackPlugin({
|
||||
favicon: 'admin/src/favicon.ico',
|
||||
inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
|
||||
templateContent: templateContent(), // eslint-disable-line no-use-before-define
|
||||
}));
|
||||
}
|
||||
chunksSortMode: 'auto',
|
||||
}),
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
minChunks: 2, // Ensure there is only the defined dependencies.
|
||||
})
|
||||
);
|
||||
|
||||
const appPath = isAdmin
|
||||
? path.join(process.cwd(), 'admin', 'src', 'app.js')
|
||||
: path.join(process.cwd(), 'node_modules', 'strapi-helper-plugin', 'lib', 'src', 'app.js');
|
||||
|
||||
const appPath = path.join(process.cwd(), 'admin', 'src', 'app.js')
|
||||
|
||||
const logger = require('../../server/logger');
|
||||
|
||||
@ -38,10 +43,12 @@ const port = argv.port || process.env.PORT || 3000;
|
||||
|
||||
module.exports = require('./webpack.base.babel')({
|
||||
// Add hot reloading in development
|
||||
entry: [
|
||||
`webpack-hot-middleware/client?path=http://localhost:${port}/__webpack_hmr`,
|
||||
appPath,
|
||||
],
|
||||
entry: {
|
||||
main: [
|
||||
`webpack-hot-middleware/client?path=http://localhost:${port}/__webpack_hmr`,
|
||||
appPath,
|
||||
]
|
||||
},
|
||||
|
||||
// Don't use hashes in dev mode for better performance
|
||||
output: {
|
||||
@ -51,7 +58,7 @@ module.exports = require('./webpack.base.babel')({
|
||||
},
|
||||
|
||||
// Add development plugins
|
||||
plugins: dependencyHandlers().concat(plugins), // eslint-disable-line no-use-before-define,
|
||||
plugins: plugins, // eslint-disable-line no-use-before-define,
|
||||
|
||||
// Process the CSS with PostCSS
|
||||
postcssPlugins: [
|
||||
@ -102,7 +109,7 @@ function dependencyHandlers() {
|
||||
if (!dllPlugin) {
|
||||
return [
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
name: 'commons',
|
||||
children: true,
|
||||
minChunks: 2,
|
||||
async: true,
|
||||
|
@ -18,7 +18,6 @@ const plugins = [
|
||||
name: 'vendor',
|
||||
children: true,
|
||||
minChunks: 2,
|
||||
async: true,
|
||||
}),
|
||||
|
||||
// Minify and optimize the JavaScript
|
||||
@ -45,6 +44,7 @@ if (isAdmin) {
|
||||
minifyCSS: true,
|
||||
minifyURLs: true,
|
||||
},
|
||||
chunksSortMode: 'auto',
|
||||
inject: true,
|
||||
}));
|
||||
plugins.push(new ExtractTextPlugin('[name].[contenthash].css'));
|
||||
|
@ -15,7 +15,7 @@ const addDevMiddlewares = (app, webpackConfig) => {
|
||||
stats: 'errors-only',
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
app.use(middleware);
|
||||
|
@ -5,6 +5,7 @@
|
||||
* only setup and plugin code.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import App, { bootstrap } from 'containers/App'; // eslint-disable-line
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import styles from './styles.scss';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, isEmpty, map, mapKeys, isObject, reject, includes } from 'lodash';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import PluginHeaderTitle from 'components/PluginHeaderTitle';
|
||||
import PluginHeaderActions from 'components/PluginHeaderActions';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import Button from 'components/Button';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
// modal
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
|
||||
|
@ -88,16 +88,17 @@
|
||||
"postcss-smart-import": "^0.7.5",
|
||||
"precss": "^2.0.0",
|
||||
"prettier": "^1.5.3",
|
||||
"react": "^15.6.1",
|
||||
"react": "^15.6.2",
|
||||
"react-css-transition": "^0.7.4",
|
||||
"react-datetime": "^2.8.6",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-dom": "^15.6.2",
|
||||
"react-helmet": "^5.1.3",
|
||||
"react-intl": "^2.3.0",
|
||||
"react-redux": "^5.0.6",
|
||||
"react-router-dom": "^4.1.2",
|
||||
"react-router-redux": "^5.0.0-alpha.6",
|
||||
"react-transition-group": "1.1.2",
|
||||
"reactstrap": "^4.8.0",
|
||||
"reactstrap": "^5.0.0-alpha.1",
|
||||
"redux": "^3.7.2",
|
||||
"redux-immutable": "^4.0.0",
|
||||
"redux-saga": "^0.15.6",
|
||||
@ -113,5 +114,7 @@
|
||||
"webpack-hot-middleware": "^2.18.2",
|
||||
"whatwg-fetch": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
"devDependencies": {
|
||||
"webpack-bundle-analyzer": "^2.9.0"
|
||||
}
|
||||
}
|
@ -248,8 +248,6 @@ module.exports = function (strapi) {
|
||||
case 'belongsTo':
|
||||
FK = _.find(definition.associations, {alias: name});
|
||||
|
||||
console.log(name, FK);
|
||||
|
||||
if (FK && FK.nature !== 'oneToOne' && FK.nature !== 'oneToMany') {
|
||||
definition.loadedModel[name] = {
|
||||
type: 'virtual',
|
||||
|
@ -20,7 +20,7 @@
|
||||
"mongoose-double": "0.0.1",
|
||||
"mongoose-float": "^1.0.2",
|
||||
"pluralize": "^6.0.0",
|
||||
"strapi-utils": "file:../strapi-utils"
|
||||
"strapi-utils": "3.0.0-alpha.5.5"
|
||||
},
|
||||
"strapi": {
|
||||
"isHook": true
|
||||
@ -49,4 +49,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
class Container extends React.Component {
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
// Dependencies.
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { findIndex, get, omit, isFunction, merge } from 'lodash';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { map } from 'lodash';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { map } from 'lodash';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { map } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Select from 'react-select';
|
||||
import PropTypes from 'prop-types';
|
||||
import 'react-select/dist/react-select.css';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Select from 'react-select';
|
||||
import PropTypes from 'prop-types';
|
||||
import 'react-select/dist/react-select.css';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import TableHeader from '../TableHeader';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import LimitSelect from '../LimitSelect';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
import PropTypes from 'prop-types';
|
||||
import _ from 'lodash';
|
||||
import { isEmpty, get } from 'lodash';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
|
||||
import injectSaga from 'utils/injectSaga';
|
||||
@ -46,7 +47,7 @@ class App extends React.Component {
|
||||
componentDidMount() {
|
||||
const config = tryRequire('../../../../config/admin.json');
|
||||
|
||||
if (!_.isEmpty(_.get(config, 'admin.schema'))) {
|
||||
if (!isEmpty(get(config, 'admin.schema'))) {
|
||||
this.props.updateSchema(config.admin.schema);
|
||||
} else {
|
||||
this.props.loadModels();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import { map } from 'lodash';
|
||||
import { fork, put, select, call, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
import request from 'utils/request';
|
||||
@ -16,7 +16,7 @@ export const generateMenu = function () {
|
||||
.then(displayedModels => {
|
||||
return [{
|
||||
name: 'Content Types',
|
||||
links: _.map(displayedModels, (model, key) => ({
|
||||
links: map(displayedModels, (model, key) => ({
|
||||
label: model.labelPlural || model.label || key,
|
||||
destination: key,
|
||||
})),
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
// Dependencies.
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Home
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
@ -11,7 +12,7 @@ import PluginHeader from 'components/PluginHeader';
|
||||
import styles from './styles.scss';
|
||||
|
||||
export class Home extends React.Component {
|
||||
render() {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div className={`container-fluid ${styles.containerFluid}`}>
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
|
@ -9,6 +9,7 @@
|
||||
* the linting exception.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export default class NotFound extends React.Component {
|
||||
|
@ -62,7 +62,7 @@
|
||||
"plop": "^1.8.1",
|
||||
"prettier": "^1.7.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"strapi-helper-plugin": "file:../strapi-helper-plugin",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.5.5",
|
||||
"webpack": "^3.6.0"
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@
|
||||
"plop": "^1.8.1",
|
||||
"prettier": "^1.7.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"strapi-helper-plugin": "file:../strapi-helper-plugin",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.5.5",
|
||||
"webpack": "^3.6.0"
|
||||
},
|
||||
"author": {
|
||||
@ -71,4 +71,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import 'whatwg-fetch';
|
||||
import _ from 'lodash';
|
||||
import { startsWith } from 'lodash';
|
||||
|
||||
/**
|
||||
* Parses the JSON returned by a network request
|
||||
@ -62,7 +62,7 @@ export default function request(url, options) {
|
||||
};
|
||||
|
||||
// Add parameters to url
|
||||
let urlFormatted = _.startsWith(url, '/')
|
||||
let urlFormatted = startsWith(url, '/')
|
||||
? `${Strapi.apiUrl}${url}`
|
||||
: url;
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
"plop": "^1.8.1",
|
||||
"prettier": "^1.7.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"strapi-helper-plugin": "file:../strapi-helper-plugin",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.5.5",
|
||||
"webpack": "^3.6.0"
|
||||
},
|
||||
"author": {
|
||||
@ -68,4 +68,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -45,4 +45,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
@ -52,13 +52,13 @@
|
||||
"node-schedule": "^1.2.0",
|
||||
"semver": "^5.4.1",
|
||||
"stack-trace": "0.0.10",
|
||||
"strapi-generate": "file:../strapi-generate",
|
||||
"strapi-generate-admin": "file:../strapi-generate-admin",
|
||||
"strapi-generate-api": "file:../strapi-generate-api",
|
||||
"strapi-generate-new": "file:../strapi-generate-new",
|
||||
"strapi-generate-policy": "file:../strapi-generate-policy",
|
||||
"strapi-generate-service": "file:../strapi-generate-service",
|
||||
"strapi-utils": "file:../strapi-utils"
|
||||
"strapi-generate": "3.0.0-alpha.5.5",
|
||||
"strapi-generate-admin": "3.0.0-alpha.5.5",
|
||||
"strapi-generate-api": "3.0.0-alpha.5.5",
|
||||
"strapi-generate-new": "3.0.0-alpha.5.5",
|
||||
"strapi-generate-policy": "3.0.0-alpha.5.5",
|
||||
"strapi-generate-service": "3.0.0-alpha.5.5",
|
||||
"strapi-utils": "3.0.0-alpha.5.5"
|
||||
},
|
||||
"author": {
|
||||
"email": "hi@strapi.io",
|
||||
@ -85,4 +85,4 @@
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user