mirror of
https://github.com/strapi/strapi.git
synced 2025-09-23 23:38:15 +00:00
Merge branch 'develop' into chore/routing-x-forwarded
This commit is contained in:
commit
a9ad27f351
@ -264,12 +264,14 @@ Documentation: [https://bookshelfjs.org/](https://bookshelfjs.org/)
|
|||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```js
|
```js
|
||||||
strapi
|
const result = await strapi
|
||||||
.query('post')
|
.query('post')
|
||||||
.model.query(qb => {
|
.model.query(qb => {
|
||||||
qb.where('id', 1);
|
qb.where('id', 1);
|
||||||
})
|
})
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
|
const fields = result.toJSON();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Mongoose
|
### Mongoose
|
||||||
@ -279,9 +281,9 @@ Documentation: [https://mongoosejs.com/](https://mongoosejs.com/)
|
|||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```js
|
```js
|
||||||
strapi
|
const result = strapi.query('post').model.find({
|
||||||
.query('post')
|
date: { $gte: '2019-01-01T00.00.00Z' },
|
||||||
.model.find({
|
|
||||||
{ date: { $gte: '2019-01-01T00.00.00Z }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const fields = result.toObject();
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
# Migrations guides
|
# 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)
|
- [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.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)
|
- [Migration guide from alpha.8 to alpha.9](migration-guide-alpha.8-to-alpha.9.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();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
@ -12,7 +12,7 @@ import styles from './styles.scss';
|
|||||||
|
|
||||||
/* eslint-disable jsx-a11y/anchor-is-valid */
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
||||||
class GlobalPagination extends React.Component {
|
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();
|
handleDotsClick = (e) => e.preventDefault();
|
||||||
|
|
||||||
|
@ -425,8 +425,9 @@ export class GroupPage extends React.Component {
|
|||||||
const { groups } = this.props;
|
const { groups } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
groups.findIndex(group => group.name === this.getFeatureDisplayName()) ===
|
groups.findIndex(
|
||||||
-1
|
group => (group.uid || group.name) === this.getFeatureName()
|
||||||
|
) === -1
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user