Skip to content

Commit 658558f

Browse files
authored
Merge branch 'develop' into feat/wallet-restoring-spinner
2 parents 5159b12 + 8fbb975 commit 658558f

49 files changed

Lines changed: 1370 additions & 86 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/cowswap-frontend/src/common/pure/NewModal/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ const Wrapper = styled.div<{
5050
}
5151
`
5252

53-
const Heading = styled.h2<{ modalMode: boolean }>`
53+
const Heading = styled.h2<{ skipLeftPadding: boolean }>`
5454
display: flex;
5555
flex-flow: row wrap;
5656
justify-content: space-between;
5757
width: 100%;
5858
height: auto;
5959
margin: 0;
60-
padding: ${({ modalMode }) => (modalMode ? '16px 20px 3px' : '16px 20px 3px 40px')};
60+
padding: ${({ skipLeftPadding }) => (skipLeftPadding ? '16px 20px 3px' : '16px 20px 3px 40px')};
6161
font-size: var(${UI.FONT_SIZE_MEDIUM});
6262
6363
${Media.upToSmall()} {
@@ -159,6 +159,7 @@ export interface NewModalProps {
159159
children?: React.ReactNode
160160
modalMode?: boolean
161161
justifyContent?: string
162+
showBackButton?: boolean
162163
}
163164

164165
export function NewModal({
@@ -170,15 +171,16 @@ export function NewModal({
170171
title,
171172
children,
172173
onDismiss,
174+
showBackButton = true,
173175
}: NewModalProps): ReactNode {
174176
const onDismissCallback = useCallback(() => onDismiss?.(), [onDismiss])
175177

176178
return (
177179
<Wrapper maxWidth={maxWidth} minHeight={minHeight} modalMode={modalMode}>
178180
<ModalInner>
179-
{!modalMode && <BackButtonStyled onClick={onDismissCallback} />}
181+
{!modalMode && showBackButton && <BackButtonStyled onClick={onDismissCallback} />}
180182
{title && (
181-
<Heading modalMode={!!modalMode}>
183+
<Heading skipLeftPadding={!!modalMode || !showBackButton}>
182184
{title}{' '}
183185
{modalMode && (
184186
<IconX onClick={onDismissCallback}>

apps/cowswap-frontend/src/locales/en-US.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,9 +3073,9 @@ msgstr "If allowance remains insufficient at creation time, this portion will no
30733073
#~ msgid "User rejected signing the order"
30743074
#~ msgstr "User rejected signing the order"
30753075

3076-
#: libs/common-const/src/common.ts
3077-
#~ msgid "Account Proxy"
3078-
#~ msgstr "Account Proxy"
3076+
#: apps/cowswap-frontend/src/pages/Account/index.tsx
3077+
msgid "Account Proxy"
3078+
msgstr "Account Proxy"
30793079

30803080
#: apps/cowswap-frontend/src/modules/orderProgressBar/constants.ts
30813081
#~ msgid "Executing', description: 'The winner of the competition is now executing your order on-chain."

apps/cowswap-frontend/src/modules/accountProxy/containers/AccountProxyWidgetPage/index.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { ReactNode, useLayoutEffect, useRef, useState } from 'react'
1+
import { ReactNode, useLayoutEffect, useState } from 'react'
22

3-
import { useOnClickOutside } from '@cowprotocol/common-hooks'
43
import { isAddress } from '@cowprotocol/common-utils'
54
import { useWalletInfo } from '@cowprotocol/wallet'
65

76
import { useLingui } from '@lingui/react/macro'
8-
import { Outlet, useLocation, useParams } from 'react-router'
7+
import { Outlet, useLocation, useParams, matchPath } from 'react-router'
98

109
import { useToggleWalletModal } from 'legacy/state/application/hooks'
1110

@@ -16,7 +15,7 @@ import { Routes } from 'common/constants/routes'
1615
import { useNavigate, useNavigateBack } from 'common/hooks/useNavigate'
1716
import { NewModal } from 'common/pure/NewModal'
1817

19-
import { EmptyWrapper, HelpLink, ModalWrapper, TitleWrapper, WidgetWrapper } from './styled'
18+
import { EmptyWrapper, HelpLink, TitleWrapper, WidgetWrapper } from './styled'
2019

2120
import { NEED_HELP_LABEL } from '../../consts'
2221
import { useOnAccountOrChainChanged } from '../../hooks/useOnAccountOrChainChanged'
@@ -28,18 +27,8 @@ import { WidgetPageTitle } from '../WidgetPageTitle'
2827

2928
const URL_NETWORK_CHANGED_STATE = 'network-changed'
3029

31-
interface AccountProxiesPageProps {
32-
modalMode?: boolean
33-
onDismiss?(): void
34-
}
35-
36-
export function AccountProxyWidgetPage({
37-
modalMode = false,
38-
onDismiss: modalOnDismiss,
39-
}: AccountProxiesPageProps): ReactNode {
30+
export function AccountProxyWidgetPage(): ReactNode {
4031
const { i18n } = useLingui()
41-
const widgetRef = useRef(null)
42-
const Wrapper = modalMode ? ModalWrapper : EmptyWrapper
4332
const { chainId, account } = useWalletInfo()
4433
const tradeNavigate = useTradeNavigate()
4534
const { inputCurrencyId, outputCurrencyId } = useSwapRawState()
@@ -55,10 +44,11 @@ export function AccountProxyWidgetPage({
5544

5645
const isWalletConnected = !!account
5746
const isHelpPage = location.pathname.endsWith('/help')
47+
const isRootProxyPage = !!matchPath(Routes.ACCOUNT_PROXIES, location.pathname)
5848
const query = new URLSearchParams(location.search)
5949
const [sourceRoute] = useState<string>(query.get('source') || 'swap')
6050

61-
const defaultOnDismiss = (): void => {
51+
const onDismiss = (): void => {
6252
if (location.key === 'default' || location.state === URL_NETWORK_CHANGED_STATE) {
6353
tradeNavigate(
6454
chainId,
@@ -71,22 +61,18 @@ export function AccountProxyWidgetPage({
7161
}
7262
}
7363

74-
const onDismiss = modalOnDismiss || defaultOnDismiss
75-
7664
// Go to main page when account/chainId changes
7765
useLayoutEffect(() => {
7866
if (!accountOrChainChanged) return
7967

8068
navigate(getProxyAccountUrl(chainId), { state: URL_NETWORK_CHANGED_STATE })
8169
}, [accountOrChainChanged, chainId, navigate])
8270

83-
useOnClickOutside([widgetRef], modalMode ? onDismiss : undefined)
84-
8571
return (
86-
<Wrapper $modalMode={modalMode}>
87-
<WidgetWrapper ref={widgetRef}>
72+
<EmptyWrapper>
73+
<WidgetWrapper>
8874
<NewModal
89-
modalMode={modalMode}
75+
showBackButton={!isRootProxyPage}
9076
title={
9177
<TitleWrapper>
9278
<span>
@@ -106,6 +92,6 @@ export function AccountProxyWidgetPage({
10692
{isWalletConnected || isHelpPage ? <Outlet /> : <WalletNotConnected onConnect={toggleWalletModal} />}
10793
</NewModal>
10894
</WidgetWrapper>
109-
</Wrapper>
95+
</EmptyWrapper>
11096
)
11197
}

apps/cowswap-frontend/src/modules/accountProxy/containers/AccountProxyWidgetPage/styled.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,14 @@
1-
import { Media } from '@cowprotocol/ui'
2-
3-
import { transparentize } from 'color2k'
41
import { Link } from 'react-router'
52
import styled from 'styled-components/macro'
63
import { WIDGET_MAX_WIDTH } from 'theme'
74

8-
export const EmptyWrapper = styled.div<{ $modalMode: boolean }>`
9-
width: 100%;
10-
`
11-
12-
export const ModalWrapper = styled.div<{ $modalMode: boolean }>`
13-
position: ${({ $modalMode }) => ($modalMode ? 'fixed' : 'static')};
5+
export const EmptyWrapper = styled.div`
146
width: 100%;
15-
height: 100%;
16-
z-index: 100;
17-
left: 0;
18-
top: 0;
19-
overflow-y: scroll;
20-
padding: 50px 0;
21-
background: ${({ theme }) => (theme.isWidget ? 'transparent' : transparentize(theme.black, 0.5))};
22-
backdrop-filter: blur(3px);
23-
24-
${Media.upToSmall()} {
25-
padding: 0;
26-
}
277
`
288

299
export const WidgetWrapper = styled.div`
3010
width: 100%;
3111
max-width: ${WIDGET_MAX_WIDTH.swap};
32-
margin: 0 auto;
3312
position: relative;
3413
`
3514

apps/cowswap-frontend/src/modules/accountProxy/index.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/cowswap-frontend/src/modules/application/containers/App/RoutesApp.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ export function RoutesApp(): ReactNode {
9292
<Route path="*" element={<AccountNotFound />} />
9393
</Route>
9494

95-
<Route path={RoutesEnum.ACCOUNT_PROXIES} element={<AccountProxyWidgetPage />}>
96-
<Route path={RoutesEnum.ACCOUNT_PROXY} element={<AccountProxyPage />} />
97-
<Route path={RoutesEnum.ACCOUNT_PROXY_RECOVER} element={<AccountProxyRecoverPage />} />
98-
<Route path={RoutesEnum.ACCOUNT_PROXY_HELP} element={<AccountProxyHelpPage />} />
99-
<Route index element={<AccountProxiesPage />} />
95+
<Route path={RoutesEnum.ACCOUNT_PROXIES} element={<Account />}>
96+
<Route element={<AccountProxyWidgetPage />}>
97+
<Route path={RoutesEnum.ACCOUNT_PROXY} element={<AccountProxyPage />} />
98+
<Route path={RoutesEnum.ACCOUNT_PROXY_RECOVER} element={<AccountProxyRecoverPage />} />
99+
<Route path={RoutesEnum.ACCOUNT_PROXY_HELP} element={<AccountProxyHelpPage />} />
100+
<Route index element={<AccountProxiesPage />} />
101+
</Route>
100102
</Route>
101103
<Route path="claim" element={<Navigate to={RoutesEnum.ACCOUNT} />} />
102104
<Route path="profile" element={<Navigate to={RoutesEnum.ACCOUNT} />} />

apps/cowswap-frontend/src/modules/application/containers/App/menuConsts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jest.mock('modules/fortune', () => ({
3434
FortuneWidget: () => null,
3535
}))
3636

37+
jest.mock('modules/accountProxy', () => ({
38+
getProxyAccountUrl: (chainId: number) => `/${chainId}/account/account-proxy`,
39+
}))
40+
3741
jest.mock('./menuConsts.utils', () => ({
3842
getSolversExplorerUrl: () => 'https://explorer.cow.fi/solvers',
3943
}))

apps/cowswap-frontend/src/modules/application/containers/App/menuConsts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { msg } from '@lingui/core/macro'
88
import AppziButton from 'legacy/components/AppziButton'
99
import { Version } from 'legacy/components/Version'
1010

11+
import { getProxyAccountUrl } from 'modules/accountProxy'
1112
import { FortuneWidget } from 'modules/fortune'
1213

1314
import { Routes } from 'common/constants/routes'
@@ -51,7 +52,7 @@ const ACCOUNT_ITEM = (chainId: SupportedChainId): UntranslatedMenuItem => ({
5152
label: msg`Tokens`,
5253
},
5354
{
54-
href: `/${chainId}/account-proxy`,
55+
href: getProxyAccountUrl(chainId),
5556
label: ACCOUNT_PROXY_LABEL,
5657
},
5758
],

apps/cowswap-frontend/src/modules/bridge/pure/ProxyAccountBanner/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BannerOrientation, CollapsibleInlineBanner, StatusColorVariant } from '
66
import { Trans, useLingui } from '@lingui/react/macro'
77
import { Link } from 'react-router'
88

9-
import { getProxyAccountUrl } from 'modules/accountProxy/utils/getProxyAccountUrl'
9+
import { getProxyAccountUrl } from 'modules/accountProxy'
1010

1111
import { AddressLink } from 'common/pure/AddressLink'
1212

apps/cowswap-frontend/src/modules/swap/containers/BottomBanners/BottomBanners.container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useWalletInfo } from '@cowprotocol/wallet'
77
import { Trans } from '@lingui/react/macro'
88
import { Link } from 'react-router'
99

10-
import { getProxyAccountUrl } from 'modules/accountProxy/utils/getProxyAccountUrl'
10+
import { getProxyAccountUrl } from 'modules/accountProxy'
1111
import { useIsHooksTradeType } from 'modules/trade'
1212

1313
import { useIsProviderNetworkDeprecated } from 'common/hooks/useIsProviderNetworkDeprecated'

0 commit comments

Comments
 (0)