Fix error on settings
This commit is contained in:
parent
ab9183f575
commit
db9f430627
3 changed files with 8 additions and 6 deletions
|
@ -68,6 +68,7 @@ class SettingsComponent extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let fields = null;
|
let fields = null;
|
||||||
|
let disabled = this.props.error.length > 0;
|
||||||
if (this.props.source === 'form') {
|
if (this.props.source === 'form') {
|
||||||
fields = this.renderFormFields(this.props.form);
|
fields = this.renderFormFields(this.props.form);
|
||||||
} else if (this.props.source === 'json') {
|
} else if (this.props.source === 'json') {
|
||||||
|
@ -84,7 +85,8 @@ class SettingsComponent extends Component {
|
||||||
label='Use form'
|
label='Use form'
|
||||||
checked={this.props.source === 'form'}
|
checked={this.props.source === 'form'}
|
||||||
value='form'
|
value='form'
|
||||||
onChange={this.bindSource.bind(this)} />
|
onChange={this.bindSource.bind(this)}
|
||||||
|
disabled={disabled} />
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
type='radio'
|
type='radio'
|
||||||
|
@ -92,8 +94,8 @@ class SettingsComponent extends Component {
|
||||||
label='Use plain JSON'
|
label='Use plain JSON'
|
||||||
checked={this.props.source === 'json'}
|
checked={this.props.source === 'json'}
|
||||||
value='json'
|
value='json'
|
||||||
onChange={this.bindSource.bind(this)} />
|
onChange={this.bindSource.bind(this)}
|
||||||
|
disabled={disabled} />
|
||||||
{ fields }
|
{ fields }
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -128,6 +130,7 @@ class SettingsComponent extends Component {
|
||||||
} else if (from === 'json' && to === 'form') {
|
} else if (from === 'json' && to === 'form') {
|
||||||
let b = window.confirm(DO_YOU_WANT_TO_CONTINUE);
|
let b = window.confirm(DO_YOU_WANT_TO_CONTINUE);
|
||||||
if (!b) {
|
if (!b) {
|
||||||
|
this.forceUpdate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.props.dispatch(settingActions.switchToForm(this.props.json));
|
this.props.dispatch(settingActions.switchToForm(this.props.json));
|
||||||
|
|
|
@ -14,11 +14,10 @@ export default function reducer(state = defaultState, action = {}) {
|
||||||
source: action.source,
|
source: action.source,
|
||||||
json: action.json,
|
json: action.json,
|
||||||
form: action.form,
|
form: action.form,
|
||||||
errors: '',
|
|
||||||
error: '', };
|
error: '', };
|
||||||
case actions.SETTING_SHOW_ERROR:
|
case actions.SETTING_SHOW_ERROR:
|
||||||
return { ...state,
|
return { ...state,
|
||||||
error: action.text,
|
error: action.error,
|
||||||
json: action.json, };
|
json: action.json, };
|
||||||
case actions.SETTING_SWITCH_TO_FORM:
|
case actions.SETTING_SWITCH_TO_FORM:
|
||||||
return { ...state,
|
return { ...state,
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe("settings setting reducer", () => {
|
||||||
it('return next state for SETTING_SHOW_ERROR', () => {
|
it('return next state for SETTING_SHOW_ERROR', () => {
|
||||||
let action = {
|
let action = {
|
||||||
type: actions.SETTING_SHOW_ERROR,
|
type: actions.SETTING_SHOW_ERROR,
|
||||||
text: 'bad value',
|
error: 'bad value',
|
||||||
json: '{}',
|
json: '{}',
|
||||||
};
|
};
|
||||||
let state = settingReducer(undefined, action);
|
let state = settingReducer(undefined, action);
|
||||||
|
|
Reference in a new issue