Merge branch 'master' into eslint-update

This commit is contained in:
Alexandre BODIN 2019-09-10 16:29:46 +02:00 committed by GitHub
commit 7e9adb789f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 30 deletions

View File

@ -38,8 +38,8 @@ If you are passing a number of configuration item values via environment variabl
```js
{
"host": "${process.env.APP_HOST || '127.0.0.1'}"
"port": "${process.env.NODE_PORT || 1337}",
"host": "${process.env.APP_HOST || '127.0.0.1'}",
"port": "${process.env.NODE_PORT || 1337}"
}
```

View File

@ -32,7 +32,7 @@ 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.
This new release introduces changes to the administration panel that require a rebuild.
Start by deleting your current build:
@ -52,9 +52,9 @@ npm run build
### 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.
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 re-select 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.
To make sure a Wysiwyg 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**:
@ -119,7 +119,7 @@ Keep in mind that if you are running custom ORM queries with Bookshelf or Mongoo
### 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.
The function exported in `config/functions/bootstrap.js` previously 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**

View File

@ -98,15 +98,14 @@ module.exports = function createQueryBuilder({ model, modelKey, strapi }) {
// Create entry with no-relational data.
const entry = await model.forge(data).save(null, { transacting: trx });
await createGroups(entry, values, { transacting: trx });
return entry;
return model.updateRelations(
{ id: entry.id, values: relations },
{ transacting: trx }
);
};
const entry = await wrapTransaction(runCreate, { transacting });
return model.updateRelations(
{ id: entry.id, values: relations },
{ transacting }
);
return wrapTransaction(runCreate, { transacting });
}
async function update(params, values, { transacting } = {}) {
@ -132,19 +131,18 @@ module.exports = function createQueryBuilder({ model, modelKey, strapi }) {
})
: entry;
await updateGroups(updatedEntry, values, { transacting: trx });
return updatedEntry;
if (Object.keys(relations).length > 0) {
return model.updateRelations(
Object.assign(params, { values: relations }),
{ transacting: trx }
);
}
return this.findOne(params, null, { transacting: trx });
};
await wrapTransaction(runUpdate, { transacting });
if (Object.keys(relations).length > 0) {
return model.updateRelations(
Object.assign(params, { values: relations }),
{ transacting }
);
}
return this.findOne(params, null, { transacting });
return wrapTransaction(runUpdate, { transacting });
}
async function deleteOne(params, { transacting } = {}) {

View File

@ -211,7 +211,7 @@ module.exports = {
const refModel = strapi.getModel(obj.ref, obj.source);
return {
ref: new mongoose.Types.ObjectId(obj.refId),
kind: refModel.globalId,
kind: obj.kind || refModel.globalId,
[association.filter]: obj.field,
};
});

View File

@ -5,7 +5,7 @@ const InfoLabel = styled.div`
top: 0;
right: 40px;
max-width: 80px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
font-weight: 400;

View File

@ -22,7 +22,7 @@
"button.attributes.add.another": "Add Another Field",
"button.contentType.add": "Add a Content Type",
"button.delete.title": "Delete",
"button.delete.label": "Make you sure you understand what you are doing",
"button.delete.label": "Make sure you understand what you are doing",
"button.group.add": "Add a Group",
"button.models.create": "Create a Content Type",
"button.groups.create": "Create a Group",

View File

@ -394,7 +394,7 @@ module.exports = {
// We have to know the difference to add or remove
// the permissions entries in the database.
const toRemove = _.difference(stringActions, currentActions).map(
key => actionsMap[key]
splitted
);
const toAdd = (permissions < 1
@ -419,7 +419,7 @@ module.exports = {
// Execute request to update entries in database for each role.
await Promise.all([
Promise.all(roles.map(createActions)),
Promise.all(toRemove.map(id => query.delete({ id }))),
Promise.all(toRemove.map(action => query.delete(action))),
]);
}
},

View File

@ -41,7 +41,21 @@ module.exports = strapi => {
strapi.app.use(
cors({
origin,
origin: function(ctx) {
const whitelist = Array.isArray(origin)
? origin
: origin.split(/\s*,\s*/);
const requestOrigin = ctx.accept.headers.origin;
if (whitelist.includes('*')) {
return '*';
}
if (!whitelist.includes(requestOrigin)) {
return ctx.throw(`${requestOrigin} is not a valid origin`);
}
return requestOrigin;
},
exposeHeaders: expose,
maxAge,
credentials,