mirror of
https://github.com/strapi/strapi.git
synced 2025-08-01 21:36:25 +00:00
Remove Arrow functions in render SettingsPage
This commit is contained in:
parent
977406d7ba
commit
20224d3f90
@ -9,13 +9,15 @@ import { FormattedMessage } from 'react-intl';
|
|||||||
|
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
|
||||||
|
const renderMsg = msg => <p>{msg}</p>;
|
||||||
|
|
||||||
const Block = ({ children, description, style, title }) => (
|
const Block = ({ children, description, style, title }) => (
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<div className={styles.ctmBlock} style={style}>
|
<div className={styles.ctmBlock} style={style}>
|
||||||
<div className={styles.ctmBlockTitle}>
|
<div className={styles.ctmBlockTitle}>
|
||||||
<FormattedMessage id={title} />
|
<FormattedMessage id={title} />
|
||||||
<FormattedMessage id={description}>
|
<FormattedMessage id={description}>
|
||||||
{msg => <p>{msg}</p>}
|
{renderMsg}
|
||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
</div>
|
</div>
|
||||||
{children}
|
{children}
|
||||||
|
@ -97,6 +97,10 @@ class DraggableAttr extends React.Component {
|
|||||||
this.props.onClickEditListItem(this.props.index);
|
this.props.onClickEditListItem(this.props.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDragEnd = () => this.setState({ dragStart: false });
|
||||||
|
|
||||||
|
handleDragStart = () => this.setState({ dragStart: true });
|
||||||
|
|
||||||
handleMouseEnter = () => {
|
handleMouseEnter = () => {
|
||||||
if (!this.props.isDraggingSibling) {
|
if (!this.props.isDraggingSibling) {
|
||||||
this.setState({ isOver: true });
|
this.setState({ isOver: true });
|
||||||
@ -123,8 +127,8 @@ class DraggableAttr extends React.Component {
|
|||||||
connectDropTarget(
|
connectDropTarget(
|
||||||
<div
|
<div
|
||||||
className={cn(className, isEditing && styles.editingAttr, overClass)}
|
className={cn(className, isEditing && styles.editingAttr, overClass)}
|
||||||
onDragStart={() => this.setState({ dragStart: true })}
|
onDragStart={this.handleDragStart}
|
||||||
onDragEnd={() => this.setState({ dragStart: false })}
|
onDragEnd={this.handleDragEnd}
|
||||||
onMouseEnter={this.handleMouseEnter}
|
onMouseEnter={this.handleMouseEnter}
|
||||||
onMouseLeave={this.handleMouseLeave}
|
onMouseLeave={this.handleMouseLeave}
|
||||||
onClick={this.handleClickEdit}
|
onClick={this.handleClickEdit}
|
||||||
|
@ -92,6 +92,11 @@ class SettingsPage extends React.PureComponent {
|
|||||||
this.props.history.push(`${pathname}${destination}`);
|
this.props.history.push(`${pathname}${destination}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleConfirmReset = () => {
|
||||||
|
this.props.onReset();
|
||||||
|
this.toggleWarningCancel();
|
||||||
|
}
|
||||||
|
|
||||||
handleReset = (e) => {
|
handleReset = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.setState({ showWarningCancel: true });
|
this.setState({ showWarningCancel: true });
|
||||||
@ -106,6 +111,17 @@ class SettingsPage extends React.PureComponent {
|
|||||||
|
|
||||||
toggleWarningCancel = () => this.setState(prevState => ({ showWarningCancel: !prevState.showWarningCancel }));
|
toggleWarningCancel = () => this.setState(prevState => ({ showWarningCancel: !prevState.showWarningCancel }));
|
||||||
|
|
||||||
|
renderForm = input => (
|
||||||
|
<Input
|
||||||
|
key={input.name}
|
||||||
|
onChange={this.props.onChange}
|
||||||
|
value={this.getValue(input)}
|
||||||
|
{...input}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
renderRow = model => <SettingsRow key={model.name} {...model} onClick={this.handleClick} />;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { showWarning, showWarningCancel } = this.state;
|
const { showWarning, showWarningCancel } = this.state;
|
||||||
const { onChange, onReset, onSubmit } = this.props;
|
const { onChange, onReset, onSubmit } = this.props;
|
||||||
@ -127,9 +143,7 @@ class SettingsPage extends React.PureComponent {
|
|||||||
confirm: 'content-manager.popUpWarning.button.confirm',
|
confirm: 'content-manager.popUpWarning.button.confirm',
|
||||||
}}
|
}}
|
||||||
popUpWarningType="danger"
|
popUpWarningType="danger"
|
||||||
onConfirm={() => {
|
onConfirm={onSubmit}
|
||||||
onSubmit();
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<PopUpWarning
|
<PopUpWarning
|
||||||
isOpen={showWarningCancel}
|
isOpen={showWarningCancel}
|
||||||
@ -141,10 +155,7 @@ class SettingsPage extends React.PureComponent {
|
|||||||
confirm: 'content-manager.popUpWarning.button.confirm',
|
confirm: 'content-manager.popUpWarning.button.confirm',
|
||||||
}}
|
}}
|
||||||
popUpWarningType="danger"
|
popUpWarningType="danger"
|
||||||
onConfirm={() => {
|
onConfirm={this.handleConfirmReset}
|
||||||
onReset();
|
|
||||||
this.toggleWarningCancel();
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<div className={cn('row', styles.container)}>
|
<div className={cn('row', styles.container)}>
|
||||||
<Block
|
<Block
|
||||||
@ -155,27 +166,22 @@ class SettingsPage extends React.PureComponent {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-10">
|
<div className="col-md-10">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{forms.inputs.map(input => (
|
{forms.inputs.map(this.renderForm)}
|
||||||
<Input
|
|
||||||
key={input.name}
|
|
||||||
onChange={onChange}
|
|
||||||
value={this.getValue(input)}
|
|
||||||
{...input}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Block>
|
</Block>
|
||||||
|
{/* LIST */}
|
||||||
<Block
|
<Block
|
||||||
title="content-manager.containers.SettingsPage.Block.contentType.title"
|
title="content-manager.containers.SettingsPage.Block.contentType.title"
|
||||||
description="content-manager.containers.SettingsPage.Block.contentType.description"
|
description="content-manager.containers.SettingsPage.Block.contentType.description"
|
||||||
>
|
>
|
||||||
<div className={styles.contentTypesWrapper}>
|
<div className={styles.contentTypesWrapper}>
|
||||||
{this.getModels().map(model => <SettingsRow key={model.name} {...model} onClick={this.handleClick} />)}
|
{this.getModels().map(this.renderRow)}
|
||||||
</div>
|
</div>
|
||||||
</Block>
|
</Block>
|
||||||
|
{/* LIST */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user