From e69497fab457df486b2a7068bdd0283505461f8b Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 2 May 2019 11:12:28 +0900 Subject: Types src/settings --- src/settings/components/index.tsx | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'src/settings/components/index.tsx') diff --git a/src/settings/components/index.tsx b/src/settings/components/index.tsx index 4ef59d7..f56e93f 100644 --- a/src/settings/components/index.tsx +++ b/src/settings/components/index.tsx @@ -6,19 +6,29 @@ import SearchForm from './form/SearchForm'; import KeymapsForm from './form/KeymapsForm'; import BlacklistForm from './form/BlacklistForm'; import PropertiesForm from './form/PropertiesForm'; -import * as properties from 'shared/settings/properties'; -import * as settingActions from 'settings/actions/setting'; +import * as properties from '../../shared/settings/properties'; +import * as settingActions from '../../settings/actions/setting'; const DO_YOU_WANT_TO_CONTINUE = 'Some settings in JSON can be lost when migrating. ' + 'Do you want to continue?'; -class SettingsComponent extends React.Component { +interface Props { + source: string; + json: string; + form: any; + error: string; + + // FIXME + store: any; +} + +class SettingsComponent extends React.Component { componentDidMount() { this.props.dispatch(settingActions.load()); } - renderFormFields(form) { + renderFormFields(form: any) { return
Keybindings @@ -56,15 +66,15 @@ class SettingsComponent extends React.Component {
; } - renderJsonFields(json, error) { + renderJsonFields(json: string, error: string) { return
@@ -90,7 +100,7 @@ class SettingsComponent extends React.Component { label='Use form' checked={this.props.source === 'form'} value='form' - onChange={this.bindSource.bind(this)} + onValueChange={this.bindSource.bind(this)} disabled={disabled} /> { fields } @@ -107,7 +117,7 @@ class SettingsComponent extends React.Component { ); } - bindForm(name, value) { + bindForm(name: string, value: any) { let settings = { source: this.props.source, json: this.props.json, @@ -117,22 +127,20 @@ class SettingsComponent extends React.Component { this.props.dispatch(settingActions.set(settings)); } - bindJson(e) { + bindJson(_name: string, value: string) { let settings = { source: this.props.source, - json: e.target.value, + json: value, form: this.props.form, }; this.props.dispatch(settingActions.set(settings)); } - bindSource(e) { + bindSource(_name: string, value: string) { let from = this.props.source; - let to = e.target.value; - - if (from === 'form' && to === 'json') { + if (from === 'form' && value === 'json') { this.props.dispatch(settingActions.switchToJson(this.props.form)); - } else if (from === 'json' && to === 'form') { + } else if (from === 'json' && value === 'form') { let b = window.confirm(DO_YOU_WANT_TO_CONTINUE); if (!b) { this.forceUpdate(); @@ -148,6 +156,6 @@ class SettingsComponent extends React.Component { } } -const mapStateToProps = state => state; +const mapStateToProps = (state: any) => state; export default connect(mapStateToProps)(SettingsComponent); -- cgit v1.2.3