Merge branch 'develop' into features/single-types

This commit is contained in:
Alexandre Bodin 2020-01-21 11:46:26 +01:00
commit dce6bd432c
8 changed files with 29 additions and 7 deletions

2
codecov.yml Normal file
View File

@ -0,0 +1,2 @@
comment:
branch: master

View File

@ -343,7 +343,7 @@ module.exports = {
to: admin.email,
from:
settings.from.email || settings.from.name
? `"${settings.from.name}" <${settings.from.email}>`
? `${settings.from.name} <${settings.from.email}>`
: undefined,
replyTo: settings.response_email,
subject: settings.object,

View File

@ -22,6 +22,7 @@ module.exports = (obj, validNatures) => {
.required(),
unique: validators.unique.nullable(),
configurable: yup.boolean().nullable(),
autoPopulate: yup.boolean().nullable(),
dominant: yup.boolean().nullable(),
columnName: yup.string().nullable(),
targetAttribute: REVERSE_RELATIONS.includes(obj.nature)

View File

@ -12,13 +12,16 @@ const createSchemaHandler = require('./schema-handler');
module.exports = function createComponentBuilder() {
return {
setRelation({ key, modelName, plugin, attribute }) {
this.contentTypes.get(attribute.target).setAttribute(
const targetCT = this.contentTypes.get(attribute.target);
const targetAttribute = targetCT.getAttribute(attribute.targetAttribute);
targetCT.setAttribute(
attribute.targetAttribute,
generateRelation({
key,
attribute,
plugin,
modelName,
targetAttribute,
})
);
},
@ -176,6 +179,8 @@ module.exports = function createComponentBuilder() {
this.unsetRelation(oldAttribute);
}
newAttribute.autoPopulate = newAttribute.autoPopulate || oldAttribute.autoPopulate;
return this.setRelation({
key,
modelName: contentType.modelName,
@ -238,11 +243,18 @@ module.exports = function createComponentBuilder() {
const createContentTypeUID = ({ name }) =>
`application::${nameToSlug(name)}.${nameToSlug(name)}`;
const generateRelation = ({ key, attribute, plugin, modelName }) => {
const generateRelation = ({
key,
attribute,
plugin,
modelName,
targetAttribute = {},
}) => {
const opts = {
via: key,
plugin,
columnName: attribute.targetColumnName || undefined,
autoPopulate: targetAttribute.autoPopulate,
};
switch (attribute.nature) {

View File

@ -119,12 +119,14 @@ function createSchemaBuilder({ components, contentTypes }) {
targetAttribute,
columnName,
dominant,
autoPopulate,
} = attribute;
const attr = {
unique: unique === true ? true : undefined,
columnName: columnName || undefined,
configurable: configurable === false ? false : undefined,
autoPopulate,
};
if (!this.contentTypes.has(target)) {

View File

@ -85,6 +85,7 @@ const formatAttribute = (key, attribute, { model }) => {
undefined
),
unique: attribute.unique ? true : false,
autoPopulate: attribute.autoPopulate,
};
}
};

View File

@ -66,6 +66,8 @@ module.exports = {
plugin: 'users-permissions',
resolverOf: 'UsersPermissions.getRole',
resolver: async (obj, options, { context }) => {
context.params = {...context.params, ...options.input};
await strapi.plugins[
'users-permissions'
].controllers.userspermissions.getRole(context);
@ -78,6 +80,8 @@ module.exports = {
plugin: 'users-permissions',
resolverOf: 'UsersPermissions.getRoles', // Apply the `getRoles` permissions on the resolver.
resolver: async (obj, options, { context }) => {
context.params = {...context.params, ...options.input};
await strapi.plugins[
'users-permissions'
].controllers.userspermissions.getRoles(context);
@ -195,10 +199,10 @@ module.exports = {
resolverOf: 'Auth.register',
resolver: async (obj, options, {context}) => {
context.request.body = _.toPlainObject(options.input);
await strapi.plugins['users-permissions'].controllers.auth.register(context);
let output = context.body.toJSON ? context.body.toJSON() : context.body;
checkBadRequest(output);
return {
user: output.user || output, jwt: output.jwt

View File

@ -362,7 +362,7 @@ module.exports = {
to: user.email,
from:
settings.from.email || settings.from.name
? `"${settings.from.name}" <${settings.from.email}>`
? `${settings.from.name} <${settings.from.email}>`
: undefined,
replyTo: settings.response_email,
subject: settings.object,
@ -560,7 +560,7 @@ module.exports = {
to: (user.toJSON ? user.toJSON() : user).email,
from:
settings.from.email && settings.from.name
? `"${settings.from.name}" <${settings.from.email}>`
? `${settings.from.name} <${settings.from.email}>`
: undefined,
replyTo: settings.response_email,
subject: settings.object,