import { isLoading, getValidationMessage, getChangedValue } from '../store/rootReducer';
import { failValidation, passValidation } from '../store/settingsPage/validationMessages/actions';
import { cancelChange, changeValue } from '../store/settingsPage/changedValues/actions';
+import { TYPE_PASSWORD } from '../constants';
class Definition extends React.Component {
static propTypes = {
handleChange (value) {
clearTimeout(this.timeout);
- return this.props.changeValue(this.props.setting.definition.key, value);
+ this.props.changeValue(this.props.setting.definition.key, value);
+ if (this.props.setting.definition.type === TYPE_PASSWORD) {
+ this.handleSave();
+ }
}
handleReset () {
handleSave () {
this.safeSetState({ success: false });
- const { definition } = this.props.setting;
- if (isEmptyValue(definition, this.props.changedValue)) {
- this.props.failValidation(definition.key, translate('settings.state.value_cant_be_empty'));
- return;
- }
-
const componentKey = this.props.component ? this.props.component.key : null;
this.props.saveValue(this.props.setting.definition.key, componentKey).then(() => {
this.safeSetState({ success: true });
autoFocus={true}
autoComplete={false}
onChange={e => this.handleInputChange(e)}/>
- <button className="spacer-left">{translate('set')}</button>
+
+ <button className="spacer-left button-success">{translate('save')}</button>
+
<a className="spacer-left" href="#" onClick={e => this.handleCancelChangeClick(e)}>
{translate('cancel')}
</a>
import { passValidation, failValidation } from './settingsPage/validationMessages/actions';
import { cancelChange } from './settingsPage/changedValues/actions';
import { getDefinition, getChangedValue } from './rootReducer';
+import { isEmptyValue } from '../utils';
+import { translate } from '../../../helpers/l10n';
export const fetchSettings = componentKey => dispatch => {
return getDefinitions(componentKey)
const definition = getDefinition(state, key);
const value = getChangedValue(state, key);
+ if (isEmptyValue(definition, value)) {
+ dispatch(failValidation(key, translate('settings.state.value_cant_be_empty')));
+ dispatch(stopLoading(key));
+ return Promise.reject();
+ }
+
return setSettingValue(definition, value, componentKey)
.then(() => getValues(key, componentKey))
.then(values => {