Progress
This commit is contained in:
@@ -7,7 +7,10 @@ export default class SettingSwitch extends ImmutablePureComponent {
|
||||
static propTypes = {
|
||||
prefix: PropTypes.string,
|
||||
settings: ImmutablePropTypes.map.isRequired,
|
||||
settingPath: PropTypes.array.isRequired,
|
||||
settingPath: PropTypes.oneOfType([
|
||||
PropTypes.array,
|
||||
PropTypes.string,
|
||||
]).isRequired,
|
||||
description: PropTypes.string,
|
||||
label: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
@@ -26,14 +29,17 @@ export default class SettingSwitch extends ImmutablePureComponent {
|
||||
description
|
||||
} = this.props
|
||||
|
||||
const id = ['setting-toggle', prefix, ...settingPath].filter(Boolean).join('-')
|
||||
|
||||
const isArray = Array.isArray(settingPath)
|
||||
const checked = isArray ? settings.getIn(settingPath) : settings.get(settingPath)
|
||||
const idVal = isArray ? settingPath.join('-') : settingPath
|
||||
const id = ['setting-toggle', prefix, idVal].filter(Boolean).join('-')
|
||||
|
||||
return (
|
||||
<Switch
|
||||
description={description}
|
||||
label={label}
|
||||
id={id}
|
||||
checked={settings.getIn(settingPath)}
|
||||
checked={checked}
|
||||
onChange={this.onChange}
|
||||
onKeyDown={this.onKeyDown}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user