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

fix: remove AddAcount modal accounts page redirect #12612

Merged
merged 3 commits into from
Mar 16, 2022
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
Expand Up @@ -47,7 +47,6 @@ export interface Props {
onAddHardwareAccounts: (selected: BraveWallet.HardwareWalletAccount[]) => void
getBalance: (address: string) => Promise<string>
onSetImportError: (hasError: boolean) => void
onRouteBackToAccounts: () => void
hasImportError: boolean
accounts: WalletAccountType[]
tab: AddAccountNavTypes
Expand All @@ -70,8 +69,7 @@ const AddAccountModal = (props: Props) => {
onAddHardwareAccounts,
getBalance,
onImportAccountFromJson,
onSetImportError,
onRouteBackToAccounts
onSetImportError
} = props

const [importOption, setImportOption] = React.useState<string>('key')
Expand Down Expand Up @@ -122,7 +120,6 @@ const AddAccountModal = (props: Props) => {
const onClickCreateAccount = () => {
if (tab === 'create') {
onCreateAccount(accountName, selectedAccountType?.coin || BraveWallet.CoinType.ETH)
onRouteBackToAccounts()
return
}
if (tab === 'import') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { Route, useHistory, useParams } from 'react-router-dom'
import { Route, useHistory, useLocation, useParams } from 'react-router-dom'
import { StyledWrapper } from './style'
import {
BraveWallet,
Expand Down Expand Up @@ -87,6 +87,7 @@ export interface Props {
}

const CryptoView = (props: Props) => {
const { pathname: walletLocation } = useLocation()
let history = useHistory()
const {
onLockWallet,
Expand Down Expand Up @@ -204,24 +205,17 @@ const CryptoView = (props: Props) => {
}

const onCloseAddModal = () => {
history.push(`${WalletRoutes.Accounts}`)
if (walletLocation.includes(WalletRoutes.Accounts)) {
history.push(WalletRoutes.Accounts)
}
onHideAddModal()
}

const onClickAddAccount = (tabId: AddAccountNavTypes) => () => {
if (tabId === 'create') {
history.push(`${WalletRoutes.AddAccountModal}`)
setAddAccountModalTab(tabId)
return
}
setAddAccountModalTab(tabId)
onShowAddModal()
}

const onRouteBack = () => {
history.push(`${WalletRoutes.Accounts}`)
}

const selectAsset = (asset: BraveWallet.BlockchainToken | undefined) => {
if (asset) {
history.push(`${WalletRoutes.Portfolio}/${asset.symbol}`)
Expand Down Expand Up @@ -368,7 +362,6 @@ const CryptoView = (props: Props) => {
accounts={accounts}
selectedNetwork={selectedNetwork}
onClose={onCloseAddModal}
onRouteBackToAccounts={onRouteBack}
onCreateAccount={onCreateAccount}
onImportAccount={onImportAccount}
isFilecoinEnabled={isFilecoinEnabled}
Expand Down
3 changes: 3 additions & 0 deletions components/brave_wallet_ui/page/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ function Container (props: Props) {

const onCreateAccount = (name: string, coin: BraveWallet.CoinType) => {
const created = props.walletPageActions.addAccount({ accountName: name, coin: coin })
if (walletLocation.includes(WalletRoutes.Accounts)) {
history.push(WalletRoutes.Accounts)
}
if (created) {
onHideAddModal()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ const CryptoStoryView = (props: Props) => {
alert('Will Nav to brave://settings/wallet')
}

const onRouteBackToAccounts = () => {
// Does nothing in storybook
}

const onClickRetryTransaction = () => {
// Does nothing in storybook
alert('Will retry transaction')
Expand Down Expand Up @@ -363,7 +359,6 @@ const CryptoStoryView = (props: Props) => {
onImportAccountFromJson={onImportAccountFromJson}
hasImportError={hasImportError}
onSetImportError={onSetImportError}
onRouteBackToAccounts={onRouteBackToAccounts}
tab={addAccountModalTab}
/>
}
Expand Down