mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 03:07:32 +00:00
Prevent the ctb from breaking if a user tries to edit an attribute that it cannot currently handle
This commit is contained in:
parent
d78c0a0200
commit
c6b24f046b
@ -26,6 +26,8 @@ import List from 'components/List';
|
|||||||
import NoTableWarning from 'components/NoTableWarning';
|
import NoTableWarning from 'components/NoTableWarning';
|
||||||
import PluginLeftMenu from 'components/PluginLeftMenu';
|
import PluginLeftMenu from 'components/PluginLeftMenu';
|
||||||
|
|
||||||
|
import forms from 'containers/Form/forms.json';
|
||||||
|
|
||||||
import injectSaga from 'utils/injectSaga';
|
import injectSaga from 'utils/injectSaga';
|
||||||
import injectReducer from 'utils/injectReducer';
|
import injectReducer from 'utils/injectReducer';
|
||||||
|
|
||||||
@ -46,6 +48,9 @@ import reducer from './reducer';
|
|||||||
import selectModelPage from './selectors';
|
import selectModelPage from './selectors';
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
|
||||||
|
// Array of attributes that the ctb can handle at the moment
|
||||||
|
const availableAttributes = Object.keys(forms.attribute);
|
||||||
|
|
||||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||||
/* eslint-disable react/jsx-wrap-multilines */
|
/* eslint-disable react/jsx-wrap-multilines */
|
||||||
|
|
||||||
@ -174,8 +179,8 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
|||||||
const index = findIndex(this.props.modelPage.model.attributes, ['name', attributeName]);
|
const index = findIndex(this.props.modelPage.model.attributes, ['name', attributeName]);
|
||||||
const attribute = this.props.modelPage.model.attributes[index];
|
const attribute = this.props.modelPage.model.attributes[index];
|
||||||
|
|
||||||
// Remove enumeration type because it's not supported by this plugin for the moment.
|
// Display a notification if the attribute is not present in the ones that the ctb handles
|
||||||
if (attribute.params.type === 'enumeration') {
|
if (!includes(availableAttributes, attribute.params.type)) {
|
||||||
return strapi.notification.info('content-type-builder.notification.info.enumeration');
|
return strapi.notification.info('content-type-builder.notification.info.enumeration');
|
||||||
}
|
}
|
||||||
const settingsType = attribute.params.type ? 'baseSettings' : 'defineRelation';
|
const settingsType = attribute.params.type ? 'baseSettings' : 'defineRelation';
|
||||||
@ -294,6 +299,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
|||||||
onButtonClick={this.handleClickAddAttribute}
|
onButtonClick={this.handleClickAddAttribute}
|
||||||
/>;
|
/>;
|
||||||
const icoType = includes(this.props.match.params.modelName, '&source=') ? '' : 'pencil';
|
const icoType = includes(this.props.match.params.modelName, '&source=') ? '' : 'pencil';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.modelPage}>
|
<div className={styles.modelPage}>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user