1717 * You should have received a copy of the GNU General Public License
1818 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1919 */
20- /* global btoa */
2120import React from 'react'
2221import { connect } from 'react-redux'
2322import * as actions from 'shared/modules/settings/settingsDuck'
@@ -35,6 +34,7 @@ import {
3534 StyledSettingLabel ,
3635 StyledSettingTextInput
3736} from './styled'
37+ import { toKeyString } from 'services/utils'
3838
3939const visualSettings = [
4040 {
@@ -140,20 +140,24 @@ const visualSettings = [
140140 }
141141]
142142
143- export const Settings = ( { settings, onSettingsSave = ( ) => { } } ) => {
143+ export const Settings = ( {
144+ settings,
145+ visualSettings,
146+ onSettingsSave = ( ) => { }
147+ } ) => {
144148 if ( ! settings ) return null
145- const mappedSettings = visualSettings . map ( ( visualSetting , oi ) => {
149+ const mappedSettings = visualSettings . map ( visualSetting => {
146150 const title = < DrawerSubHeader > { visualSetting . title } </ DrawerSubHeader >
147151 const mapSettings = visualSetting . settings
148- . map ( ( settingObj , i ) => {
152+ . map ( settingObj => {
149153 const setting = Object . keys ( settingObj ) [ 0 ]
150154 if ( typeof settings [ setting ] === 'undefined' ) return false
151155 const visual = settingObj [ setting ] . displayName
152156 const tooltip = settingObj [ setting ] . tooltip || ''
153157
154158 if ( ! settingObj [ setting ] . type || settingObj [ setting ] . type === 'input' ) {
155159 return (
156- < StyledSetting key = { btoa ( visual ) } >
160+ < StyledSetting key = { toKeyString ( visual ) } >
157161 < StyledSettingLabel title = { tooltip } > { visual } </ StyledSettingLabel >
158162 < StyledSettingTextInput
159163 onChange = { event => {
@@ -168,7 +172,7 @@ export const Settings = ({ settings, onSettingsSave = () => {} }) => {
168172 )
169173 } else if ( settingObj [ setting ] . type === 'radio' ) {
170174 return (
171- < StyledSetting key = { btoa ( visual ) } >
175+ < StyledSetting key = { toKeyString ( visual ) } >
172176 < StyledSettingLabel title = { tooltip } > { visual } </ StyledSettingLabel >
173177 < RadioSelector
174178 options = { settingObj [ setting ] . options }
@@ -182,7 +186,7 @@ export const Settings = ({ settings, onSettingsSave = () => {} }) => {
182186 )
183187 } else if ( settingObj [ setting ] . type === 'checkbox' ) {
184188 return (
185- < StyledSetting key = { btoa ( visual ) } >
189+ < StyledSetting key = { toKeyString ( visual ) } >
186190 < CheckboxSelector
187191 onChange = { event => {
188192 settings [ setting ] = event . target . checked
@@ -197,7 +201,7 @@ export const Settings = ({ settings, onSettingsSave = () => {} }) => {
197201 } )
198202 . filter ( setting => setting !== false )
199203 return (
200- < React . Fragment key = { btoa ( visualSetting . title ) } >
204+ < React . Fragment key = { toKeyString ( visualSetting . title ) } >
201205 { title }
202206 { mapSettings }
203207 </ React . Fragment >
@@ -218,7 +222,8 @@ export const Settings = ({ settings, onSettingsSave = () => {} }) => {
218222
219223const mapStateToProps = state => {
220224 return {
221- settings : state . settings
225+ settings : state . settings ,
226+ visualSettings
222227 }
223228}
224229
@@ -230,4 +235,7 @@ const mapDispatchToProps = dispatch => {
230235 }
231236}
232237
233- export default connect ( mapStateToProps , mapDispatchToProps ) ( Settings )
238+ export default connect (
239+ mapStateToProps ,
240+ mapDispatchToProps
241+ ) ( Settings )
0 commit comments