Fix general settings global udpdates

This commit is contained in:
Alexandre Bodin 2019-07-22 17:31:20 +02:00
parent 85762551aa
commit 128b26f1ee
3 changed files with 14 additions and 28 deletions

View File

@ -25,8 +25,9 @@ module.exports = {
strapi.plugins['content-manager'].services.contenttypes;
const configurations = await storeUtils.getAllConfigurations();
await Promise.all(
configurations.map(({ value }) => {
configurations.map(value => {
const { uid, source } = value;
const settings = {
...value.settings,

View File

@ -2,7 +2,14 @@
const _ = require('lodash');
const pickSchemaFields = model => _.pick(model, []);
const pickSchemaFields = model =>
_.pick(model, [
'connection',
'collectionName',
'info',
'options',
'attributes',
]);
module.exports = {
pickSchemaFields,

View File

@ -15,31 +15,6 @@ const getStore = () => {
});
};
function getAllConfigurationsQuery({ model }) {
if (model.orm === 'mongoose') {
return model
.find({
$regex: `plugin_content_manager_configuration.*`,
})
.then(results =>
results.map(({ key, value }) => ({ key, value: JSON.parse(value) }))
);
}
return model
.query(qb => {
qb.where('key', 'like', `plugin_content_manager_configuration%`);
})
.fetchAll()
.then(config => config && config.toJSON())
.then(results =>
results.map(({ key, value }) => ({ key, value: JSON.parse(value) }))
);
}
const getAllConfigurations = () =>
strapi.query('core_store').custom(getAllConfigurationsQuery)();
/** General settings */
const getGeneralSettings = () =>
@ -99,7 +74,7 @@ function findByKeyQuery({ model }, key) {
if (model.orm === 'mongoose') {
return model
.find({
$regex: `${key}.*`,
key: { $regex: `${key}.*` },
})
.then(results => results.map(({ value }) => JSON.parse(value)));
}
@ -115,6 +90,9 @@ function findByKeyQuery({ model }, key) {
const findByKey = key => strapi.query('core_store').custom(findByKeyQuery)(key);
const getAllConfigurations = () =>
findByKey('plugin_content_manager_configuration');
module.exports = {
getGeneralSettings,
setGeneralSettings,