mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 06:40:42 +00:00
Chore: Remove component icon validation from backend
This commit is contained in:
parent
287787a550
commit
4d4c3e90cd
@ -28,7 +28,6 @@ describe('Component validator', () => {
|
|||||||
component: {
|
component: {
|
||||||
category: 'default',
|
category: 'default',
|
||||||
displayName: 'mycompo',
|
displayName: 'mycompo',
|
||||||
icon: 'american-sign-language-interpreting',
|
|
||||||
attributes: {
|
attributes: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -50,7 +49,6 @@ describe('Component validator', () => {
|
|||||||
component: {
|
component: {
|
||||||
category: 'default',
|
category: 'default',
|
||||||
displayName: 'mycompo',
|
displayName: 'mycompo',
|
||||||
icon: 'american-sign-language-interpreting',
|
|
||||||
attributes: {
|
attributes: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -74,7 +72,6 @@ describe('Component validator', () => {
|
|||||||
component: {
|
component: {
|
||||||
category: 'default',
|
category: 'default',
|
||||||
displayName: 'mycompo',
|
displayName: 'mycompo',
|
||||||
icon: 'american-sign-language-interpreting',
|
|
||||||
attributes: {
|
attributes: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
|||||||
@ -122,7 +122,6 @@ describe('Content type validator', () => {
|
|||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
uid: 'edit',
|
uid: 'edit',
|
||||||
icon: 'star',
|
|
||||||
displayName: 'test',
|
displayName: 'test',
|
||||||
category: 'test',
|
category: 'test',
|
||||||
attributes: {
|
attributes: {
|
||||||
@ -134,7 +133,6 @@ describe('Content type validator', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
tmpUID: 'random',
|
tmpUID: 'random',
|
||||||
icon: 'star',
|
|
||||||
displayName: 'test2',
|
displayName: 'test2',
|
||||||
category: 'test',
|
category: 'test',
|
||||||
attributes: {
|
attributes: {
|
||||||
|
|||||||
@ -13,7 +13,6 @@ const validators = {
|
|||||||
const NAME_REGEX = /^[A-Za-z][_0-9A-Za-z]*$/;
|
const NAME_REGEX = /^[A-Za-z][_0-9A-Za-z]*$/;
|
||||||
const COLLECTION_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
|
const COLLECTION_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
|
||||||
const CATEGORY_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
|
const CATEGORY_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
|
||||||
const ICON_REGEX = /^[A-Za-z0-9][-A-Za-z0-9]*$/;
|
|
||||||
const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
||||||
|
|
||||||
const isValidName = {
|
const isValidName = {
|
||||||
@ -40,12 +39,6 @@ const isValidCollectionName = {
|
|||||||
test: (val) => val === '' || COLLECTION_NAME_REGEX.test(val),
|
test: (val) => val === '' || COLLECTION_NAME_REGEX.test(val),
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidIcon = {
|
|
||||||
name: 'isValidIcon',
|
|
||||||
message: `\${path} must match the following regex: ${ICON_REGEX}`,
|
|
||||||
test: (val) => val === '' || ICON_REGEX.test(val),
|
|
||||||
};
|
|
||||||
|
|
||||||
const isValidKey = (key) => ({
|
const isValidKey = (key) => ({
|
||||||
name: 'isValidKey',
|
name: 'isValidKey',
|
||||||
message: `Attribute name '${key}' must match the following regex: ${NAME_REGEX}`,
|
message: `Attribute name '${key}' must match the following regex: ${NAME_REGEX}`,
|
||||||
@ -103,7 +96,6 @@ module.exports = {
|
|||||||
isValidCategoryName,
|
isValidCategoryName,
|
||||||
isValidDefaultJSON,
|
isValidDefaultJSON,
|
||||||
isValidName,
|
isValidName,
|
||||||
isValidIcon,
|
|
||||||
isValidKey,
|
isValidKey,
|
||||||
isValidEnum,
|
isValidEnum,
|
||||||
isValidUID,
|
isValidUID,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const _ = require('lodash');
|
|||||||
const { yup, validateYupSchema } = require('@strapi/utils');
|
const { yup, validateYupSchema } = require('@strapi/utils');
|
||||||
|
|
||||||
const { modelTypes, DEFAULT_TYPES } = require('../../services/constants');
|
const { modelTypes, DEFAULT_TYPES } = require('../../services/constants');
|
||||||
const { isValidCategoryName, isValidIcon } = require('./common');
|
const { isValidCategoryName } = require('./common');
|
||||||
const createSchema = require('./model-schema');
|
const createSchema = require('./model-schema');
|
||||||
const { removeEmptyDefaults } = require('./data-transform');
|
const { removeEmptyDefaults } = require('./data-transform');
|
||||||
|
|
||||||
@ -16,7 +16,6 @@ const componentSchema = createSchema(VALID_TYPES, VALID_RELATIONS, {
|
|||||||
})
|
})
|
||||||
.shape({
|
.shape({
|
||||||
displayName: yup.string().min(1).required('displayName.required'),
|
displayName: yup.string().min(1).required('displayName.required'),
|
||||||
icon: yup.string().nullable().test(isValidIcon),
|
|
||||||
category: yup.string().nullable().test(isValidCategoryName).required('category.required'),
|
category: yup.string().nullable().test(isValidCategoryName).required('category.required'),
|
||||||
})
|
})
|
||||||
.required()
|
.required()
|
||||||
|
|||||||
@ -18,7 +18,6 @@ const formatComponent = (component) => {
|
|||||||
category,
|
category,
|
||||||
apiId: modelName,
|
apiId: modelName,
|
||||||
schema: {
|
schema: {
|
||||||
icon: _.get(info, 'icon'),
|
|
||||||
displayName: _.get(info, 'displayName'),
|
displayName: _.get(info, 'displayName'),
|
||||||
description: _.get(info, 'description', ''),
|
description: _.get(info, 'description', ''),
|
||||||
connection,
|
connection,
|
||||||
|
|||||||
@ -51,7 +51,6 @@ module.exports = function createComponentBuilder() {
|
|||||||
.setUID(uid)
|
.setUID(uid)
|
||||||
.set('collectionName', collectionName)
|
.set('collectionName', collectionName)
|
||||||
.set(['info', 'displayName'], infos.displayName)
|
.set(['info', 'displayName'], infos.displayName)
|
||||||
.set(['info', 'icon'], infos.icon)
|
|
||||||
.set(['info', 'description'], infos.description)
|
.set(['info', 'description'], infos.description)
|
||||||
.set('pluginOptions', infos.pluginOptions)
|
.set('pluginOptions', infos.pluginOptions)
|
||||||
.set('config', infos.config)
|
.set('config', infos.config)
|
||||||
@ -101,7 +100,6 @@ module.exports = function createComponentBuilder() {
|
|||||||
.setUID(newUID)
|
.setUID(newUID)
|
||||||
.setDir(newDir)
|
.setDir(newDir)
|
||||||
.set(['info', 'displayName'], infos.displayName)
|
.set(['info', 'displayName'], infos.displayName)
|
||||||
.set(['info', 'icon'], infos.icon)
|
|
||||||
.set(['info', 'description'], infos.description)
|
.set(['info', 'description'], infos.description)
|
||||||
.set('pluginOptions', infos.pluginOptions)
|
.set('pluginOptions', infos.pluginOptions)
|
||||||
.setAttributes(this.convertAttributes(newAttributes));
|
.setAttributes(this.convertAttributes(newAttributes));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user