Merge branch 'develop' into features/single-types

This commit is contained in:
HichamELBSI 2020-02-26 14:54:33 +01:00
commit ff870e7aa0
5 changed files with 446 additions and 417 deletions

View File

@ -4,6 +4,8 @@
The context object (`ctx`) contains all the requests related information. They are accessible through `ctx.request`, from [controllers](controllers.md) and [policies](policies.md). The context object (`ctx`) contains all the requests related information. They are accessible through `ctx.request`, from [controllers](controllers.md) and [policies](policies.md).
Strapi passes the `body` on `ctx.request.body` and `files` through `ctx.request.files`
For more information, please refer to the [Koa request documentation](http://koajs.com/#request). For more information, please refer to the [Koa request documentation](http://koajs.com/#request).
## Responses ## Responses

View File

@ -22,11 +22,11 @@
"@babel/preset-env": "^7.4.3", "@babel/preset-env": "^7.4.3",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.4.3", "@babel/runtime": "^7.4.3",
"@buffetjs/core": "2.1.1-next.1", "@buffetjs/core": "3.0.0-next.1",
"@buffetjs/custom": "2.1.1-next.1", "@buffetjs/custom": "3.0.0-next.1",
"@buffetjs/hooks": "2.1.1-next.1", "@buffetjs/hooks": "3.0.0-next.1",
"@buffetjs/icons": "2.1.1-next.1", "@buffetjs/icons": "3.0.0-next.1",
"@buffetjs/styles": "2.1.1-next.1", "@buffetjs/styles": "3.0.0-next.1",
"@buffetjs/utils": "^2.0.0", "@buffetjs/utils": "^2.0.0",
"@fortawesome/fontawesome-free": "^5.11.2", "@fortawesome/fontawesome-free": "^5.11.2",
"@fortawesome/fontawesome-svg-core": "^1.2.25", "@fortawesome/fontawesome-svg-core": "^1.2.25",

View File

@ -13,13 +13,7 @@ module.exports = {
const uploadService = strapi.plugins.upload.services.upload; const uploadService = strapi.plugins.upload.services.upload;
// Retrieve provider configuration. // Retrieve provider configuration.
const config = await strapi const config = await uploadService.getConfig();
.store({
environment: strapi.config.environment,
type: 'plugin',
name: 'upload',
})
.get({ key: 'provider' });
// Verify if the file upload is enable. // Verify if the file upload is enable.
if (config.enabled === false) { if (config.enabled === false) {
@ -131,13 +125,19 @@ module.exports = {
}, },
async updateSettings(ctx) { async updateSettings(ctx) {
const {
request: { body: newSettings },
} = ctx;
await strapi await strapi
.store({ .store({
environment: ctx.params.environment, environment: ctx.params.environment,
type: 'plugin', type: 'plugin',
name: 'upload', name: 'upload',
}) })
.set({ key: 'provider', value: ctx.request.body }); .set({
key: 'provider',
value: { ...newSettings, sizeLimit: parseFloat(newSettings.sizeLimit) },
});
ctx.send({ ok: true }); ctx.send({ ok: true });
}, },
@ -208,10 +208,9 @@ const searchQueries = {
return ({ id }) => { return ({ id }) => {
return model return model
.query(qb => { .query(qb => {
qb.whereRaw('LOWER(hash) LIKE ?', [`%${id}%`]).orWhereRaw( qb.whereRaw('LOWER(hash) LIKE ?', [
'LOWER(name) LIKE ?', `%${id}%`,
[`%${id}%`] ]).orWhereRaw('LOWER(name) LIKE ?', [`%${id}%`]);
);
}) })
.fetchAll() .fetchAll()
.then(results => results.toJSON()); .then(results => results.toJSON());

View File

@ -176,4 +176,15 @@ module.exports = {
}) })
); );
}, },
async getConfig() {
const config = await strapi
.store({
environment: strapi.config.environment,
type: 'plugin',
name: 'upload',
})
.get({ key: 'provider' });
return { ...config, sizeLimit: parseFloat(config.sizeLimit) };
},
}; };

817
yarn.lock

File diff suppressed because it is too large Load Diff