Skip to content

Commit

Permalink
refactor(prevent inheritance of all props in settings)
Browse files Browse the repository at this point in the history
  • Loading branch information
sixtedemaupeou committed Jun 4, 2018
1 parent 50f512f commit a624899
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SettingsContainer extends React.PureComponent {
}

render () {
return <Settings {...this.props} handleClick={this.handleClick} />
return <Settings handleClick={this.handleClick} />
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BadgesContainer = styled.div`
& > * { display:inline; margin-right: 5px; }
`

const PairingCode = (props) => {
const PairingCode = () => {
return (
<SettingContainer>
<SettingSummary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { selectors } from 'data'
import Settings from './template.js'

const SettingsContainer = props => {
return <Settings {...props} />
return <Settings guid={props.guid} />
}

const mapStateToProps = (state) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text } from 'blockchain-info-components'
import { SettingComponent, SettingContainer, SettingDescription, SettingHeader, SettingSummary } from 'components/Setting'
import Settings from './Settings'

const WalletId = (props) => {
const WalletId = () => {
return (
<SettingContainer>
<SettingSummary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class SettingContainer extends React.PureComponent {
}

render () {
const { ui, ...rest } = this.props
const { logoutTime, ui } = this.props

return <Settings
{...rest}
logoutTime={logoutTime}
updateToggled={ui.updateToggled}
handleToggle={this.handleToggle}
handleClick={this.handleClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BitcoinLinkHandlingContainer extends React.PureComponent {
}

render () {
return <BitcoinLinkHandling {...this.props} warningDisplayed={this.props.ui.warningDisplayed} handleClick={this.handleClick}
return <BitcoinLinkHandling warningDisplayed={this.props.ui.warningDisplayed} handleClick={this.handleClick}
/>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SettingsContainer extends React.PureComponent {
}

render () {
return <Settings {...this.props} />
return <Settings />
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { getData } from './selectors'

class LocalCurrencyContainer extends React.PureComponent {
render () {
const { data, ...rest } = this.props
const { data } = this.props

return data.cata({
Success: (value) => <Success {...rest} currency={value} />,
Failure: (message) => <Error {...rest} message={message} />,
Loading: () => <Loading {...rest} />,
NotAsked: () => <Loading {...rest} />
Success: (value) => <Success currency={value} />,
Failure: (message) => <Error message={message} />,
Loading: () => <Loading />,
NotAsked: () => <Loading />
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ class SettingContainer extends Component {
}

render () {
const { modalActions, smsNumber, smsVerified } = this.props

return <Settings
{...this.props}
smsNumber={smsNumber}
smsVerified={smsVerified}
handleClick={this.handleClick}
modalActions={modalActions}
showWarning={this.state.show2FAWarning}
resetWarning={() => this.setState({ show2FAWarning: false })}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { getData } from './selectors'

class MobileNumberContainer extends React.PureComponent {
render () {
const { data, ...rest } = this.props
const { data } = this.props

return data.cata({
Success: (value) => <Success {...rest} data={value} />,
Failure: (message) => <Error {...rest} message={message} />,
Loading: () => <Loading {...rest} />,
NotAsked: () => <Loading {...rest} />
Success: (value) => <Success data={value} />,
Failure: (message) => <Error message={message} />,
Loading: () => <Loading />,
NotAsked: () => <Loading />
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import Settings from './template.js'

class SettingContainer extends React.PureComponent {
render () {
const defaultData = { isEmailVerified: false, isMobileVerified: false }

return this.props.data.cata({
Success: value => <Settings data={value} />,
Failure: message => <Settings data={{ isEmailVerified: false, isMobileVerified: false }} />,
Loading: () => <Settings data={{isEmailVerified: false, isMobileVerified: false}} />,
NotAsked: () => <Settings data={{isEmailVerified: false, isMobileVerified: false}} />
Failure: message => <Settings data={defaultData} />,
Loading: () => <Settings data={defaultData} />,
NotAsked: () => <Settings data={defaultData} />
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Notifications from './template.js'

class NotificationsContainer extends React.PureComponent {
render () {
return <Notifications {...this.props} />
return <Notifications />
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl'
import { SettingComponent, SettingContainer, SettingDescription, SettingHeader, SettingSummary } from 'components/Setting'
import Settings from './Settings'

const Notifications = (props) => {
const Notifications = () => {
return (
<SettingContainer>
<SettingSummary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SettingsContainer extends React.PureComponent {
}

render () {
return <Settings {...this.props} />
return <Settings />
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Field, reduxForm } from 'redux-form'
import { SelectBoxTheme } from 'components/Form'
import { SettingSelectBoxWrapper } from 'components/Setting'

const Settings = (props) => (
const Settings = () => (
<SettingSelectBoxWrapper>
<Field name='theme' component={SelectBoxTheme} />
</SettingSelectBoxWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl'
import { SettingComponent, SettingContainer, SettingDescription, SettingHeader, SettingSummary } from 'components/Setting'
import Settings from './Settings'

const Themes = (props) => {
const Themes = () => {
return (
<SettingContainer>
<SettingSummary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SettingsContainer extends React.PureComponent {
}

render () {
return <Settings {...this.props} />
return <Settings />
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Field, reduxForm } from 'redux-form'
import { SelectBoxLanguages } from 'components/Form'
import { SettingSelectBoxWrapper } from 'components/Setting'

const Settings = (props) => (
const Settings = () => (
<SettingSelectBoxWrapper>
<Field name='language' component={SelectBoxLanguages} />
</SettingSelectBoxWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { getData } from './selectors'

class WalletLanguageContainer extends React.PureComponent {
render () {
const { data, ...rest } = this.props
const { data } = this.props

return data.cata({
Success: (value) => <Success {...rest} language={value} />,
Failure: (message) => <Error {...rest} message={message} />,
Loading: () => <Loading {...rest} />,
NotAsked: () => <Loading {...rest} />
Success: (value) => <Success language={value} />,
Failure: (message) => <Error message={message} />,
Loading: () => <Loading />,
NotAsked: () => <Loading />
})
}
}
Expand Down

0 comments on commit a624899

Please sign in to comment.