Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(settings): refactor general settings #6161

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { bindActionCreators } from 'redux'

import { Button, Icon, Link } from 'blockchain-info-components'
import {
Expand All @@ -11,9 +9,8 @@ import {
SettingHeader,
SettingSummary
} from 'components/Setting'
import { actions } from 'data'

const About = (props: Props) => {
const About = () => {
return (
<SettingContainer>
<SettingSummary>
Expand All @@ -28,13 +25,7 @@ const About = (props: Props) => {
</SettingDescription>
</SettingSummary>
<SettingComponent>
<Link
onClick={() => {
props.settingsActions.generalSettingsExternalRedirect('/about')
}}
href='https://www.blockchain.com/about'
target='_blank'
>
<Link href='https://www.blockchain.com/about' target='_blank'>
<Button data-e2e='aboutLink' nature='empty-blue'>
<Icon name='open-in-new-tab' size='20px' />
</Button>
Expand All @@ -44,12 +35,4 @@ const About = (props: Props) => {
)
}

const mapDispatchToProps = (dispatch) => ({
settingsActions: bindActionCreators(actions.modules.settings, dispatch)
})

const connector = connect(null, mapDispatchToProps)

type Props = {} & ConnectedProps<typeof connector>

export default connector(About)
export default About
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { bindActionCreators } from 'redux'
import { useDispatch } from 'react-redux'
import styled from 'styled-components'

import { Badge, Button, Text } from 'blockchain-info-components'
Expand All @@ -12,7 +11,7 @@ import {
SettingHeader,
SettingSummary
} from 'components/Setting'
import { actions } from 'data'
import { modals } from 'data/actions'
import { ModalName } from 'data/types'

const BadgesContainer = styled.div`
Expand All @@ -24,63 +23,57 @@ const BadgesContainer = styled.div`
}
`

class PairingCode extends React.PureComponent<Props> {
onShowCode = () => {
this.props.modalActions.showModal(ModalName.PAIRING_CODE_MODAL, {
origin: 'SettingsPage'
})
const PairingCode = () => {
const dispatch = useDispatch()

const onShowCode = () => {
dispatch(
modals.showModal(ModalName.PAIRING_CODE_MODAL, {
origin: 'SettingsPage'
})
)
}

render() {
return (
<SettingContainer>
<SettingSummary>
<SettingHeader>
<FormattedMessage
id='scenes.settings.general.pairingcode.title'
defaultMessage='Mobile App Pairing Code'
/>
</SettingHeader>
<SettingDescription>
<FormattedMessage
id='scenes.settings.general.pairingcode.description'
defaultMessage="Scan the code (click on 'Show Pairing Code') with your Blockchain Wallet (iOS or Android) for a seamless connection to your wallet."
/>{' '}
<FormattedMessage
id='scenes.settings.general.pairingcode.description2'
defaultMessage='Download our mobile applications below.'
/>{' '}
<Text color='error' size='13px' weight={600}>
<FormattedMessage
id='scenes.settings.general.pairingcode.warning'
defaultMessage='Do not share your Pairing Code with others.'
/>
</Text>
<BadgesContainer>
<Badge size='34px' type='applestore' />
<Badge size='34px' type='googleplay' />
</BadgesContainer>
</SettingDescription>
</SettingSummary>
<SettingComponent>
<Button data-e2e='showQrCode' nature='empty-blue' onClick={this.onShowCode}>
return (
<SettingContainer>
<SettingSummary>
<SettingHeader>
<FormattedMessage
id='scenes.settings.general.pairingcode.title'
defaultMessage='Mobile App Pairing Code'
/>
</SettingHeader>
<SettingDescription>
<FormattedMessage
id='scenes.settings.general.pairingcode.description'
defaultMessage="Scan the code (click on 'Show Pairing Code') with your Blockchain Wallet (iOS or Android) for a seamless connection to your wallet."
/>{' '}
<FormattedMessage
id='scenes.settings.general.pairingcode.description2'
defaultMessage='Download our mobile applications below.'
/>{' '}
<Text color='error' size='13px' weight={600}>
<FormattedMessage
id='scenes.settings.general.pairingcode.settings.show'
defaultMessage='Show Pairing Code'
id='scenes.settings.general.pairingcode.warning'
defaultMessage='Do not share your Pairing Code with others.'
/>
</Button>
</SettingComponent>
</SettingContainer>
)
}
</Text>
<BadgesContainer>
<Badge size='34px' type='applestore' />
<Badge size='34px' type='googleplay' />
</BadgesContainer>
</SettingDescription>
</SettingSummary>
<SettingComponent>
<Button data-e2e='showQrCode' nature='empty-blue' onClick={onShowCode}>
<FormattedMessage
id='scenes.settings.general.pairingcode.settings.show'
defaultMessage='Show Pairing Code'
/>
</Button>
</SettingComponent>
</SettingContainer>
)
}

const mapDispatchToProps = (dispatch) => ({
modalActions: bindActionCreators(actions.modals, dispatch)
})

const connector = connect(null, mapDispatchToProps)

type Props = ConnectedProps<typeof connector>

export default connector(PairingCode)
export default PairingCode
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { bindActionCreators } from 'redux'

import { Button, Icon, Link } from 'blockchain-info-components'
import {
Expand All @@ -11,9 +9,8 @@ import {
SettingHeader,
SettingSummary
} from 'components/Setting'
import { actions } from 'data'

const PrivacyPolicy = (props: Props) => {
const PrivacyPolicy = () => {
return (
<SettingContainer>
<SettingSummary>
Expand All @@ -31,13 +28,7 @@ const PrivacyPolicy = (props: Props) => {
</SettingDescription>
</SettingSummary>
<SettingComponent>
<Link
onClick={() => {
props.settingsActions.generalSettingsExternalRedirect('/legal/privacy')
}}
href='https://www.blockchain.com/legal/privacy'
target='_blank'
>
<Link href='https://www.blockchain.com/legal/privacy' target='_blank'>
<Button data-e2e='privacyLink' nature='empty-blue'>
<Icon name='open-in-new-tab' size='20px' />
</Button>
Expand All @@ -47,12 +38,4 @@ const PrivacyPolicy = (props: Props) => {
)
}

const mapDispatchToProps = (dispatch) => ({
settingsActions: bindActionCreators(actions.modules.settings, dispatch)
})

const connector = connect(null, mapDispatchToProps)

type Props = {} & ConnectedProps<typeof connector>

export default connector(PrivacyPolicy)
export default PrivacyPolicy
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { bindActionCreators } from 'redux'

import { Button, Icon, Link } from 'blockchain-info-components'
import {
Expand All @@ -11,9 +9,8 @@ import {
SettingHeader,
SettingSummary
} from 'components/Setting'
import { actions } from 'data'

const TermsOfService = (props: Props) => {
const TermsOfService = () => {
return (
<SettingContainer>
<SettingSummary>
Expand All @@ -31,13 +28,7 @@ const TermsOfService = (props: Props) => {
</SettingDescription>
</SettingSummary>
<SettingComponent>
<Link
onClick={() => {
props.settingsActions.generalSettingsExternalRedirect('/legal/terms')
}}
href='https://www.blockchain.com/legal/terms'
target='_blank'
>
<Link href='https://www.blockchain.com/legal/terms' target='_blank'>
<Button data-e2e='termsLink' nature='empty-blue'>
<Icon name='open-in-new-tab' size='20px' />
</Button>
Expand All @@ -47,12 +38,4 @@ const TermsOfService = (props: Props) => {
)
}

const mapDispatchToProps = (dispatch) => ({
settingsActions: bindActionCreators(actions.modules.settings, dispatch)
})

const connector = connect(null, mapDispatchToProps)

type Props = {} & ConnectedProps<typeof connector>

export default connector(TermsOfService)
export default TermsOfService
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { useSelector } from 'react-redux'

import { getGuid } from '@core/redux/wallet/selectors'
import { Text } from 'blockchain-info-components'
import {
SettingComponent,
Expand All @@ -10,9 +11,10 @@ import {
SettingHeader,
SettingSummary
} from 'components/Setting'
import { selectors } from 'data'

const WalletId = (props: Props) => {
const WalletId = () => {
const guid = useSelector(getGuid)

return (
<SettingContainer>
<SettingSummary>
Expand All @@ -37,19 +39,11 @@ const WalletId = (props: Props) => {
</SettingSummary>
<SettingComponent>
<Text color='grey800' data-e2e='walletId' size='14px' weight={600}>
{props.guid}
{guid}
</Text>
</SettingComponent>
</SettingContainer>
)
}

const mapStateToProps = (state) => ({
guid: selectors.core.wallet.getGuid(state) as string
})

const connector = connect(mapStateToProps)

type Props = ConnectedProps<typeof connector>

export default connector(WalletId)
export default WalletId
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { useSelector } from 'react-redux'

import {
SettingContainer,
Expand All @@ -10,7 +10,9 @@ import {
} from 'components/Setting'
import { selectors } from 'data'

const WalletVersion = (props: Props) => {
const WalletVersion = () => {
const walletVersion = useSelector(selectors.core.wallet.getVersion)

return (
<SettingContainer>
<SettingSummary>
Expand All @@ -20,18 +22,10 @@ const WalletVersion = (props: Props) => {
defaultMessage='Wallet Version'
/>
</SettingHeader>
<SettingDescription>{props.version}</SettingDescription>
<SettingDescription>{walletVersion}</SettingDescription>
</SettingSummary>
</SettingContainer>
)
}

const mapStateToProps = (state) => ({
version: selectors.core.wallet.getVersion(state) as string
})

const connector = connect(mapStateToProps)

type Props = ConnectedProps<typeof connector>

export default connector(WalletVersion)
export default WalletVersion
6 changes: 4 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/wallet/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { always, compose, curry, flatten, ifElse, isNil, map, prop } from 'ramda'

import { RootState } from 'data/rootReducer'

import {
Address,
AddressMap,
Expand All @@ -15,7 +17,7 @@ import { walletPath } from '../paths'
const intoJS = (i) => i.toJS()
export const getWrapper = prop(walletPath)
export const getWallet = compose(Wrapper.selectWallet, getWrapper)
export const getVersion = compose(Wrapper.selectVersion, getWrapper)
export const getVersion = (state: RootState) => state.walletPath.version as string
export const getDefaultHDWallet = compose(
HDWalletList.selectHDWallet,
Wallet.selectHdWallets,
Expand All @@ -27,7 +29,7 @@ export const getContext = compose(flatten, intoJS, Wallet.selectContext, getWall
export const getSpendableContext = compose(intoJS, Wallet.selectSpendableContext, getWallet)
export const getSpendableAddrContext = compose(intoJS, Wallet.selectSpendableAddrContext, getWallet)
export const getSharedKey = compose(Wallet.selectSharedKey, getWallet)
export const getGuid = compose(Wallet.selectGuid, getWallet)
export const getGuid = (state: RootState) => state.walletPath.wallet.guid
export const getAddresses = compose(intoJS, map(Address.toJS), Wallet.selectAddresses, getWallet)
export const getActiveAddresses = compose(
intoJS,
Expand Down
Loading