mirror of
https://github.com/strapi/strapi.git
synced 2025-11-25 14:41:15 +00:00
Update branch
Merge branch 'alpha.6' of github.com:strapi/strapi into improvement/inject-content-types
This commit is contained in:
commit
726bab8aa1
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// Public node modules.
|
// Public node modules.
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const mongoose = require('mongoose');
|
const Mongoose = require('mongoose').Mongoose;
|
||||||
const mongooseUtils = require('mongoose/lib/utils');
|
const mongooseUtils = require('mongoose/lib/utils');
|
||||||
|
|
||||||
// Local helpers.
|
// Local helpers.
|
||||||
@ -46,23 +46,22 @@ module.exports = function (strapi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => {
|
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => {
|
||||||
|
const instance = new Mongoose();
|
||||||
const {host, port, username, password, database} = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
const {host, port, username, password, database} = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
||||||
|
|
||||||
// Connect to mongo database
|
// Connect to mongo database
|
||||||
if (_.isEmpty(username) || _.isEmpty(password)) {
|
if (_.isEmpty(username) || _.isEmpty(password)) {
|
||||||
mongoose.connect(`mongodb://${host}:${port}/${database}`, {
|
instance.connect(`mongodb://${host}:${port}/${database}`, {
|
||||||
useMongoClient: true
|
useMongoClient: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mongoose.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`, {
|
instance.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`, {
|
||||||
useMongoClient: true
|
useMongoClient: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = mongoose.connection;
|
|
||||||
|
|
||||||
// Handle error
|
// Handle error
|
||||||
db.on('error', error => {
|
instance.connection.on('error', error => {
|
||||||
if (error.message.indexOf(`:${port}`)) {
|
if (error.message.indexOf(`:${port}`)) {
|
||||||
return cb('Make sure your MongoDB database is running...');
|
return cb('Make sure your MongoDB database is running...');
|
||||||
}
|
}
|
||||||
@ -71,9 +70,9 @@ module.exports = function (strapi) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle success
|
// Handle success
|
||||||
db.on('open', () => {
|
instance.connection.on('open', () => {
|
||||||
// Select models concerned by this connection
|
// Select models concerned by this connection
|
||||||
const models = _.pickBy(strapi.models, {connection: connectionName});
|
const models = _.pickBy(strapi.models, { connection: connectionName });
|
||||||
|
|
||||||
// Return callback if there is no model
|
// Return callback if there is no model
|
||||||
if (_.isEmpty(models)) {
|
if (_.isEmpty(models)) {
|
||||||
@ -139,10 +138,10 @@ module.exports = function (strapi) {
|
|||||||
virtuals: true
|
virtuals: true
|
||||||
});
|
});
|
||||||
|
|
||||||
global[definition.globalName] = mongoose.model(definition.globalName, collection.schema);
|
global[definition.globalName] = instance.model(definition.globalName, collection.schema);
|
||||||
|
|
||||||
// Expose ORM functions through the `strapi.models` object.
|
// Expose ORM functions through the `strapi.models` object.
|
||||||
strapi.models[model] = _.assign(mongoose.model(definition.globalName), strapi.models[model]);
|
strapi.models[model] = _.assign(instance.model(definition.globalName), strapi.models[model]);
|
||||||
|
|
||||||
// Push model to strapi global variables.
|
// Push model to strapi global variables.
|
||||||
collection = global[definition.globalName];
|
collection = global[definition.globalName];
|
||||||
@ -188,7 +187,7 @@ module.exports = function (strapi) {
|
|||||||
|
|
||||||
if (_.isEmpty(definition.attributes)) {
|
if (_.isEmpty(definition.attributes)) {
|
||||||
// Generate empty schema
|
// Generate empty schema
|
||||||
_.set(strapi.config.hook.settings.mongoose, 'collections.' + mongooseUtils.toCollectionName(definition.globalName) + '.schema', new mongoose.Schema({}));
|
_.set(strapi.config.hook.settings.mongoose, 'collections.' + mongooseUtils.toCollectionName(definition.globalName) + '.schema', new instance.Schema({}));
|
||||||
|
|
||||||
return loadedAttributes();
|
return loadedAttributes();
|
||||||
}
|
}
|
||||||
@ -197,7 +196,7 @@ module.exports = function (strapi) {
|
|||||||
// all attributes for relationships-- see below.
|
// all attributes for relationships-- see below.
|
||||||
const done = _.after(_.size(definition.attributes), () => {
|
const done = _.after(_.size(definition.attributes), () => {
|
||||||
// Generate schema without virtual populate
|
// Generate schema without virtual populate
|
||||||
_.set(strapi.config.hook.settings.mongoose, 'collections.' + mongooseUtils.toCollectionName(definition.globalName) + '.schema', new mongoose.Schema(_.omitBy(definition.loadedModel, model => {
|
_.set(strapi.config.hook.settings.mongoose, 'collections.' + mongooseUtils.toCollectionName(definition.globalName) + '.schema', new instance.Schema(_.omitBy(definition.loadedModel, model => {
|
||||||
return model.type === 'virtual';
|
return model.type === 'virtual';
|
||||||
})));
|
})));
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ module.exports = function (strapi) {
|
|||||||
utilsModels.defineAssociations(model, definition, details, name);
|
utilsModels.defineAssociations(model, definition, details, name);
|
||||||
|
|
||||||
if (_.isEmpty(verbose)) {
|
if (_.isEmpty(verbose)) {
|
||||||
definition.loadedModel[name].type = utils(mongoose).convertType(details.type);
|
definition.loadedModel[name].type = utils(instance).convertType(details.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
let FK;
|
let FK;
|
||||||
@ -221,7 +220,7 @@ module.exports = function (strapi) {
|
|||||||
switch (verbose) {
|
switch (verbose) {
|
||||||
case 'hasOne':
|
case 'hasOne':
|
||||||
definition.loadedModel[name] = {
|
definition.loadedModel[name] = {
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: instance.Schema.Types.ObjectId,
|
||||||
ref: _.capitalize(details.model)
|
ref: _.capitalize(details.model)
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
@ -240,7 +239,7 @@ module.exports = function (strapi) {
|
|||||||
details.isVirtual = true;
|
details.isVirtual = true;
|
||||||
} else {
|
} else {
|
||||||
definition.loadedModel[name] = [{
|
definition.loadedModel[name] = [{
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: instance.Schema.Types.ObjectId,
|
||||||
ref: _.capitalize(details.collection)
|
ref: _.capitalize(details.collection)
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -260,7 +259,7 @@ module.exports = function (strapi) {
|
|||||||
details.isVirtual = true;
|
details.isVirtual = true;
|
||||||
} else {
|
} else {
|
||||||
definition.loadedModel[name] = {
|
definition.loadedModel[name] = {
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: instance.Schema.Types.ObjectId,
|
||||||
ref: _.capitalize(details.model)
|
ref: _.capitalize(details.model)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -281,7 +280,7 @@ module.exports = function (strapi) {
|
|||||||
details.isVirtual = true;
|
details.isVirtual = true;
|
||||||
} else {
|
} else {
|
||||||
definition.loadedModel[name] = [{
|
definition.loadedModel[name] = [{
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: instance.Schema.Types.ObjectId,
|
||||||
ref: _.capitalize(details.collection)
|
ref: _.capitalize(details.collection)
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@
|
|||||||
li{
|
li{
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 15px;
|
min-width: 15px;
|
||||||
margin: 0 5px;
|
margin: 0 5px !important;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
color: #333740;
|
color: #333740;
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { isEmpty } from 'lodash';
|
import moment from 'moment';
|
||||||
|
import { isEmpty, isObject } from 'lodash';
|
||||||
|
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
|
||||||
@ -36,6 +37,13 @@ class TableRow extends React.Component {
|
|||||||
return value && !isEmpty(value.toString()) ? value.toString() : '-';
|
return value && !isEmpty(value.toString()) ? value.toString() : '-';
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return value && !isEmpty(value.toString()) ? value.toString() : '-';
|
return value && !isEmpty(value.toString()) ? value.toString() : '-';
|
||||||
|
case 'date':
|
||||||
|
case 'time':
|
||||||
|
case 'datetime':
|
||||||
|
case 'timestamp':
|
||||||
|
return value && isObject(value) && value._isAMomentObject === true ?
|
||||||
|
this.props.value.format('YYYY-MM-DD HH:mm:ss') :
|
||||||
|
moment(this.props.value).format('YYYY-MM-DD HH:mm:ss');
|
||||||
default:
|
default:
|
||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
@ -83,6 +91,9 @@ TableRow.propTypes = {
|
|||||||
headers: PropTypes.array.isRequired,
|
headers: PropTypes.array.isRequired,
|
||||||
record: PropTypes.object.isRequired,
|
record: PropTypes.object.isRequired,
|
||||||
redirectUrl: PropTypes.string.isRequired,
|
redirectUrl: PropTypes.string.isRequired,
|
||||||
|
value: PropTypes.shape({
|
||||||
|
format: PropTypes.func,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
TableRow.defaultProps = {
|
TableRow.defaultProps = {
|
||||||
|
|||||||
@ -232,7 +232,7 @@ export class List extends React.Component {
|
|||||||
}}
|
}}
|
||||||
actions={pluginHeaderActions}
|
actions={pluginHeaderActions}
|
||||||
/>
|
/>
|
||||||
<div className='row'>
|
<div className={`row ${styles.row}`}>
|
||||||
<div className='col-lg-12'>
|
<div className='col-lg-12'>
|
||||||
{content}
|
{content}
|
||||||
<PopUpWarning
|
<PopUpWarning
|
||||||
|
|||||||
@ -5,3 +5,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.row{
|
||||||
|
padding-bottom: 36px;
|
||||||
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"containers.Edit.cancel": "Cancel",
|
"containers.Edit.cancel": "Cancel",
|
||||||
"containers.Edit.returnList": "Return to list",
|
"containers.Edit.returnList": "Return to list",
|
||||||
"containers.List.addAnEntry": "Add New {entity}",
|
"containers.List.addAnEntry": "Add New {entity}",
|
||||||
"containers.List.pluginHeaderDescription": "Manage your {label}",
|
"containers.List.pluginHeaderDescription": "Manage your {label}.",
|
||||||
"components.LimitSelect.itemsPerPage": "Items per page",
|
"components.LimitSelect.itemsPerPage": "Items per page",
|
||||||
"containers.List.errorFetchRecords": "Error",
|
"containers.List.errorFetchRecords": "Error",
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
.contentHeader { /* stylelint-disable */
|
.contentHeader { /* stylelint-disable */
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 2.4rem 0rem 3.3rem 0rem;
|
margin: 2.3rem 0rem 3.3rem 0rem;
|
||||||
font-family: Lato;
|
font-family: Lato;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -12,6 +12,8 @@
|
|||||||
font-size: 2.4rem;
|
font-size: 2.4rem;
|
||||||
line-height: 2.9rem;
|
line-height: 2.9rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
|
||||||
> i {
|
> i {
|
||||||
margin-top: 1.1rem;
|
margin-top: 1.1rem;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
|
|||||||
@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
.pluginLeftMenuLink { /* stylelint-disable */
|
.pluginLeftMenuLink { /* stylelint-disable */
|
||||||
color: #2D3138;
|
color: #2D3138;
|
||||||
}
|
|
||||||
|
|
||||||
li:not(:first-child) {
|
li:not(:first-child) {
|
||||||
margin-top: 0.2rem;
|
margin-top: 0.2rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
padding: 2rem 0 0rem 0;
|
padding: 2rem 0 0rem 0;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
font-family: Lato;
|
font-family: Lato;
|
||||||
|
box-shadow: 0 2px 4px #E3E9F3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.headerContainer {
|
.headerContainer {
|
||||||
|
|||||||
@ -92,7 +92,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
|
|||||||
<ContentHeader
|
<ContentHeader
|
||||||
name={'content-type-builder.home.contentTypeBuilder.name'}
|
name={'content-type-builder.home.contentTypeBuilder.name'}
|
||||||
description={'content-type-builder.home.contentTypeBuilder.description'}
|
description={'content-type-builder.home.contentTypeBuilder.description'}
|
||||||
styles={{ margin: '0 0 3.2rem 0'}}
|
styles={{ margin: '-1px 0 3rem 0'}}
|
||||||
/>
|
/>
|
||||||
{component}
|
{component}
|
||||||
<Form
|
<Form
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
.homePage { /* stylelint-disable */
|
.homePage { /* stylelint-disable */
|
||||||
padding: 2.4rem 3.2rem;
|
padding: 2.4rem 3rem;
|
||||||
background: rgba(14,22,34,0.02);
|
background: rgba(14,22,34,0.02);
|
||||||
min-height: calc(100vh - 6rem); // TODO shoukd be variable
|
min-height: calc(100vh - 6rem); // TODO shoukd be variable
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,14 +48,6 @@
|
|||||||
"policies": []
|
"policies": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"method": "GET",
|
|
||||||
"path": "/assets/:file",
|
|
||||||
"handler": "ContentTypeBuilder.assets",
|
|
||||||
"config": {
|
|
||||||
"policies": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"path": "/autoReload",
|
"path": "/autoReload",
|
||||||
|
|||||||
@ -185,14 +185,6 @@ module.exports = {
|
|||||||
strapi.reload();
|
strapi.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
assets: async ctx => {
|
|
||||||
try {
|
|
||||||
await send(ctx, `plugins/content-type-builder/admin/build/${ctx.params.file}`);
|
|
||||||
} catch (err) {
|
|
||||||
ctx.body = ctx.notFound();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
autoReload: async ctx => {
|
autoReload: async ctx => {
|
||||||
ctx.send({
|
ctx.send({
|
||||||
autoReload: _.get(strapi.config.environments, 'development.server.autoReload', false),
|
autoReload: _.get(strapi.config.environments, 'development.server.autoReload', false),
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap": "^4.0.0-alpha.6",
|
"bootstrap": "^4.0.0-alpha.6",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"koa-send": "^4.1.0",
|
|
||||||
"pluralize": "^7.0.0",
|
"pluralize": "^7.0.0",
|
||||||
"prop-types": "^15.5.10",
|
"prop-types": "^15.5.10",
|
||||||
"react": "^15.6.1",
|
"react": "^15.6.1",
|
||||||
|
|||||||
@ -92,13 +92,13 @@ module.exports = {
|
|||||||
const apiPath = path.join(strapi.config.appPath, 'api');
|
const apiPath = path.join(strapi.config.appPath, 'api');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apis = fs.readdirSync(apiPath);
|
const apis = fs.readdirSync(apiPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(apis, api => {
|
_.forEach(apis, api => {
|
||||||
const modelsPath = path.join(apiPath, api, 'models');
|
const modelsPath = path.join(apiPath, api, 'models');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const models = fs.readdirSync(modelsPath);
|
const models = fs.readdirSync(modelsPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
const modelIndex = _.indexOf(_.map(models, model => _.toLower(model)), searchFileName);
|
const modelIndex = _.indexOf(_.map(models, model => _.toLower(model)), searchFileName);
|
||||||
|
|
||||||
@ -177,13 +177,13 @@ module.exports = {
|
|||||||
const apiPath = path.join(strapi.config.appPath, 'api');
|
const apiPath = path.join(strapi.config.appPath, 'api');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apis = fs.readdirSync(apiPath);
|
const apis = fs.readdirSync(apiPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(apis, api => {
|
_.forEach(apis, api => {
|
||||||
const modelsPath = path.join(apiPath, api, 'models');
|
const modelsPath = path.join(apiPath, api, 'models');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const models = fs.readdirSync(modelsPath);
|
const models = fs.readdirSync(modelsPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(models, modelPath => {
|
_.forEach(models, modelPath => {
|
||||||
if (_.endsWith(modelPath, '.settings.json')) {
|
if (_.endsWith(modelPath, '.settings.json')) {
|
||||||
@ -250,13 +250,13 @@ module.exports = {
|
|||||||
const apiPath = path.join(strapi.config.appPath, 'api');
|
const apiPath = path.join(strapi.config.appPath, 'api');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apis = fs.readdirSync(apiPath);
|
const apis = fs.readdirSync(apiPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(apis, api => {
|
_.forEach(apis, api => {
|
||||||
const modelsPath = path.join(apiPath, api, 'models');
|
const modelsPath = path.join(apiPath, api, 'models');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const models = fs.readdirSync(modelsPath);
|
const models = fs.readdirSync(modelsPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(models, modelPath => {
|
_.forEach(models, modelPath => {
|
||||||
if (_.endsWith(modelPath, '.settings.json')) {
|
if (_.endsWith(modelPath, '.settings.json')) {
|
||||||
@ -393,7 +393,7 @@ module.exports = {
|
|||||||
|
|
||||||
const recurciveDeleteFiles = folderPath => {
|
const recurciveDeleteFiles = folderPath => {
|
||||||
try {
|
try {
|
||||||
const items = fs.readdirSync(folderPath);
|
const items = fs.readdirSync(folderPath).filter(x => x[0] !== '.');
|
||||||
|
|
||||||
_.forEach(items, item => {
|
_.forEach(items, item => {
|
||||||
const itemPath = path.join(folderPath, item);
|
const itemPath = path.join(folderPath, item);
|
||||||
@ -405,7 +405,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_.isEmpty(fs.readdirSync(folderPath))) {
|
if (_.isEmpty(fs.readdirSync(folderPath).filter(x => x[0] !== '.'))) {
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(folderPath);
|
fs.rmdirSync(folderPath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -104,14 +104,6 @@
|
|||||||
"policies": []
|
"policies": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"method": "GET",
|
|
||||||
"path": "/assets/:file",
|
|
||||||
"handler": "SettingsManager.assets",
|
|
||||||
"config": {
|
|
||||||
"policies": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"path": "/autoReload",
|
"path": "/autoReload",
|
||||||
|
|||||||
@ -330,14 +330,6 @@ module.exports = {
|
|||||||
strapi.reload();
|
strapi.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
assets: async ctx => {
|
|
||||||
try {
|
|
||||||
await send(ctx, `plugins/settings-manager/admin/build/${ctx.params.file}`);
|
|
||||||
} catch (err) {
|
|
||||||
ctx.body = ctx.notFound();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
autoReload: async ctx => {
|
autoReload: async ctx => {
|
||||||
ctx.send({
|
ctx.send({
|
||||||
autoReload: _.get(strapi.config.environments, 'development.server.autoReload', false),
|
autoReload: _.get(strapi.config.environments, 'development.server.autoReload', false),
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap": "^4.0.0-alpha.6",
|
"bootstrap": "^4.0.0-alpha.6",
|
||||||
"flag-icon-css": "^2.8.0",
|
"flag-icon-css": "^2.8.0",
|
||||||
"koa-send": "^4.1.0",
|
|
||||||
"react": "^15.6.1",
|
"react": "^15.6.1",
|
||||||
"react-dom": "^15.6.1",
|
"react-dom": "^15.6.1",
|
||||||
"react-select": "^1.0.0-rc.5",
|
"react-select": "^1.0.0-rc.5",
|
||||||
|
|||||||
@ -279,7 +279,7 @@ module.exports.app = async function() {
|
|||||||
this.config.url = `http://${this.config.host}:${this.config.port}`;
|
this.config.url = `http://${this.config.host}:${this.config.port}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const enableHookNestedDependencies = function (name, flattenHooksConfig) {
|
const enableHookNestedDependencies = function (name, flattenHooksConfig, force = false) {
|
||||||
if (!this.hook[name]) {
|
if (!this.hook[name]) {
|
||||||
this.log.warn(`(hook:${name}) \`strapi-${name}\` is missing in your dependencies. Please run \`npm install strapi-${name}\``);
|
this.log.warn(`(hook:${name}) \`strapi-${name}\` is missing in your dependencies. Please run \`npm install strapi-${name}\``);
|
||||||
}
|
}
|
||||||
@ -305,13 +305,13 @@ const enableHookNestedDependencies = function (name, flattenHooksConfig) {
|
|||||||
}) || 0; // Filter model with the right connector
|
}) || 0; // Filter model with the right connector
|
||||||
|
|
||||||
flattenHooksConfig[name] = {
|
flattenHooksConfig[name] = {
|
||||||
enabled: modelsUsed.length > 0 // Will return false if there is no model, else true.
|
enabled: force || modelsUsed.length > 0 // Will return false if there is no model, else true.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enabled dependencies.
|
// Enabled dependencies.
|
||||||
if (get(this.hook, `${name}.dependencies`, []).length > 0) {
|
if (get(this.hook, `${name}.dependencies`, []).length > 0) {
|
||||||
this.hook[name].dependencies.forEach(dependency => {
|
this.hook[name].dependencies.forEach(dependency => {
|
||||||
enableHookNestedDependencies.call(this, dependency.replace('strapi-', ''), flattenHooksConfig);
|
enableHookNestedDependencies.call(this, dependency.replace('strapi-', ''), flattenHooksConfig, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,22 @@ module.exports = strapi => {
|
|||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
strapi.router.route({
|
||||||
|
method: 'GET',
|
||||||
|
path: `/${plugin}/assets/*.*`,
|
||||||
|
handler: [
|
||||||
|
async (ctx, next) => {
|
||||||
|
ctx.url = path.basename(ctx.url);
|
||||||
|
|
||||||
|
await next();
|
||||||
|
},
|
||||||
|
strapi.koaMiddlewares.static(`./plugins/${plugin}/admin/build`, {
|
||||||
|
maxage: strapi.config.middleware.settings.public.maxAge,
|
||||||
|
defer: true
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user