mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +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 PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { capitalize } from 'lodash';
|
||||
import { capitalize, has } from 'lodash';
|
||||
|
||||
import PopUpWarning from 'components/PopUpWarning';
|
||||
import IcoContainer from 'components/IcoContainer';
|
||||
@ -66,6 +66,7 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer
|
||||
}
|
||||
|
||||
render() {
|
||||
const isNotEditable = has(this.props.row.params, 'configurable') && !this.props.row.params.configurable;
|
||||
const relationType = 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 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 (
|
||||
<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.nameContainer}>
|
||||
{this.renderAttributesBox()}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
.attributeRow { /* stylelint-disable */
|
||||
cursor: pointer;
|
||||
min-height: 5.3rem;
|
||||
margin-top: 0!important;
|
||||
list-style: none;
|
||||
@ -10,9 +9,14 @@
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.editable {
|
||||
&:hover {
|
||||
background-color: #F7F8F8;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.flex {
|
||||
|
||||
@ -147,7 +147,8 @@ export function* submitChanges(action) {
|
||||
}
|
||||
|
||||
} 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