mirror of
https://github.com/strapi/strapi.git
synced 2025-08-04 06:49:16 +00:00
Merge branch 'develop' into features/single-types
This commit is contained in:
commit
dce6bd432c
2
codecov.yml
Normal file
2
codecov.yml
Normal file
@ -0,0 +1,2 @@
|
||||
comment:
|
||||
branch: master
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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)) {
|
||||
|
@ -85,6 +85,7 @@ const formatAttribute = (key, attribute, { model }) => {
|
||||
undefined
|
||||
),
|
||||
unique: attribute.unique ? true : false,
|
||||
autoPopulate: attribute.autoPopulate,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user