Skip to content

Commit

Permalink
Merge pull request #25470 from brave/feat-wallet-enhanced-transaction…
Browse files Browse the repository at this point in the history
…-submission-status-panels

feat(wallet): Enhanced Transaction Submission Status Panels
  • Loading branch information
Douglashdaniel committed Sep 16, 2024
2 parents dabb50e + 896d742 commit c398669
Show file tree
Hide file tree
Showing 32 changed files with 1,309 additions and 584 deletions.
2 changes: 2 additions & 0 deletions browser/ui/webui/brave_wallet/wallet_page_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ WalletPageUI::WalletPageUI(content::WebUI* web_ui)
plural_string_handler->AddLocalizedString(
"braveWalletExchangeNamePlusSteps",
IDS_BRAVE_WALLET_EXCHANGE_NAME_PLUS_STEPS);
plural_string_handler->AddLocalizedString(
"braveWalletPendingTransactions", IDS_BRAVE_WALLET_PENDING_TRANSACTIONS);
web_ui->AddMessageHandler(std::move(plural_string_handler));
NavigationBarDataProvider::Initialize(source, profile);
webui::SetupWebUIDataSource(
Expand Down
2 changes: 2 additions & 0 deletions browser/ui/webui/brave_wallet/wallet_panel_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ WalletPanelUI::WalletPanelUI(content::WebUI* web_ui)
plural_string_handler->AddLocalizedString(
"braveWalletExchangeNamePlusSteps",
IDS_BRAVE_WALLET_EXCHANGE_NAME_PLUS_STEPS);
plural_string_handler->AddLocalizedString(
"braveWalletPendingTransactions", IDS_BRAVE_WALLET_PENDING_TRANSACTIONS);
web_ui->AddMessageHandler(std::move(plural_string_handler));
webui::SetupWebUIDataSource(source,
base::make_span(kBraveWalletPanelGenerated,
Expand Down
26 changes: 22 additions & 4 deletions components/brave_wallet/browser/brave_wallet_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -1124,14 +1124,32 @@ inline constexpr webui::LocalizedString kLocalizedStrings[] = {
{"braveWalletPortfolioSettings", IDS_BRAVE_WALLET_PORTFOLIO_SETTINGS},
{"braveWalletAccountFilterAllAccounts",
IDS_BRAVE_WALLET_ACCOUNT_FILTER_ALL_ACCOUNTS},
{"braveWalletGetHelp", IDS_BRAVE_WALLET_GET_HELP},
{"braveWalletTransactionTakingLongTime",
IDS_BRAVE_WALLET_TRANSACTION_TAKING_LONG_TIME},
{"braveWalletViewInActivity", IDS_BRAVE_WALLET_VIEW_IN_ACTIVITY},
{"braveWalletSafelyDismissWindow", IDS_BRAVE_WALLET_SAFELY_DISMISS_WINDOW},
{"braveWalletSendingAmountToAccount",
IDS_BRAVE_WALLET_SENDING_AMOUNT_TO_ACCOUNT},
{"braveWalletAmountSentToAccount", IDS_BRAVE_WALLET_AMOUNT_SENT_TO_ACCOUNT},
{"braveWalletSwappingAmountToAmountOnNetwork",
IDS_BRAVE_WALLET_SWAPPING_AMOUNT_TO_ACCOUNT_ON_NETWORK},
{"braveWalletAmountAddedToAccount",
IDS_BRAVE_WALLET_AMOUNT_ADDED_TO_ACCOUNT},
{"braveWalletBridgingAmountToNetwork",
IDS_BRAVE_WALLET_BRIDGING_AMOUNT_TO_NETWORK},
{"braveWalletUnableToSendSwapOrBridge",
IDS_BRAVE_WALLET_UNABLE_TO_SEND_SWAP_OR_BRIDGE},
{"braveWalletErrorAttemptingToTransact",
IDS_BRAVE_WALLET_ERROR_ATTEMPTING_TO_TRANSACT},
{"braveWalletApprovingAmountOnExchange",
IDS_BRAVE_WALLET_APPROVING_AMOUNT_ON_EXCHANGE},
{"braveWalletCancelTransactionDescription",
IDS_BRAVE_WALLET_CANCEL_TRANSACTION_DESCRIPTION},
{"braveWalletTransactionSubmittedTitle",
IDS_BRAVE_WALLET_TRANSACTION_SUBMITTED_TITLE},
{"braveWalletTransactionSubmittedDescription",
IDS_BRAVE_WALLET_TRANSACTION_SUBMITTED_DESCRIPTION},
{"braveWalletTransactionSignedTitle",
IDS_BRAVE_WALLET_TRANSACTION_SIGNED_TITLE},
{"braveWalletTransactionSignedDescription",
IDS_BRAVE_WALLET_TRANSACTION_SIGNED_DESCRIPTION},
{"braveWalletTransactionFailedHeaderTitle",
IDS_BRAVE_WALLET_TRANSACTION_FAILED_HEADER_TITLE},
{"braveWalletTransactionFailedTitle",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
import * as React from 'react'

// Mocks
import {
mockTransactionInfo //
} from '../../../../stories/mock-data/mock-transaction-info'

// Components
import {
WalletPanelStory //
} from '../../../../stories/wrappers/wallet-panel-story-wrapper'
import { CancelTransaction } from './cancel_transaction'

// Styled Components
import { LongWrapper } from '../../../../stories/style'
import { PanelWrapper } from '../../../../panel/style'

export const _CancelTransaction = {
render: () => {
return (
<WalletPanelStory>
<PanelWrapper
width={390}
height={650}
>
<LongWrapper padding='0px'>
<CancelTransaction
onBack={() => alert('Back clicked')}
transaction={mockTransactionInfo}
/>
</LongWrapper>
</PanelWrapper>
</WalletPanelStory>
)
}
}

export default { component: CancelTransaction }
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
import styled from 'styled-components'
import Button from '@brave/leo/react/button'
import * as leo from '@brave/leo/tokens/css/variables'

export const CancelButton = styled(Button)`
--leo-button-color: ${leo.color.button.errorBackground};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
import * as React from 'react'

// Types
import { SerializableTransactionInfo } from '../../../../constants/types'

// Utils
import { getLocale } from '$web-common/locale'
import { getCoinFromTxDataUnion } from '../../../../utils/network-utils'

// Hooks
import {
useCancelTransactionMutation //
} from '../../../../common/slices/api.slice'

// Components
import { PostConfirmationHeader } from '../common/post_confirmation_header'

// Styled components
import { CancelButton } from './cancel_transaction.style'
import { Wrapper, Title } from '../common/common.style'
import { Column, Row, Text } from '../../../shared/style'

interface Props {
transaction: SerializableTransactionInfo
onBack: () => void
}

export const CancelTransaction = (props: Props) => {
const { transaction, onBack } = props

// Computed
const txCoinType = getCoinFromTxDataUnion(transaction.txDataUnion)

// Hooks
const [cancelTx] = useCancelTransactionMutation()

// Methods
const onClickCancelTransaction = () => {
cancelTx({
coinType: txCoinType,
chainId: transaction.chainId,
transactionId: transaction.id
})
}

return (
<Wrapper
fullWidth={true}
fullHeight={true}
alignItems='center'
justifyContent='space-between'
>
<PostConfirmationHeader onBack={onBack} />
<Column
fullWidth={true}
padding='0px 24px'
gap='8px'
>
<Title>{getLocale('braveWalletTransactionCancel')}</Title>
<Text
textSize='14px'
textColor='primary'
isBold={false}
>
{getLocale('braveWalletCancelTransactionDescription')}
</Text>
</Column>
<Row padding='16px'>
<CancelButton onClick={onClickCancelTransaction}>
{getLocale('braveWalletTransactionCancel')}
</CancelButton>
</Row>
</Wrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at https://mozilla.org/MPL/2.0/.
import styled from 'styled-components'

import ProgressRing from '@brave/leo/react/progressRing'
import LeoIcon from '@brave/leo/react/icon'
import LeoAlert from '@brave/leo/react/alert'
import * as leo from '@brave/leo/tokens/css/variables'
import LinkSvg from '../../../../assets/svg-icons/link-icon.svg'
import LoadingIcon from '../../../../assets/svg-icons/loading-slow.svg'
import { WalletButton } from '../../../shared/style'
import { WalletButton, Column, Text } from '../../../shared/style'

export const TransactionStatusIcon = styled.div`
width: 112px;
height: 112px;
margin: 24px 0;
export const Wrapper = styled(Column)`
background-color: ${leo.color.container.highlight};
`

export const TransactionStatusText = styled.div`
font-family: 'Poppins';
font-style: normal;
font-weight: 600;
font-size: 18px;
line-height: 27px;
text-align: center;
letter-spacing: 0.02em;
export const Title = styled(Text)`
font: ${leo.font.heading.h3};
margin-bottom: 8px;
`

export const TransactionStatusDescription = styled.div`
Expand All @@ -33,31 +28,7 @@ export const TransactionStatusDescription = styled.div`
line-height: 20px;
text-align: center;
color: ${(p) => p.theme.color.text02};
padding: 8px 16px;
flex-grow: 1;
`

export const PendingTransactionsRow = styled.div`
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 20px;
text-align: center;
color: ${(p) => p.theme.color.text03};
padding: 8px 16px;
flex-grow: 1;
`

export const ButtonRow = styled.div`
display: flex;
align-items: center;
justify-content: center;
flex-direction: row;
width: 100%;
padding-bottom: 22px;
gap: 8px;
`

export const LinkIcon = styled.div`
Expand Down Expand Up @@ -90,3 +61,68 @@ export const Loader = styled.div`
margin: 36px 0;
opacity: 0.4;
`

export const LoadingRing = styled(ProgressRing)`
--leo-progressring-size: 110px;
--leo-progressring-color: ${leo.color.icon.interactive};
margin-bottom: 46px;
`

export const StatusIcon = styled(LeoIcon)`
--leo-icon-size: 34px;
color: ${leo.color.icon.interactive};
`

export const Button = styled(WalletButton)`
cursor: pointer;
background-color: none;
background: none;
outline: none;
border: none;
padding: 0px;
margin: 0px;
`

export const HeaderButton = styled(Button)`
margin: 2px 0px;
`

export const HeaderIcon = styled(LeoIcon)`
--leo-icon-size: 24px;
color: ${leo.color.icon.default};
`

export const ExplorerIcon = styled(LeoIcon).attrs({
name: 'arrow-diagonal-up-right'
})`
--leo-icon-size: 20px;
color: ${leo.color.icon.interactive};
`

export const Alert = styled(LeoAlert)`
width: 100%;
--leo-alert-padding: 12px;
margin-bottom: 46px;
`

export const ErrorOrSuccessIconWrapper = styled.div<{
kind: 'error' | 'success'
}>`
padding: 20px;
border-radius: 100%;
background-color: ${(p) =>
p.kind === 'error'
? leo.color.systemfeedback.errorBackground
: leo.color.systemfeedback.successBackground};
margin-bottom: 40px;
`

export const ErrorOrSuccessIcon = styled(LeoIcon)<{
kind: 'error' | 'success'
}>`
--leo-icon-size: 60px;
color: ${(p) =>
p.kind === 'error'
? leo.color.systemfeedback.errorIcon
: leo.color.systemfeedback.successIcon};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
import * as React from 'react'
import Icon from '@brave/leo/react/icon'
import LeoButton from '@brave/leo/react/button'

// Utils
import { getLocale } from '$web-common/locale'

// Styled Components
import { HeaderButton, HeaderIcon } from './common.style'
import { Row } from '../../../shared/style'

interface Props {
onClose?: () => void
onBack?: () => void
showHelp?: boolean
}

export const PostConfirmationHeader = (props: Props) => {
const { onClose, onBack, showHelp } = props

return (
<Row
padding='16px'
justifyContent={onBack || showHelp ? 'space-between' : 'flex-end'}
>
{showHelp && (
<div>
<LeoButton
kind='outline'
size='tiny'
>
<Icon
slot='icon-before'
name='help-outline'
/>
{getLocale('braveWalletGetHelp')}
</LeoButton>
</div>
)}
{onBack && (
<HeaderButton onClick={onBack}>
<HeaderIcon name='arrow-left' />
</HeaderButton>
)}
{onClose && (
<HeaderButton onClick={onClose}>
<HeaderIcon name='close' />
</HeaderButton>
)}
</Row>
)
}
Loading

0 comments on commit c398669

Please sign in to comment.