mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +00:00 
			
		
		
		
	Fix general settings global udpdates
This commit is contained in:
		
							parent
							
								
									85762551aa
								
							
						
					
					
						commit
						128b26f1ee
					
				| @ -25,8 +25,9 @@ module.exports = { | |||||||
|       strapi.plugins['content-manager'].services.contenttypes; |       strapi.plugins['content-manager'].services.contenttypes; | ||||||
| 
 | 
 | ||||||
|     const configurations = await storeUtils.getAllConfigurations(); |     const configurations = await storeUtils.getAllConfigurations(); | ||||||
|  | 
 | ||||||
|     await Promise.all( |     await Promise.all( | ||||||
|       configurations.map(({ value }) => { |       configurations.map(value => { | ||||||
|         const { uid, source } = value; |         const { uid, source } = value; | ||||||
|         const settings = { |         const settings = { | ||||||
|           ...value.settings, |           ...value.settings, | ||||||
|  | |||||||
| @ -2,7 +2,14 @@ | |||||||
| 
 | 
 | ||||||
| const _ = require('lodash'); | const _ = require('lodash'); | ||||||
| 
 | 
 | ||||||
| const pickSchemaFields = model => _.pick(model, []); | const pickSchemaFields = model => | ||||||
|  |   _.pick(model, [ | ||||||
|  |     'connection', | ||||||
|  |     'collectionName', | ||||||
|  |     'info', | ||||||
|  |     'options', | ||||||
|  |     'attributes', | ||||||
|  |   ]); | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|   pickSchemaFields, |   pickSchemaFields, | ||||||
|  | |||||||
| @ -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 */ | /** General settings */ | ||||||
| 
 | 
 | ||||||
| const getGeneralSettings = () => | const getGeneralSettings = () => | ||||||
| @ -99,7 +74,7 @@ function findByKeyQuery({ model }, key) { | |||||||
|   if (model.orm === 'mongoose') { |   if (model.orm === 'mongoose') { | ||||||
|     return model |     return model | ||||||
|       .find({ |       .find({ | ||||||
|         $regex: `${key}.*`, |         key: { $regex: `${key}.*` }, | ||||||
|       }) |       }) | ||||||
|       .then(results => results.map(({ value }) => JSON.parse(value))); |       .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 findByKey = key => strapi.query('core_store').custom(findByKeyQuery)(key); | ||||||
| 
 | 
 | ||||||
|  | const getAllConfigurations = () => | ||||||
|  |   findByKey('plugin_content_manager_configuration'); | ||||||
|  | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|   getGeneralSettings, |   getGeneralSettings, | ||||||
|   setGeneralSettings, |   setGeneralSettings, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Alexandre Bodin
						Alexandre Bodin