|
|
@ -16,6 +16,7 @@ import { |
|
|
|
shepherdCli, |
|
|
|
checkForUpdateUIPromise, |
|
|
|
updateUIPromise, |
|
|
|
triggerToaster, |
|
|
|
} from '../../../actions/actionCreators'; |
|
|
|
import Store from '../../../store'; |
|
|
|
|
|
|
@ -447,17 +448,53 @@ class Settings extends React.Component { |
|
|
|
_saveAppConfig() { |
|
|
|
const _appSettings = this.state.appSettings; |
|
|
|
let _appSettingsPristine = Object.assign({}, this.props.Settings.appSettings); |
|
|
|
let isError = false; |
|
|
|
let saveAfterPathCheck = false; |
|
|
|
|
|
|
|
for (let key in _appSettings) { |
|
|
|
if (key.indexOf('__') === -1) { |
|
|
|
_appSettingsPristine[key] = this.state.appConfigSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key]; |
|
|
|
|
|
|
|
if (this.state.appConfigSchema[key].type === 'folder' && |
|
|
|
_appSettings[key] && |
|
|
|
_appSettings[key].length) { |
|
|
|
const _testLocation = window.require('electron').remote.getCurrentWindow().testLocation; |
|
|
|
saveAfterPathCheck = true; |
|
|
|
|
|
|
|
_testLocation(_appSettings[key]) |
|
|
|
.then((res) => { |
|
|
|
if (res === -1) { |
|
|
|
isError = true; |
|
|
|
Store.dispatch( |
|
|
|
triggerToaster( |
|
|
|
'Komodo datadir path is invalid', |
|
|
|
translate('INDEX.SETTINGS'), |
|
|
|
'error' |
|
|
|
) |
|
|
|
); |
|
|
|
} else if (res === false) { |
|
|
|
isError = true; |
|
|
|
Store.dispatch( |
|
|
|
triggerToaster( |
|
|
|
'Komodo datadir path is not a directory', |
|
|
|
translate('INDEX.SETTINGS'), |
|
|
|
'error' |
|
|
|
) |
|
|
|
); |
|
|
|
} else { |
|
|
|
Store.dispatch(saveAppConfig(_appSettingsPristine)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
const _nestedKey = key.split('__'); |
|
|
|
_appSettingsPristine[_nestedKey[0]][_nestedKey[1]] = this.state.appConfigSchema[_nestedKey[0]][_nestedKey[1]].type === 'number' ? Number(_appSettings[key]) : _appSettings[key]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Store.dispatch(saveAppConfig(_appSettingsPristine)); |
|
|
|
if (!saveAfterPathCheck) { |
|
|
|
Store.dispatch(saveAppConfig(_appSettingsPristine)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
renderConfigEditForm() { |
|
|
@ -502,11 +539,12 @@ class Settings extends React.Component { |
|
|
|
value={ _appConfig[key][_key] } |
|
|
|
onChange={ (event) => this.updateInputSettings(event, key, _key) } /> |
|
|
|
} |
|
|
|
{ this.state.appConfigSchema[key][_key].type === 'string' && |
|
|
|
{ (this.state.appConfigSchema[key][_key].type === 'string' || this.state.appConfigSchema[key][_key].type === 'folder') && |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
name={ `${key}__${_key}` } |
|
|
|
value={ _appConfig[key][_key] } |
|
|
|
className={ this.state.appConfigSchema[key][_key].type === 'folder' ? 'full-width': '' } |
|
|
|
onChange={ (event) => this.updateInputSettings(event, key, _key) } /> |
|
|
|
} |
|
|
|
{ this.state.appConfigSchema[key][_key].type === 'boolean' && |
|
|
@ -549,11 +587,12 @@ class Settings extends React.Component { |
|
|
|
value={ _appConfig[key] } |
|
|
|
onChange={ (event) => this.updateInputSettings(event, key) } /> |
|
|
|
} |
|
|
|
{ this.state.appConfigSchema[key].type === 'string' && |
|
|
|
{ (this.state.appConfigSchema[key].type === 'string' || this.state.appConfigSchema[key].type === 'folder') && |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
name={ `${key}` } |
|
|
|
value={ _appConfig[key] } |
|
|
|
className={ this.state.appConfigSchema[key].type === 'folder' ? 'full-width': '' } |
|
|
|
onChange={ (event) => this.updateInputSettings(event, key) } /> |
|
|
|
} |
|
|
|
{ this.state.appConfigSchema[key].type === 'boolean' && |
|
|
|