mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 16:52:18 +00:00
Prevent user from editing not configurable attr
This commit is contained in:
parent
39d21388a3
commit
788894cf3a
@ -7,7 +7,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { capitalize } from 'lodash';
|
import { capitalize, has } from 'lodash';
|
||||||
|
|
||||||
import PopUpWarning from 'components/PopUpWarning';
|
import PopUpWarning from 'components/PopUpWarning';
|
||||||
import IcoContainer from 'components/IcoContainer';
|
import IcoContainer from 'components/IcoContainer';
|
||||||
@ -66,6 +66,7 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const isNotEditable = has(this.props.row.params, 'configurable') && !this.props.row.params.configurable;
|
||||||
const relationType = this.props.row.params.type ?
|
const relationType = this.props.row.params.type ?
|
||||||
<FormattedMessage id={`content-type-builder.attribute.${this.props.row.params.type}`} />
|
<FormattedMessage id={`content-type-builder.attribute.${this.props.row.params.type}`} />
|
||||||
: (
|
: (
|
||||||
@ -87,10 +88,16 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer
|
|||||||
);
|
);
|
||||||
|
|
||||||
const relationStyle = !this.props.row.params.type ? styles.relation : '';
|
const relationStyle = !this.props.row.params.type ? styles.relation : '';
|
||||||
const icons = [{ icoType: 'pencil', onClick: this.handleEdit }, { icoType: 'trash', onClick: () => this.setState({ showWarning: !this.state.showWarning }) }];
|
const icons = isNotEditable ? [{ icoType: 'lock' }] : [{ icoType: 'pencil', onClick: this.handleEdit }, { icoType: 'trash', onClick: () => this.setState({ showWarning: !this.state.showWarning }) }];
|
||||||
|
const editableStyle = isNotEditable ? '' : styles.editable;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={`${styles.attributeRow} ${relationStyle}`} onClick={this.handleEdit}>
|
<li
|
||||||
|
className={`${styles.attributeRow} ${editableStyle} ${relationStyle}`}
|
||||||
|
onClick={() => {
|
||||||
|
isNotEditable ? () => {} : this.handleEdit();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div className={styles.flex}>
|
<div className={styles.flex}>
|
||||||
<div className={styles.nameContainer}>
|
<div className={styles.nameContainer}>
|
||||||
{this.renderAttributesBox()}
|
{this.renderAttributesBox()}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
.attributeRow { /* stylelint-disable */
|
.attributeRow { /* stylelint-disable */
|
||||||
cursor: pointer;
|
|
||||||
min-height: 5.3rem;
|
min-height: 5.3rem;
|
||||||
margin-top: 0!important;
|
margin-top: 0!important;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
@ -10,9 +9,14 @@
|
|||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.editable {
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #F7F8F8;
|
background-color: #F7F8F8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
|
|||||||
@ -147,7 +147,8 @@ export function* submitChanges(action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
strapi.notification.error(error);
|
strapi.notification.error(get(error, ['response', 'payload', 'message'], 'notification.error'));
|
||||||
|
yield put(unsetButtonLoader());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user