refactor: Rename @strapi/icons imports
parent
835fbe17af
commit
ecb580ec95
|
@ -5,7 +5,7 @@ import { Flex } from '@strapi/design-system/Flex';
|
||||||
import { Text } from '@strapi/design-system/Text';
|
import { Text } from '@strapi/design-system/Text';
|
||||||
import { Stack } from '@strapi/design-system/Stack';
|
import { Stack } from '@strapi/design-system/Stack';
|
||||||
import { Button } from '@strapi/design-system/Button';
|
import { Button } from '@strapi/design-system/Button';
|
||||||
import DeleteIcon from '@strapi/icons/DeleteIcon';
|
import DeleteIcon from '@strapi/icons/Delete';
|
||||||
import AlertWarningIcon from '@strapi/icons/AlertWarningIcon';
|
import AlertWarningIcon from '@strapi/icons/AlertWarningIcon';
|
||||||
|
|
||||||
import getTrad from '../../helpers/getTrad';
|
import getTrad from '../../helpers/getTrad';
|
||||||
|
|
|
@ -2,7 +2,7 @@ const { logMessage, sanitizeConfig } = require('../utils');
|
||||||
const difference = require('../utils/getObjectDiff');
|
const difference = require('../utils/getObjectDiff');
|
||||||
|
|
||||||
const ConfigType = class ConfigType {
|
const ConfigType = class ConfigType {
|
||||||
constructor(queryString, configPrefix, uid, jsonFields) {
|
constructor(queryString, configPrefix, uid, jsonFields, relations) {
|
||||||
if (!queryString) {
|
if (!queryString) {
|
||||||
strapi.log.error(logMessage('Query string is missing for ConfigType'));
|
strapi.log.error(logMessage('Query string is missing for ConfigType'));
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ const ConfigType = class ConfigType {
|
||||||
this.configPrefix = configPrefix;
|
this.configPrefix = configPrefix;
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
this.jsonFields = jsonFields || [];
|
this.jsonFields = jsonFields || [];
|
||||||
|
this.relations = relations || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,24 +20,31 @@ const AdminRolePermissionsConfigType = class AdminRolePermissionsConfigType exte
|
||||||
.findOne({ where: { [this.uid]: configName } });
|
.findOne({ where: { [this.uid]: configName } });
|
||||||
|
|
||||||
if (existingConfig && configContent === null) {
|
if (existingConfig && configContent === null) {
|
||||||
await queryAPI.delete({ where: { [this.uid]: configName } });
|
await queryAPI.delete({
|
||||||
|
where: { [this.uid]: configName },
|
||||||
|
populate: this.relations.map(({ relationName }) => relationName),
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existingConfig) {
|
if (!existingConfig) {
|
||||||
const { permissions } = configContent;
|
// Format JSON fields.
|
||||||
delete configContent.permissions;
|
|
||||||
const query = { ...configContent };
|
const query = { ...configContent };
|
||||||
this.jsonFields.map((field) => query[field] = JSON.stringify(configContent[field]));
|
this.jsonFields.map((field) => query[field] = JSON.stringify(configContent[field]));
|
||||||
const newConfig = await queryAPI.create({ data: query });
|
|
||||||
await strapi.admin.services.role.assignPermissions(newConfig.id, permissions);
|
this.relations.map(({ queryString }) => {
|
||||||
|
const queryAPI = strapi.query(queryString);
|
||||||
|
|
||||||
|
// Compare relations
|
||||||
|
// Make changes to the db
|
||||||
|
});
|
||||||
|
|
||||||
|
await queryAPI.create({ data: query });
|
||||||
} else {
|
} else {
|
||||||
await strapi.admin.services.role.assignPermissions(existingConfig.id, configContent.permissions);
|
|
||||||
delete configContent.permissions;
|
|
||||||
const query = { ...configContent };
|
const query = { ...configContent };
|
||||||
this.jsonFields.map((field) => query[field] = JSON.stringify(configContent[field]));
|
this.jsonFields.map((field) => query[field] = JSON.stringify(configContent[field]));
|
||||||
await queryAPI.update({ where: { [this.uid]: configName }, data: query });
|
await queryAPI.update({ where: { [this.uid]: configName }, data: { ...query } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,14 @@ module.exports = {
|
||||||
'i18n-locale': new ConfigType('plugin::i18n.locale', 'i18n-locale', 'code'),
|
'i18n-locale': new ConfigType('plugin::i18n.locale', 'i18n-locale', 'code'),
|
||||||
'core-store': new ConfigType('strapi::core-store', 'core-store', 'key', ['value']),
|
'core-store': new ConfigType('strapi::core-store', 'core-store', 'key', ['value']),
|
||||||
'user-role': new UserRoleConfigType('plugin::users-permissions.role', 'user-role', 'type'),
|
'user-role': new UserRoleConfigType('plugin::users-permissions.role', 'user-role', 'type'),
|
||||||
'admin-role': new AdminRoleConfigType('admin::role', 'admin-role', 'code'),
|
'admin-role': new AdminRoleConfigType(
|
||||||
|
'admin::role',
|
||||||
|
'admin-role',
|
||||||
|
'code',
|
||||||
|
[],
|
||||||
|
[{
|
||||||
|
queryString: 'admin::permission',
|
||||||
|
relationName: 'permissions',
|
||||||
|
}]
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue