|
2 | 2 |
|
3 | 3 | const ConfigType = require("./type"); |
4 | 4 |
|
5 | | -module.exports = { |
6 | | - 'i18n-locale': new ConfigType('plugin::i18n.locale', 'i18n-locale', 'code'), |
7 | | - 'core-store': new ConfigType('strapi::core-store', 'core-store', 'key', ['value']), |
8 | | - 'user-role': new ConfigType( |
9 | | - 'plugin::users-permissions.role', |
10 | | - 'user-role', |
11 | | - 'type', |
12 | | - [], |
13 | | - [{ |
14 | | - queryString: 'plugin::users-permissions.permission', |
15 | | - relationName: 'permissions', |
16 | | - parentName: 'role', |
17 | | - relationSortField: 'action', |
18 | | - }] |
19 | | - ), |
20 | | - 'admin-role': new ConfigType( |
21 | | - 'admin::role', |
22 | | - 'admin-role', |
23 | | - 'code', |
24 | | - [], |
25 | | - [{ |
26 | | - queryString: 'admin::permission', |
27 | | - relationName: 'permissions', |
28 | | - parentName: 'role', |
29 | | - relationSortField: 'action', |
30 | | - }] |
31 | | - ), |
| 5 | +const types = (strapi) => { |
| 6 | + const typesObject = { |
| 7 | + 'i18n-locale': new ConfigType('plugin::i18n.locale', 'i18n-locale', 'code'), |
| 8 | + 'core-store': new ConfigType('strapi::core-store', 'core-store', 'key', ['value']), |
| 9 | + 'user-role': new ConfigType( |
| 10 | + 'plugin::users-permissions.role', |
| 11 | + 'user-role', |
| 12 | + 'type', |
| 13 | + [], |
| 14 | + [{ |
| 15 | + queryString: 'plugin::users-permissions.permission', |
| 16 | + relationName: 'permissions', |
| 17 | + parentName: 'role', |
| 18 | + relationSortField: 'action', |
| 19 | + }], |
| 20 | + ), |
| 21 | + 'admin-role': new ConfigType( |
| 22 | + 'admin::role', |
| 23 | + 'admin-role', |
| 24 | + 'code', |
| 25 | + [], |
| 26 | + [{ |
| 27 | + queryString: 'admin::permission', |
| 28 | + relationName: 'permissions', |
| 29 | + parentName: 'role', |
| 30 | + relationSortField: 'action', |
| 31 | + }], |
| 32 | + ), |
| 33 | + }; |
| 34 | + |
| 35 | + // Remove types for which the corresponding plugin is not installed. |
| 36 | + Object.keys(typesObject).map((type) => { |
| 37 | + if (type === 'i18n-locale' && !strapi.plugin('i18n')) { |
| 38 | + delete typesObject[type]; |
| 39 | + } |
| 40 | + |
| 41 | + if (type === 'user-role' && !strapi.plugin('users-permissions')) { |
| 42 | + delete typesObject[type]; |
| 43 | + } |
| 44 | + }); |
| 45 | + |
| 46 | + return typesObject; |
32 | 47 | }; |
| 48 | + |
| 49 | +module.exports = types; |
0 commit comments