Simplified the object needed for InputDescription and InputErros message

This commit is contained in:
cyril lopez 2018-02-02 16:12:30 +01:00
parent ced682764a
commit dc4e380787
4 changed files with 20 additions and 32 deletions

View File

@ -534,10 +534,8 @@ Component integrates Label, InputText, InputDescription and InputErrors.
render() { render() {
const { didCheckErrors, errors, foo } = this.state; const { didCheckErrors, errors, foo } = this.state;
const inputDescription = { const inputDescription = {
message: {
id: 'my-plugin.inputFoo.description', id: 'my-plugin.inputFoo.description',
params: { bar: 'Something' } params: { bar: 'Something' },
}
}; };
// This can also works (it's the same behavior for the label) // This can also works (it's the same behavior for the label)
@ -555,10 +553,10 @@ Component integrates Label, InputText, InputDescription and InputErrors.
inputDescription={inputDescription} inputDescription={inputDescription}
name="foo" name="foo"
onChange={this.handleChange} onChange={this.handleChange}
label={{ message: { label={{
id: 'my-plugin.inputFoo.label', id: 'my-plugin.inputFoo.label',
params: { name: <a href="strapi.io" target="_blank">Click me</a> } params: { name: <a href="strapi.io" target="_blank">Click me</a> }
}}} }}
value={foo} value={foo}
validations={{ required: true }} validations={{ required: true }}
/> />

View File

@ -83,7 +83,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
<Label <Label
className={labelClassName} className={labelClassName}
htmlFor={name} htmlFor={name}
message={this.props.label && this.props.label.message || this.props.label} message={this.props.label}
style={labelStyle} style={labelStyle}
/> />
<InputNumber <InputNumber
@ -103,7 +103,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
/> />
<InputDescription <InputDescription
className={inputDescriptionClassName} className={inputDescriptionClassName}
message={this.props.inputDescription && this.props.inputDescription.message || this.props.inputDescription} message={this.props.inputDescription}
style={inputDescriptionStyle} style={inputDescriptionStyle}
/> />
<InputErrors <InputErrors
@ -200,11 +200,9 @@ InputNumberWithErrors.propTypes = {
PropTypes.string, PropTypes.string,
PropTypes.func, PropTypes.func,
PropTypes.shape({ PropTypes.shape({
message: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
params: PropTypes.object, params: PropTypes.object,
}), }),
}),
]), ]),
inputDescriptionClassName: PropTypes.string, inputDescriptionClassName: PropTypes.string,
inputDescriptionStyle: PropTypes.object, inputDescriptionStyle: PropTypes.object,
@ -213,11 +211,9 @@ InputNumberWithErrors.propTypes = {
PropTypes.string, PropTypes.string,
PropTypes.func, PropTypes.func,
PropTypes.shape({ PropTypes.shape({
message: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
params: PropTypes.object, params: PropTypes.object,
}), }),
}),
]), ]),
labelClassName: PropTypes.string, labelClassName: PropTypes.string,
labelStyle: PropTypes.object, labelStyle: PropTypes.object,

View File

@ -83,7 +83,7 @@ class InputTextWithErrors extends React.Component { // eslint-disable-line react
<Label <Label
className={labelClassName} className={labelClassName}
htmlFor={name} htmlFor={name}
message={this.props.label && this.props.label.message || this.props.label} message={this.props.label}
style={labelStyle} style={labelStyle}
/> />
<InputText <InputText
@ -103,7 +103,7 @@ class InputTextWithErrors extends React.Component { // eslint-disable-line react
/> />
<InputDescription <InputDescription
className={inputDescriptionClassName} className={inputDescriptionClassName}
message={this.props.inputDescription && this.props.inputDescription.message || this.props.inputDescription} message={this.props.inputDescription}
style={inputDescriptionStyle} style={inputDescriptionStyle}
/> />
<InputErrors <InputErrors
@ -199,11 +199,9 @@ InputTextWithErrors.propTypes = {
PropTypes.string, PropTypes.string,
PropTypes.func, PropTypes.func,
PropTypes.shape({ PropTypes.shape({
message: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
params: PropTypes.object, params: PropTypes.object,
}), }),
}),
]), ]),
inputDescriptionClassName: PropTypes.string, inputDescriptionClassName: PropTypes.string,
inputDescriptionStyle: PropTypes.object, inputDescriptionStyle: PropTypes.object,
@ -212,11 +210,9 @@ InputTextWithErrors.propTypes = {
PropTypes.string, PropTypes.string,
PropTypes.func, PropTypes.func,
PropTypes.shape({ PropTypes.shape({
message: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
params: PropTypes.object, params: PropTypes.object,
}), }),
}),
]), ]),
labelClassName: PropTypes.string, labelClassName: PropTypes.string,
labelStyle: PropTypes.object, labelStyle: PropTypes.object,

View File

@ -72,7 +72,7 @@ class InputToggleWithErrors extends React.Component {
<Label <Label
className={cn(!isEmpty(labelClassName) && labelClassName)} className={cn(!isEmpty(labelClassName) && labelClassName)}
htmlFor={name} htmlFor={name}
message={label && label.message || label} message={label}
style={labelStyle} style={labelStyle}
/> />
</div> </div>
@ -90,7 +90,7 @@ class InputToggleWithErrors extends React.Component {
/> />
<InputDescription <InputDescription
className={inputDescriptionClassName} className={inputDescriptionClassName}
message={inputDescription && inputDescription.message || inputDescription} message={inputDescription}
style={inputDescriptionStyle} style={inputDescriptionStyle}
/> />
<InputErrors <InputErrors
@ -141,11 +141,9 @@ InputToggleWithErrors.propTypes = {
PropTypes.string, PropTypes.string,
PropTypes.func, PropTypes.func,
PropTypes.shape({ PropTypes.shape({
message: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
params: PropTypes.object, params: PropTypes.object,
}), }),
}),
]), ]),
inputDescriptionClassName: PropTypes.string, inputDescriptionClassName: PropTypes.string,
inputDescriptionStyle: PropTypes.object, inputDescriptionStyle: PropTypes.object,