diff --git a/docs/3.0.0-beta.x/guides/queries.md b/docs/3.0.0-beta.x/guides/queries.md index c9eed07632..77adbb25a4 100644 --- a/docs/3.0.0-beta.x/guides/queries.md +++ b/docs/3.0.0-beta.x/guides/queries.md @@ -264,12 +264,14 @@ Documentation: [https://bookshelfjs.org/](https://bookshelfjs.org/) **Example** ```js -strapi +const result = await strapi .query('post') .model.query(qb => { qb.where('id', 1); }) .fetch(); + +const fields = result.toJSON(); ``` ### Mongoose @@ -279,9 +281,9 @@ Documentation: [https://mongoosejs.com/](https://mongoosejs.com/) **Example** ```js -strapi - .query('post') - .model.find({ - { date: { $gte: '2019-01-01T00.00.00Z } - }); +const result = strapi.query('post').model.find({ + date: { $gte: '2019-01-01T00.00.00Z' }, +}); + +const fields = result.toObject(); ``` diff --git a/docs/3.0.0-beta.x/migration-guide/README.md b/docs/3.0.0-beta.x/migration-guide/README.md index c4567d9b42..3ea0772b50 100644 --- a/docs/3.0.0-beta.x/migration-guide/README.md +++ b/docs/3.0.0-beta.x/migration-guide/README.md @@ -1,5 +1,15 @@ # Migrations guides +## Migrating from Alpha ? + +Read the [Migration guide from alpha.26 to beta](migration-guide-alpha.26-to-beta.md) first then read the [Beta migration guides](#beta-guides) + +## Beta guides + +- [Migration guide from beta.15 to beta.16](migration-guide-beta.15-to-beta.16.md) + +## Alpha guides + - [Migrating from v1 to v3](migration-guide-1-to-3.md) - [Migration guide from alpha.7.4 to alpha.8](migration-guide-alpha.7.4-to-alpha.8.md) - [Migration guide from alpha.8 to alpha.9](migration-guide-alpha.8-to-alpha.9.md) diff --git a/docs/3.0.0-beta.x/migration-guide/migration-guide-beta.15-to-beta.16.md b/docs/3.0.0-beta.x/migration-guide/migration-guide-beta.15-to-beta.16.md new file mode 100644 index 0000000000..a86b9ad86d --- /dev/null +++ b/docs/3.0.0-beta.x/migration-guide/migration-guide-beta.15-to-beta.16.md @@ -0,0 +1,211 @@ +# Migration guide from beta.15 to beta.16 + +Upgrading your Strapi application to `v3.0.0-beta.16`. + +## Upgrading your dependencies + +Start by upgrading all your strapi package version to `3.0.0-beta.16`. + +Your package.json would look like this: + +```json +{ + //... + "dependencies": { + "strapi": "3.0.0-beta.16", + "strapi-admin": "3.0.0-beta.16", + "strapi-hook-bookshelf": "3.0.0-beta.16", + "strapi-hook-knex": "3.0.0-beta.16", + "strapi-plugin-content-manager": "3.0.0-beta.16", + "strapi-plugin-content-type-builder": "3.0.0-beta.16", + "strapi-plugin-email": "3.0.0-beta.16", + "strapi-plugin-graphql": "3.0.0-beta.16", + "strapi-plugin-settings-manager": "3.0.0-beta.16", + "strapi-plugin-upload": "3.0.0-beta.16", + "strapi-plugin-users-permissions": "3.0.0-beta.16", + "strapi-utils": "3.0.0-beta.16" + } +} +``` + +Then run either `yarn install` or `npm install`. + +## Building your administration panel + +This new release introduces changes to the administration panel than require rebuild it. + +Start by deleting your current build: + +```bash +rm -rf ./build +``` + +Build the administration panel: + +```bash +yarn build +# or +npm run build +``` + +## Updating your code + +### Wysiwyg + +Wysiwyg was previously an option of the `text` type that was stored in the database. When deploying to production for the first time you had to select again the option in the interface. + +To improve make sure a field stays the same when deploying we introduced the `richtext` type. This type is equivalent to the previous `text` type with `wysiwyg` option enabled. + +**Before**: + +```json +{ + //... + "attributes": { + "name": { + "type": "string" + } + "description": { + "type": "text" + } + } +} +``` + +**After**: + +```json +{ + //... + "attributes": { + "name": { + "type": "string" + } + "description": { + "type": "richtext" + } + } +} +``` + +### Custom controllers and services + +If you are using [core services](../guides/services.md), you previously needed to call `result.toJSON()` or `result.toObject()` to get a plain javascript object. This is not the case anymore, you will now receive a simple object directly. + +**Before**: + +```js +module.exports = { + async findOne(id) { + const result = await strapi.services.restaurant.findOne(id); + return result.toJSON(); + }, +}; +``` + +**After**: + +```js +module.exports = { + findOne(id) { + return strapi.services.restaurant.findOne(id); + }, +}; +``` + +The same modification was made to `strapi.query()`. Read more about **Queries** [here](../guides/queries.md). + +Keep in mind that if you are running custom ORM queries with Bookshelf or Mongoose you will still have to call `toJSON` or `toObject`. Check out this section about [custom queries](../guides/queries.html#api-reference). + +### Bootstrap function + +The function exported in `config/functions/bootstrap.js` previsouly received a callback. This is not the case anymore. You can either use an async function, return a promise or simply run a synchronous function. + +**Before** + +```js +module.exports = { + defaults: {}, + initialize(cb) { + // code + cb(); + }, +}; +``` + +**After** + +**Async** + +```js +module.exports = async () => { + await someOperation(); +}; +``` + +**Promise** + +```js +module.exports = () => { + return new Promise(/* ... */); +}; +``` + +**Sync** + +```js +module.exports = () => { + someSyncCode(); +}; +``` + +### Custom hooks + +If you have custom [hooks](../advanced/hooks.md) in your project, the `initialize` function will not receive a callback anymore. You can either use an async function, return a promise or simply run a synchronous function. + +**Before** + +```js +module.exports = { + defaults: {}, + initialize(cb) { + // code + cb(); + }, +}; +``` + +**After** + +**Async** + +```js +module.exports = { + defaults: {}, + async initialize() { + await someOperation(); + }, +}; +``` + +**Promise** + +```js +module.exports = { + defaults: {}, + initialize() { + return new Promise(/* ... */); + }, +}; +``` + +**Sync** + +```js +module.exports = { + defaults: {}, + initialize() { + someSyncCode(); + }, +}; +``` diff --git a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js index 1ab788082e..b8b9bbc339 100644 --- a/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/GlobalPagination/index.js @@ -12,7 +12,7 @@ import styles from './styles.scss'; /* eslint-disable jsx-a11y/anchor-is-valid */ class GlobalPagination extends React.Component { - getLastPageNumber = () => Math.ceil(this.props.count / this.props.params._limit); + getLastPageNumber = () => Math.ceil(this.props.count / this.props.params._limit) || 1; handleDotsClick = (e) => e.preventDefault(); diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js index 7b59872774..32a0d96235 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js @@ -425,8 +425,9 @@ export class GroupPage extends React.Component { const { groups } = this.props; return ( - groups.findIndex(group => group.name === this.getFeatureDisplayName()) === - -1 + groups.findIndex( + group => (group.uid || group.name) === this.getFeatureName() + ) === -1 ); };