mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Merge branch 'features/dynamic-zones' of github.com:strapi/strapi into front/dz-post-data
This commit is contained in:
commit
c9089a4ad2
@ -8,6 +8,7 @@ Read the [Migration guide from alpha.26 to beta](migration-guide-alpha.26-to-bet
|
||||
|
||||
- [Migration guide from beta.15 to beta.16](migration-guide-beta.15-to-beta.16.md)
|
||||
- [Migration guide from beta.16+ to beta.17.4](migration-guide-beta.16-to-beta.17.4.md)
|
||||
- [Migration guide from beta.17+ to beta.18](migration-guide-beta.17-to-beta.18.md)
|
||||
|
||||
## Alpha guides
|
||||
|
||||
|
||||
@ -0,0 +1,229 @@
|
||||
# Migration guide from beta.18 through beta.17.8 to beta.18
|
||||
|
||||
Upgrading your Strapi application to `v3.0.0-beta.18`.
|
||||
|
||||
## Upgrading your dependencies
|
||||
|
||||
Start by upgrading your dependencies. Make sure to use exact versions.
|
||||
|
||||
::: danger
|
||||
Starting from beta.18 the database packages have been changed to allow future changes.
|
||||
|
||||
- `strapi-hook-knex` has been removed and merged into the `bookshelf` database connector.
|
||||
- `strapi-hook-bookshelf` is renamed `strapi-connector-bookshelf`.
|
||||
- `strapi-hook-mongoose` is renamed `strapi-connector-mongoose`.
|
||||
|
||||
:::
|
||||
|
||||
Update your package.json accordingly:
|
||||
|
||||
**Before**
|
||||
|
||||
```json
|
||||
{
|
||||
//...
|
||||
"dependencies": {
|
||||
"strapi": "3.0.0-beta.17.4",
|
||||
"strapi-admin": "3.0.0-beta.17.4",
|
||||
"strapi-hook-bookshelf": "3.0.0-beta.17.4", // rename to strapi-connector-bookshelf
|
||||
"strapi-hook-knex": "3.0.0-beta.17.4", // remove
|
||||
"strapi-plugin-content-manager": "3.0.0-beta.17.4",
|
||||
"strapi-plugin-content-type-builder": "3.0.0-beta.17.4",
|
||||
"strapi-plugin-email": "3.0.0-beta.17.4",
|
||||
"strapi-plugin-graphql": "3.0.0-beta.17.4",
|
||||
"strapi-plugin-upload": "3.0.0-beta.17.4",
|
||||
"strapi-plugin-users-permissions": "3.0.0-beta.17.4",
|
||||
"strapi-utils": "3.0.0-beta.17.4"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```json
|
||||
{
|
||||
//...
|
||||
"dependencies": {
|
||||
"strapi": "3.0.0-beta.18",
|
||||
"strapi-admin": "3.0.0-beta.18",
|
||||
"strapi-connector-bookshelf": "3.0.0-beta.18",
|
||||
"strapi-plugin-content-manager": "3.0.0-beta.18",
|
||||
"strapi-plugin-content-type-builder": "3.0.0-beta.18",
|
||||
"strapi-plugin-email": "3.0.0-beta.18",
|
||||
"strapi-plugin-graphql": "3.0.0-beta.18",
|
||||
"strapi-plugin-upload": "3.0.0-beta.18",
|
||||
"strapi-plugin-users-permissions": "3.0.0-beta.18",
|
||||
"strapi-utils": "3.0.0-beta.18"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then run either `yarn install` or `npm install`.
|
||||
|
||||
## Database configuration
|
||||
|
||||
Now that you have installed the new database package. You need to update your `database.json` configuration files located in `./config/environments/{env}/database.json`.
|
||||
|
||||
You can now only use the connector name instead of the complete package name.
|
||||
|
||||
**Before**
|
||||
|
||||
```json
|
||||
{
|
||||
"defaultConnection": "default",
|
||||
"connections": {
|
||||
"default": {
|
||||
"connector": "strapi-hook-bookshelf",
|
||||
"settings": {
|
||||
//...
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```json
|
||||
{
|
||||
"defaultConnection": "default",
|
||||
"connections": {
|
||||
"default": {
|
||||
"connector": "bookshelf",
|
||||
"settings": {
|
||||
//...
|
||||
},
|
||||
"options": {
|
||||
//...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## `ctx.state.user`
|
||||
|
||||
Previously the ctx.state.user was populated with the user informations, its role and permissions. To avoid perfromance issues the role is the only populated relation on the user by default.
|
||||
|
||||
## File model
|
||||
|
||||
The file model has been update. The `size` field is now a decimal number, allowing correct sorting behavior.
|
||||
|
||||
You will need to clear some database indexes if you are using either Mysql or PostgreSQL.
|
||||
|
||||
:::: tabs
|
||||
|
||||
::: tab Mysql
|
||||
|
||||
Run the following statement in your database:
|
||||
|
||||
`DROP INDEX SEARCH_UPLOAD_FILE ON upload_file;`
|
||||
|
||||
:::
|
||||
::: tab PostgreSQL
|
||||
|
||||
Run the following statement in your database:
|
||||
|
||||
`DROP INDEX search_upload_file_size;`
|
||||
|
||||
:::
|
||||
::::
|
||||
|
||||
## Groups become Components
|
||||
|
||||
If you were using the groups feature you will need to apply some changes:
|
||||
|
||||
Start by renaming the `./groups` folder to `./components` in your project root folder.
|
||||
|
||||
Components now are placed into `categories`. To reflect this you must move all your components inside a `category` folder.
|
||||
|
||||
### Example
|
||||
|
||||
**Before**
|
||||
|
||||
```
|
||||
groups/
|
||||
├── seo-metadata.json
|
||||
└── image-text.json
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```
|
||||
components/
|
||||
├── seo/
|
||||
│ └── metadata.json
|
||||
└── content/
|
||||
└── image-text.json
|
||||
```
|
||||
|
||||
Now that you have moved your component into categories. You need to update your content-types to references them correctly.
|
||||
|
||||
**Before**
|
||||
`./api/restaurant/models/Restaurant.settings.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"connection": "default",
|
||||
"collectionName": "restaurants",
|
||||
"info": {
|
||||
"name": "restaurant",
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
"increments": true,
|
||||
"timestamps": ["created_at", "updated_at"]
|
||||
},
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"seo_metadatas": {
|
||||
"type": "group",
|
||||
"group": "seo-metadata",
|
||||
"repeatable": true
|
||||
},
|
||||
"cover": {
|
||||
"type": "group",
|
||||
"group": "image-text"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
`./api/restaurant/models/Restaurant.settings.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"connection": "default",
|
||||
"collectionName": "restaurants",
|
||||
"info": {
|
||||
"name": "restaurant",
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
"increments": true,
|
||||
"timestamps": ["created_at", "updated_at"]
|
||||
},
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"seo_metadatas": {
|
||||
"type": "component",
|
||||
"component": "seo.metadata", // {category}.{name}
|
||||
"repeatable": true
|
||||
},
|
||||
"cover": {
|
||||
"type": "component",
|
||||
"component": "content.image-text"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Rebuilding your administration panel
|
||||
|
||||
Now delete the `.cache` and `build` folders. Then run `yarn develop`.
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { fromJS } from 'immutable';
|
||||
import { first, get, includes, split } from 'lodash';
|
||||
import { get, includes, split } from 'lodash';
|
||||
|
||||
// Import supported languages from the translations folder
|
||||
import trads from '../../translations';
|
||||
@ -33,7 +33,7 @@ if (!foundLanguage) {
|
||||
}
|
||||
|
||||
const initialState = fromJS({
|
||||
locale: foundLanguage || first(languages) || 'en',
|
||||
locale: foundLanguage || 'en',
|
||||
});
|
||||
|
||||
function languageProviderReducer(state = initialState, action) {
|
||||
|
||||
@ -13,34 +13,37 @@ const createComponentModels = async ({ model, definition, ORM, GLOBALS }) => {
|
||||
// create component model
|
||||
const joinTable = `${collectionName}_components`;
|
||||
const joinColumn = `${pluralize.singular(collectionName)}_${primaryKey}`;
|
||||
|
||||
const relatedComponents = componentAttributes
|
||||
.map(key => {
|
||||
const attr = definition.attributes[key];
|
||||
const { type } = attr;
|
||||
|
||||
switch (type) {
|
||||
case 'component': {
|
||||
const { component } = attr;
|
||||
return strapi.components[component];
|
||||
}
|
||||
case 'dynamiczone': {
|
||||
const { components } = attr;
|
||||
return components.map(component => strapi.components[component]);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Invalid type for attribute ${key}: ${type}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
.reduce((acc, arr) => acc.concat(arr), []);
|
||||
|
||||
const joinModel = ORM.Model.extend({
|
||||
requireFetch: false,
|
||||
tableName: joinTable,
|
||||
component() {
|
||||
return this.morphTo(
|
||||
'component',
|
||||
...componentAttributes
|
||||
.map(key => {
|
||||
const attr = definition.attributes[key];
|
||||
const { type } = attr;
|
||||
|
||||
switch (type) {
|
||||
case 'component': {
|
||||
const { component } = attr;
|
||||
return GLOBALS[strapi.components[component].globalId];
|
||||
}
|
||||
case 'dynamiczone': {
|
||||
const { components } = attr;
|
||||
return components.map(
|
||||
component => GLOBALS[strapi.components[component].globalId]
|
||||
);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Invalid type for attribute ${key}: ${type}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
.reduce((acc, arr) => acc.concat(arr), [])
|
||||
...relatedComponents.map(component => {
|
||||
return GLOBALS[component.globalId];
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
@ -51,7 +54,12 @@ const createComponentModels = async ({ model, definition, ORM, GLOBALS }) => {
|
||||
componentAttributes.forEach(name => {
|
||||
model[name] = function relation() {
|
||||
return this.hasMany(joinModel).query(qb => {
|
||||
qb.where('field', name).orderBy('order');
|
||||
qb.where('field', name)
|
||||
.whereIn(
|
||||
'component_type',
|
||||
relatedComponents.map(component => component.collectionName)
|
||||
)
|
||||
.orderBy('order');
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"mongoose": "5.7.4",
|
||||
"mongoose": "5.8.0",
|
||||
"mongoose-float": "^1.0.4",
|
||||
"mongoose-long": "^0.2.1",
|
||||
"pluralize": "^7.0.0",
|
||||
|
||||
49
yarn.lock
49
yarn.lock
@ -11348,6 +11348,11 @@ memory-fs@^0.5.0:
|
||||
errno "^0.1.3"
|
||||
readable-stream "^2.0.1"
|
||||
|
||||
memory-pager@^1.0.2:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5"
|
||||
integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==
|
||||
|
||||
memorystream@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
|
||||
@ -11694,6 +11699,17 @@ mongodb@3.3.2:
|
||||
require_optional "^1.0.1"
|
||||
safe-buffer "^5.1.2"
|
||||
|
||||
mongodb@3.3.5:
|
||||
version "3.3.5"
|
||||
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.3.5.tgz#38d531013afede92b0dd282e3b9f3c08c9bdff3b"
|
||||
integrity sha512-6NAv5gTFdwRyVfCz+O+KDszvjpyxmZw+VlmqmqKR2GmpkeKrKFRv/ZslgTtZba2dc9JYixIf99T5Gih7TIWv7Q==
|
||||
dependencies:
|
||||
bson "^1.1.1"
|
||||
require_optional "^1.0.1"
|
||||
safe-buffer "^5.1.2"
|
||||
optionalDependencies:
|
||||
saslprep "^1.0.0"
|
||||
|
||||
mongoose-float@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mongoose-float/-/mongoose-float-1.0.4.tgz#abdda2c66320a8acf8a13a8b704c9b7ea4b5b840"
|
||||
@ -11709,7 +11725,24 @@ mongoose-long@^0.2.1:
|
||||
resolved "https://registry.yarnpkg.com/mongoose-long/-/mongoose-long-0.2.1.tgz#2d4f560430338bfbe7129e31a543c497a2d6a4db"
|
||||
integrity sha512-cbzEW5rShz8MxoTMFUidf13KObGkauA4ILeR3XcIdI7VLzMXwwXy///gLAbN2fD6vYy2ZAMDnCopQrCkNH9VNQ==
|
||||
|
||||
mongoose@5.7.4, mongoose@^5.5.13:
|
||||
mongoose@5.8.0:
|
||||
version "5.8.0"
|
||||
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.8.0.tgz#ddbfd6849632ed5840ec3e5faeaab1945bb3b650"
|
||||
integrity sha512-+VqrLGmHoDW/72yaXgiXSF7E/JcZ8Iyt7etrd4x3+Bj0z7k6GHHUBgGHP5ySPoG4J412RFuvHqx6xEOIuUrcfQ==
|
||||
dependencies:
|
||||
bson "~1.1.1"
|
||||
kareem "2.3.1"
|
||||
mongodb "3.3.5"
|
||||
mongoose-legacy-pluralize "1.0.2"
|
||||
mpath "0.6.0"
|
||||
mquery "3.2.2"
|
||||
ms "2.1.2"
|
||||
regexp-clone "1.0.0"
|
||||
safe-buffer "5.1.2"
|
||||
sift "7.0.1"
|
||||
sliced "1.0.1"
|
||||
|
||||
mongoose@^5.5.13:
|
||||
version "5.7.4"
|
||||
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.7.4.tgz#b6a77a9217dace917ab028fa5dc72f400f2faf4b"
|
||||
integrity sha512-IgqQS5HIaZ8tG2cib6QllfIw2Wc/A0QVOsdKLsSqRolqJFWOjI0se3vsKXLNkbEcuJ1xziW3e/jPhBs65678Hg==
|
||||
@ -15446,6 +15479,13 @@ sanitize.css@^4.1.0:
|
||||
resolved "https://registry.yarnpkg.com/sanitize.css/-/sanitize.css-4.1.0.tgz#0bafc3c513699f2fe8c7980c6d37edf21d3f5448"
|
||||
integrity sha1-C6/DxRNpny/ox5gMbTft8h0/VEg=
|
||||
|
||||
saslprep@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226"
|
||||
integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==
|
||||
dependencies:
|
||||
sparse-bitfield "^3.0.3"
|
||||
|
||||
sax@1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
|
||||
@ -16187,6 +16227,13 @@ sourcemap-codec@^1.4.4:
|
||||
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.6.tgz#e30a74f0402bad09807640d39e971090a08ce1e9"
|
||||
integrity sha512-1ZooVLYFxC448piVLBbtOxFcXwnymH9oUF8nRd3CuYDVvkRBxRl6pB4Mtas5a4drtL+E8LDgFkQNcgIw6tc8Hg==
|
||||
|
||||
sparse-bitfield@^3.0.3:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11"
|
||||
integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE=
|
||||
dependencies:
|
||||
memory-pager "^1.0.2"
|
||||
|
||||
spdx-correct@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user