Remove all required props in settings-manager and change input select design

This commit is contained in:
cyril lopez 2017-09-26 11:47:13 +02:00
parent 381dfb4c3c
commit f406dc8b3f
22 changed files with 137 additions and 106 deletions

View File

@ -114,4 +114,4 @@
"whatwg-fetch": "^2.0.3" "whatwg-fetch": "^2.0.3"
}, },
"devDependencies": {} "devDependencies": {}
} }

View File

@ -58,11 +58,11 @@ class EditForm extends React.Component { // eslint-disable-line react/prefer-sta
EditForm.propTypes = { EditForm.propTypes = {
cancelAction: PropTypes.bool, cancelAction: PropTypes.bool,
formErrors: PropTypes.array, formErrors: PropTypes.array,
handleCancel: PropTypes.func.isRequired, handleCancel: PropTypes.func,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
handleSubmit: PropTypes.func.isRequired, handleSubmit: PropTypes.func,
sections: PropTypes.array.isRequired, sections: PropTypes.array,
values: PropTypes.object.isRequired, values: PropTypes.object,
}; };
export default EditForm; export default EditForm;

View File

@ -56,13 +56,13 @@ class EditFormSection extends React.Component { // eslint-disable-line react/pre
} }
EditFormSection.propTypes = { EditFormSection.propTypes = {
formErrors: PropTypes.array.isRequired, formErrors: PropTypes.array,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
renderInput: PropTypes.func, renderInput: PropTypes.func,
section: PropTypes.object.isRequired, section: PropTypes.object,
showNestedForm: PropTypes.bool, showNestedForm: PropTypes.bool,
styles: PropTypes.object, styles: PropTypes.object,
values: PropTypes.object.isRequired, values: PropTypes.object,
}; };
export default WithFormSection(EditFormSection); // eslint-disable-line new-cap export default WithFormSection(EditFormSection); // eslint-disable-line new-cap

View File

@ -81,13 +81,13 @@ class EditFormSectionNested extends React.Component { // eslint-disable-line rea
} }
EditFormSectionNested.propTypes = { EditFormSectionNested.propTypes = {
formErrors: PropTypes.array.isRequired, formErrors: PropTypes.array,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
renderInput: PropTypes.func, renderInput: PropTypes.func,
section: PropTypes.oneOfType([ section: PropTypes.oneOfType([
PropTypes.array, PropTypes.array,
PropTypes.object, PropTypes.object,
]).isRequired, ]),
styles: PropTypes.object, styles: PropTypes.object,
value: PropTypes.object, value: PropTypes.object,
values: PropTypes.object, values: PropTypes.object,

View File

@ -24,11 +24,11 @@ class EditFormSectionSubNested extends React.Component { // eslint-disable-line
} }
EditFormSectionSubNested.propTypes = { EditFormSectionSubNested.propTypes = {
renderInput: PropTypes.func.isRequired, renderInput: PropTypes.func,
section: PropTypes.oneOfType([ section: PropTypes.oneOfType([
PropTypes.array, PropTypes.array,
PropTypes.object, PropTypes.object,
]).isRequired, ]),
styles: PropTypes.object, styles: PropTypes.object,
}; };

View File

@ -49,8 +49,8 @@ class HeaderNav extends React.Component { // eslint-disable-line react/prefer-st
} }
HeaderNav.propTypes = { HeaderNav.propTypes = {
links: PropTypes.array.isRequired, links: PropTypes.array,
path: PropTypes.string.isRequired, path: PropTypes.string,
renderListComponent: PropTypes.bool.isRequired, renderListComponent: PropTypes.bool,
} }
export default HeaderNav; export default HeaderNav;

View File

@ -44,12 +44,12 @@ class InputEnum extends React.Component { // eslint-disable-line react/prefer-st
} }
InputEnum.propTypes = { InputEnum.propTypes = {
customBootstrapClass: PropTypes.string.isRequired, customBootstrapClass: PropTypes.string,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
name: PropTypes.string.isRequired, name: PropTypes.string,
selectOptions: PropTypes.array.isRequired, selectOptions: PropTypes.array,
target: PropTypes.string.isRequired, target: PropTypes.string,
value: PropTypes.any.isRequired, value: PropTypes.any,
} }
export default InputEnum; export default InputEnum;

View File

@ -169,19 +169,19 @@ InputNumber.propTypes = {
PropTypes.array, PropTypes.array,
]).isRequired, ]).isRequired,
handleBlur: PropTypes.func, handleBlur: PropTypes.func,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
handleFocus: PropTypes.func, handleFocus: PropTypes.func,
inputDescription: PropTypes.string, inputDescription: PropTypes.string,
name: PropTypes.string.isRequired, name: PropTypes.string,
noErrorsDescription: PropTypes.bool, noErrorsDescription: PropTypes.bool,
placeholder: PropTypes.string, placeholder: PropTypes.string,
styles: PropTypes.object, styles: PropTypes.object,
target: PropTypes.string.isRequired, target: PropTypes.string,
validations: PropTypes.object.isRequired, validations: PropTypes.object,
value: PropTypes.oneOfType([ value: PropTypes.oneOfType([
PropTypes.number, PropTypes.number,
PropTypes.string, PropTypes.string,
]).isRequired, ]),
} }
export default WithInput(InputNumber); // eslint-disable-line new-cap export default WithInput(InputNumber); // eslint-disable-line new-cap

View File

@ -144,20 +144,20 @@ class InputPassword extends React.Component { // eslint-disable-line react/prefe
} }
InputPassword.propTypes = { InputPassword.propTypes = {
customBootstrapClass: PropTypes.string.isRequired, customBootstrapClass: PropTypes.string,
deactivateErrorHighlight: PropTypes.bool.isRequired, deactivateErrorHighlight: PropTypes.bool,
errors: PropTypes.array.isRequired, errors: PropTypes.array,
handleBlur: PropTypes.func.isRequired, handleBlur: PropTypes.func,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
handleFocus: PropTypes.func.isRequired, handleFocus: PropTypes.func,
inputDescription: PropTypes.string.isRequired, inputDescription: PropTypes.string,
name: PropTypes.string.isRequired, name: PropTypes.string,
noErrorsDescription: PropTypes.bool.isRequired, noErrorsDescription: PropTypes.bool,
placeholder: PropTypes.string.isRequired, placeholder: PropTypes.string,
styles: PropTypes.object.isRequired, styles: PropTypes.object,
target: PropTypes.string.isRequired, target: PropTypes.string,
validations: PropTypes.object.isRequired, validations: PropTypes.object,
value: PropTypes.string.isRequired, value: PropTypes.string,
}; };
export default WithInput(InputPassword); // eslint-disable-line new-cap export default WithInput(InputPassword); // eslint-disable-line new-cap

View File

@ -23,7 +23,7 @@ class InputSelect extends React.Component { // eslint-disable-line react/prefer-
const requiredClass = this.props.validations.required && this.props.addRequiredInputDesign ? styles.requiredClass : ''; const requiredClass = this.props.validations.required && this.props.addRequiredInputDesign ? styles.requiredClass : '';
return ( return (
<div className={`${styles.inputSelect} ${requiredClass} ${bootStrapClass}`}> <div className={`${styles.input} ${requiredClass} ${bootStrapClass}`}>
<label htmlFor={this.props.name}> <label htmlFor={this.props.name}>
<FormattedMessage id={`settings-manager.${this.props.name}`} /> <FormattedMessage id={`settings-manager.${this.props.name}`} />
</label> </label>
@ -35,13 +35,15 @@ class InputSelect extends React.Component { // eslint-disable-line react/prefer-
value={this.props.value} value={this.props.value}
> >
{map(this.props.selectOptions, (option, key) => ( {map(this.props.selectOptions, (option, key) => (
<FormattedMessage id={`settings-manager.${option.name}`} key={key}> option.name ?
{(message) => ( <FormattedMessage id={`settings-manager.${option.name}`} key={key}>
<option value={option.value}> {(message) => (
{message} <option value={option.value}>
</option> {message}
)} </option>
</FormattedMessage> )}
</FormattedMessage> :
<option value={option.value} key={key}>{option.name}</option>
))} ))}
</select> </select>
</div> </div>
@ -50,17 +52,17 @@ class InputSelect extends React.Component { // eslint-disable-line react/prefer-
} }
InputSelect.propTypes = { InputSelect.propTypes = {
addRequiredInputDesign: PropTypes.bool.isRequired, addRequiredInputDesign: PropTypes.bool,
customBootstrapClass: PropTypes.string.isRequired, customBootstrapClass: PropTypes.string,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
name: PropTypes.string.isRequired, name: PropTypes.string,
selectOptions: PropTypes.oneOfType([ selectOptions: PropTypes.oneOfType([
PropTypes.array.isRequired, PropTypes.array,
PropTypes.object.isRequired, // TODO remove PropTypes.object,
]).isRequired, ]),
target: PropTypes.string.isRequired, target: PropTypes.string,
validations: PropTypes.object.isRequired, validations: PropTypes.object,
value: PropTypes.string.isRequired, value: PropTypes.string,
}; };
export default InputSelect; export default InputSelect;

View File

@ -27,3 +27,34 @@
content: "*"; content: "*";
} }
} }
.input {
margin-bottom: 1.5rem;
font-size: 1.3rem;
font-family: Lato;
-webkit-font-smoothing: antialiased;
> label {
margin-bottom: 0;
font-weight: 500;
text-transform: capitalize;
}
> select {
margin-top: .9rem;
padding-top: 0rem;
padding-left: 1rem;
height: 3.4rem !important;
line-height: 3.2rem;
border: 1px solid #E3E9F3;
border-radius: 0.25rem;
-moz-appearance: none;
-webkit-appearance: none;
font-size: 1.3rem;
font-family: Lato !important;
background-position: right -1px center;
background-repeat: no-repeat;
background-image: url('../../assets/images/background_input.svg');
}
}

View File

@ -193,15 +193,15 @@ InputText.propTypes = {
deactivateErrorHighlight: PropTypes.bool, deactivateErrorHighlight: PropTypes.bool,
errors: PropTypes.array, errors: PropTypes.array,
handleBlur: PropTypes.func, handleBlur: PropTypes.func,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
handleFocus: PropTypes.func, handleFocus: PropTypes.func,
inputDescription: PropTypes.string, inputDescription: PropTypes.string,
name: PropTypes.string.isRequired, name: PropTypes.string,
noErrorsDescription: PropTypes.bool, noErrorsDescription: PropTypes.bool,
placeholder: PropTypes.string, placeholder: PropTypes.string,
styles: PropTypes.object, styles: PropTypes.object,
target: PropTypes.string.isRequired, target: PropTypes.string,
validations: PropTypes.object.isRequired, validations: PropTypes.object,
value: PropTypes.string, value: PropTypes.string,
} }

View File

@ -72,12 +72,12 @@ class InputToggle extends React.Component { // eslint-disable-line react/prefer-
} }
InputToggle.propTypes = { InputToggle.propTypes = {
customBootstrapClass: PropTypes.string.isRequired, customBootstrapClass: PropTypes.string,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
hiddenLabel: PropTypes.bool.isRequired, hiddenLabel: PropTypes.bool,
isChecked: PropTypes.bool, isChecked: PropTypes.bool,
name: PropTypes.string.isRequired, name: PropTypes.string,
target: PropTypes.string.isRequired, target: PropTypes.string,
} }
export default InputToggle; export default InputToggle;

View File

@ -147,17 +147,17 @@ List.propTypes = {
formErrors: PropTypes.array, formErrors: PropTypes.array,
handlei18n: PropTypes.bool, handlei18n: PropTypes.bool,
handleListPopUpSubmit: PropTypes.func, handleListPopUpSubmit: PropTypes.func,
listButtonLabel: PropTypes.string.isRequired, listButtonLabel: PropTypes.string,
listItems: PropTypes.array, listItems: PropTypes.array,
listTitle: PropTypes.oneOfType([ listTitle: PropTypes.oneOfType([
PropTypes.string.isRequired, PropTypes.string,
PropTypes.object.isRequired, PropTypes.object,
]).isRequired, ]),
noListButtonPopUp: PropTypes.bool, noListButtonPopUp: PropTypes.bool,
renderRow: PropTypes.oneOfType([ renderRow: PropTypes.oneOfType([
PropTypes.bool.isRequired, PropTypes.bool,
PropTypes.func.isRequired, PropTypes.func,
]).isRequired, ]),
} }
export default List; export default List;

View File

@ -38,9 +38,9 @@ class PluginLeftMenuSection extends React.Component { // eslint-disable-line rea
} }
PluginLeftMenuSection.propTypes = { PluginLeftMenuSection.propTypes = {
environments: PropTypes.array.isRequired, environments: PropTypes.array,
envParams: PropTypes.string, envParams: PropTypes.string,
section: PropTypes.object.isRequired, section: PropTypes.object,
}; };
export default PluginLeftMenuSection; export default PluginLeftMenuSection;

View File

@ -45,13 +45,13 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
} }
PopUpForm.propTypes = { PopUpForm.propTypes = {
renderInput: PropTypes.func.isRequired, renderInput: PropTypes.func,
renderPopUpForm: PropTypes.oneOfType([ renderPopUpForm: PropTypes.oneOfType([
PropTypes.func, PropTypes.func,
PropTypes.bool, PropTypes.bool,
]).isRequired, ]),
resetToggleDefaultConnection: PropTypes.func.isRequired, resetToggleDefaultConnection: PropTypes.func,
sections: PropTypes.array.isRequired, sections: PropTypes.array,
}; };
export default WithFormSection(PopUpForm); // eslint-disable-line new-cap export default WithFormSection(PopUpForm); // eslint-disable-line new-cap

View File

@ -69,11 +69,11 @@ class PopUpWarning extends React.Component { // eslint-disable-line react/prefer
PopUpWarning.propTypes = { PopUpWarning.propTypes = {
dangerMessage: PropTypes.string, dangerMessage: PropTypes.string,
handleConfirm: PropTypes.func.isRequired, handleConfirm: PropTypes.func,
handleConfirmDanger: PropTypes.func, handleConfirmDanger: PropTypes.func,
isOpen: PropTypes.bool.isRequired, isOpen: PropTypes.bool,
showDanger: PropTypes.bool, showDanger: PropTypes.bool,
toggleModal: PropTypes.func.isRequired, toggleModal: PropTypes.func,
warningMessage: PropTypes.string, warningMessage: PropTypes.string,
} }

View File

@ -131,12 +131,12 @@ class RowDatabase extends React.Component { // eslint-disable-line react/prefer-
} }
RowDatabase.propTypes = { RowDatabase.propTypes = {
data: PropTypes.object.isRequired, data: PropTypes.object,
error: PropTypes.bool.isRequired, error: PropTypes.bool,
formErrors: PropTypes.array.isRequired, formErrors: PropTypes.array,
getDatabase: PropTypes.func.isRequired, getDatabase: PropTypes.func,
handleDatabaseDelete: PropTypes.func.isRequired, handleDatabaseDelete: PropTypes.func,
handleSubmit: PropTypes.func.isRequired, handleSubmit: PropTypes.func,
}; };
export default RowDatabase; export default RowDatabase;

View File

@ -92,11 +92,11 @@ class RowLanguage extends React.Component { // eslint-disable-line react/prefer-
RowLanguage.propTypes = { RowLanguage.propTypes = {
active: PropTypes.bool, active: PropTypes.bool,
changeDefaultLanguage: PropTypes.func.isRequired, changeDefaultLanguage: PropTypes.func,
handleLanguageDelete: PropTypes.func.isRequired, handleLanguageDelete: PropTypes.func,
listLanguages: PropTypes.object.isRequired, listLanguages: PropTypes.object,
liStyles: PropTypes.object.isRequired, liStyles: PropTypes.object,
name: PropTypes.string.isRequired, name: PropTypes.string,
}; };
export default RowLanguage; export default RowLanguage;

View File

@ -39,10 +39,10 @@ class SelectOptionLanguage extends React.Component { // eslint-disable-line reac
} }
SelectOptionLanguage.propTypes = { SelectOptionLanguage.propTypes = {
isFocused: PropTypes.bool.isRequired, isFocused: PropTypes.bool,
onFocus: PropTypes.func.isRequired, onFocus: PropTypes.func,
onSelect: PropTypes.func.isRequired, onSelect: PropTypes.func,
option: PropTypes.object.isRequired, option: PropTypes.object,
}; };
export default SelectOptionLanguage; export default SelectOptionLanguage;

View File

@ -21,13 +21,13 @@ const WithFormSection = (InnerComponent) => class extends React.Component {
static propTypes = { static propTypes = {
addRequiredInputDesign: PropTypes.bool, addRequiredInputDesign: PropTypes.bool,
cancelAction: PropTypes.bool, cancelAction: PropTypes.bool,
formErrors: PropTypes.array.isRequired, formErrors: PropTypes.array,
handleChange: PropTypes.func.isRequired, handleChange: PropTypes.func,
section: PropTypes.oneOfType([ section: PropTypes.oneOfType([
PropTypes.object, PropTypes.object,
PropTypes.array, PropTypes.array,
]), ]),
values: PropTypes.object.isRequired, values: PropTypes.object,
} }
constructor(props) { constructor(props) {

View File

@ -7,8 +7,6 @@
import styles from './styles.scss'; import styles from './styles.scss';
const WithInput = (InnerInput) => class extends React.Component { // eslint-disable-line react/prefer-stateless-function const WithInput = (InnerInput) => class extends React.Component { // eslint-disable-line react/prefer-stateless-function
// TODO handle state and props
render() { render() {
return ( return (
<InnerInput <InnerInput