mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Delay admin load and handle relation between plugin and main models
This commit is contained in:
		
							parent
							
								
									9409a39fc8
								
							
						
					
					
						commit
						f9cc9b504c
					
				| @ -43,9 +43,6 @@ import { translationMessages, languages } from './i18n'; | ||||
| import { findIndex } from 'lodash'; | ||||
| /* eslint-enable */ | ||||
| 
 | ||||
| // Retrieve plugins from config.
 | ||||
| let appPlugins = plugins; | ||||
| 
 | ||||
| // Create redux store with history
 | ||||
| const initialState = {}; | ||||
| const history = createHistory({ | ||||
| @ -95,7 +92,9 @@ if (window.location.port !== '4000') { | ||||
|       return response.json(); | ||||
|     }) | ||||
|     .then(plugins => { | ||||
|       appPlugins = plugins || []; | ||||
|       if (findIndex(plugins, ['id', 'users-permissions']) === -1) { | ||||
|         store.dispatch(setHasUserPlugin()); | ||||
|       } | ||||
| 
 | ||||
|       (plugins || []).forEach(plugin => { | ||||
|         const script = document.createElement('script'); | ||||
| @ -125,15 +124,13 @@ if (window.location.port !== '4000') { | ||||
|     .catch(err => { | ||||
|       console.log(err); | ||||
|     }); | ||||
| } else if (findIndex(plugins, ['id', 'users-permissions']) === -1) { | ||||
|   store.dispatch(setHasUserPlugin()); | ||||
| } | ||||
| 
 | ||||
| // const isPluginAllowedToRegister = (plugin) => true;
 | ||||
| const isPluginAllowedToRegister = (plugin) => plugin.id === 'users-permissions' || plugin.id === 'email' || auth.getToken(); | ||||
| 
 | ||||
| /** | ||||
|  * Public Strapi object exposed to the `window` object | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * Register a plugin | ||||
|  * | ||||
| @ -178,9 +175,10 @@ const displayNotification = (message, status) => { | ||||
|   store.dispatch(showNotification(message, status)); | ||||
| }; | ||||
| 
 | ||||
| if (findIndex(appPlugins, ['id', 'users-permissions']) === -1) { | ||||
|   store.dispatch(setHasUserPlugin()); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Public Strapi object exposed to the `window` object | ||||
|  */ | ||||
| 
 | ||||
| window.strapi = Object.assign(window.strapi || {}, { | ||||
|   remoteURL: devFrontURL || remoteURL, | ||||
|  | ||||
| @ -15,14 +15,6 @@ | ||||
|       "test": "http://localhost:1337/admin/content-type-builder/main.js" | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     "id": "email", | ||||
|     "source": { | ||||
|       "development": "http://localhost:1337/admin/email/main.js", | ||||
|       "production": "http://localhost:1337/admin/email/main.js", | ||||
|       "test": "http://localhost:1337/admin/email/main.js" | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     "id": "settings-manager", | ||||
|     "source": { | ||||
| @ -30,13 +22,5 @@ | ||||
|       "production": "http://localhost:1337/admin/settings-manager/main.js", | ||||
|       "test": "http://localhost:1337/admin/settings-manager/main.js" | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     "id": "users-permissions", | ||||
|     "source": { | ||||
|       "development": "http://localhost:1337/admin/users-permissions/main.js", | ||||
|       "production": "http://localhost:1337/admin/users-permissions/main.js", | ||||
|       "test": "http://localhost:1337/admin/users-permissions/main.js" | ||||
|     } | ||||
|   } | ||||
| ] | ||||
| @ -42,10 +42,9 @@ export const generateMenu = function () { | ||||
| 
 | ||||
| export function* getModels() { | ||||
|   try { | ||||
|     const response = yield call(request, | ||||
|       `${strapi.backendURL}/content-manager/models`, { | ||||
|         method: 'GET', | ||||
|       }); | ||||
|     const response = yield call(request, `/content-manager/models`, { | ||||
|       method: 'GET', | ||||
|     }); | ||||
| 
 | ||||
|     yield put(loadedModels(response)); | ||||
|   } catch (err) { | ||||
|  | ||||
| @ -36,12 +36,18 @@ const generateSchema = (responses) => { | ||||
|     if (model.associations) { | ||||
|       // Model relations
 | ||||
|       schemaModel.relations = model.associations.reduce((acc, current) => { | ||||
|         const displayedAttribute = current.plugin ? | ||||
|           get(responses.plugins, [current.plugin, 'models', current.model || current.collection, 'info', 'mainField']) || | ||||
|           findKey(get(responses.plugins, [current.plugin, 'models', current.model || current.collection, 'attributes']), { type : 'string'}) || | ||||
|           'id' : | ||||
|           get(responses.models, [current.model || current.collection, 'info', 'mainField']) || | ||||
|           findKey(get(responses.models, [current.model || current.collection, 'attributes']), { type : 'string'}) || | ||||
|           'id'; | ||||
| 
 | ||||
|         acc[current.alias] = { | ||||
|           ...current, | ||||
|           description: '', | ||||
|           displayedAttribute: get(models[current.model || current.collection], 'info.mainField') || | ||||
|             findKey(models[current.model || current.collection].attributes, { type : 'string'}) || | ||||
|             'id', | ||||
|           displayedAttribute, | ||||
|         }; | ||||
| 
 | ||||
|         return acc; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aurelsicoko
						Aurelsicoko