Merge pull request #4227 from strapi/front/fix-ctb-issues

Add reserved content type names
This commit is contained in:
Alexandre BODIN 2019-10-15 11:25:30 +02:00 committed by GitHub
commit 0055b236a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -9,8 +9,18 @@ const Wrapper = styled.div`
}
.adminPageRightWrapper {
width: calc(100% - #{$left-menu-width});
width: ${props => `calc(100% - ${props.theme.main.sizes.leftMenu.width})`};
}
`;
Wrapper.defaultProps = {
theme: {
main: {
sizes: {
leftMenu: {},
},
},
},
};
export default Wrapper;

View File

@ -31,6 +31,7 @@ import IconGroup from '../../assets/icons/icon_type_groups.png';
import forms from './forms.json';
const NAVLINKS = [{ id: 'base' }, { id: 'advanced' }];
const RESERVED_NAMES = ['admin', 'series', 'file'];
class ModelForm extends React.Component {
// eslint-disable-line react/prefer-stateless-function
@ -98,6 +99,12 @@ class ModelForm extends React.Component {
);
let formErrors = {};
if (RESERVED_NAMES.includes(modifiedData.name)) {
formErrors = {
name: [{ id: `${pluginId}.error.contentTypeName.reserved-name` }],
};
}
if (alreadyTakenContentTypeNames.includes(modifiedData.name)) {
formErrors = {
name: [{ id: `${pluginId}.error.contentTypeName.taken` }],

View File

@ -32,6 +32,7 @@
"error.attribute.sameKeyAndName": "Can't be equal",
"error.attribute.taken": "This field name already exists",
"error.contentTypeName.taken": "This name already exists",
"error.contentTypeName.reserved-name": "This name cannot be used in your project as it might break other functionnalities",
"error.validation.max": "The value is too high.",
"error.validation.maxLength": "The value is too long.",
"error.validation.min": "The value is too low.",

View File

@ -31,6 +31,7 @@
"error.attribute.sameKeyAndName": "Ne peuvent pas être égaux",
"error.attribute.taken": "Ce champ existe déjà",
"error.contentTypeName.taken": "Ce nom existe déjà",
"error.contentTypeName.reserved-name": "Ce nom ne peut être utilisé",
"error.validation.max": "La valeur est trop grande.",
"error.validation.maxLength": "La valeur est trop longue.",
"error.validation.min": "La valeur est trop basse.",