Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:safe-global/web-core into epic-tx-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Jun 27, 2023
2 parents 2d6cd18 + b9e2b18 commit 2cc1c42
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/smoke/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Dashboard', () => {
cy.contains('2/3')
cy.get(`a[href="/balances?safe=${SAFE}"]`).contains('View assets')
// Text next to Tokens contains a number greater than 0
cy.contains('p', 'Tokens').next().contains('3')
cy.contains('p', 'Tokens').next().contains('4')
cy.contains('p', 'NFTs').next().contains('0')
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/CheckWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CheckWallet = ({ children, allowSpendingLimit, allowNonOwner }: CheckWalle
? Message.WalletNotConnected
: !isSafeOwner && !isSpendingLimit && !allowNonOwner
? Message.NotSafeOwner
: isSpendingLimit && !allowSpendingLimit
: isSpendingLimit && !allowSpendingLimit && !allowNonOwner
? Message.OnlySpendingLimitBeneficiary
: ''

Expand Down
6 changes: 4 additions & 2 deletions src/components/common/PaginatedTxns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { type TxFilter, useTxFilter } from '@/utils/tx-history-filter'
import { isTransactionListItem } from '@/utils/transaction-guards'
import NoTransactionsIcon from '@/public/images/transactions/no-transactions.svg'
import { useHasPendingTxs } from '@/hooks/usePendingTxs'
import useSafeInfo from '@/hooks/useSafeInfo'

const NoQueuedTxns = () => {
return <PagePlaceholder img={<NoTransactionsIcon />} text="Queued transactions will appear here" />
Expand Down Expand Up @@ -68,11 +69,12 @@ const TxPage = ({
const PaginatedTxns = ({ useTxns }: { useTxns: typeof useTxHistory | typeof useTxQueue }): ReactElement => {
const [pages, setPages] = useState<string[]>([''])
const [filter] = useTxFilter()
const { safeAddress, safe } = useSafeInfo()

// Reset the pages when the filter changes
// Reset the pages when the Safe Account or filter changes
useEffect(() => {
setPages([''])
}, [filter, useTxns])
}, [filter, safe.chainId, safeAddress, useTxns])

// Trigger the next page load
const onNextPage = (pageUrl: string) => {
Expand Down
12 changes: 11 additions & 1 deletion src/components/dashboard/CreationDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { type ElementType } from 'react'
import { Box, Button, Dialog, DialogContent, Grid, SvgIcon, Typography } from '@mui/material'
import { useRouter } from 'next/router'

import HomeIcon from '@/public/images/sidebar/home.svg'
import TransactionIcon from '@/public/images/sidebar/transactions.svg'
Expand All @@ -9,6 +10,7 @@ import BeamerIcon from '@/public/images/sidebar/whats-new.svg'
import HelpCenterIcon from '@/public/images/sidebar/help-center.svg'
import { useRemoteSafeApps } from '@/hooks/safe-apps/useRemoteSafeApps'
import { useCurrentChain } from '@/hooks/useChains'
import { CREATION_MODAL_QUERY_PARM } from '@/components/new-safe/create/logic'

const HintItem = ({ Icon, title, description }: { Icon: ElementType; title: string; description: string }) => {
return (
Expand All @@ -26,10 +28,18 @@ const HintItem = ({ Icon, title, description }: { Icon: ElementType; title: stri
}

const CreationDialog = () => {
const router = useRouter()
const [open, setOpen] = React.useState(true)
const [remoteSafeApps = []] = useRemoteSafeApps()
const chain = useCurrentChain()

const onClose = () => {
const { [CREATION_MODAL_QUERY_PARM]: _, ...query } = router.query
router.replace({ pathname: router.pathname, query })

setOpen(false)
}

return (
<Dialog open={open}>
<DialogContent sx={{ paddingX: 8, paddingTop: 9, paddingBottom: 6 }}>
Expand Down Expand Up @@ -64,7 +74,7 @@ const CreationDialog = () => {
/>
</Grid>
<Box display="flex" justifyContent="center">
<Button onClick={() => setOpen(false)} variant="contained" size="stretched">
<Button onClick={onClose} variant="contained" size="stretched">
Got it
</Button>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { useRouter } from 'next/router'
import Relaying from '@/components/dashboard/Relaying'
import { FEATURES } from '@/utils/chains'
import { useHasFeature } from '@/hooks/useChains'
import { CREATION_MODAL_QUERY_PARM } from '../new-safe/create/logic'

const Dashboard = (): ReactElement => {
const router = useRouter()
const supportsRelaying = useHasFeature(FEATURES.RELAYING)
const { showCreationModal = '' } = router.query
const { [CREATION_MODAL_QUERY_PARM]: showCreationModal = '' } = router.query

return (
<>
Expand Down
4 changes: 3 additions & 1 deletion src/components/new-safe/create/logic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export const checkSafeCreationTx = async (
}
}

export const CREATION_MODAL_QUERY_PARM = 'showCreationModal'

export const getRedirect = (
chainPrefix: string,
safeAddress: string,
Expand All @@ -248,7 +250,7 @@ export const getRedirect = (

// Go to the dashboard if no specific redirect is provided
if (!redirectUrl) {
return { pathname: AppRoutes.home, query: { safe: address, showCreationModal: true } }
return { pathname: AppRoutes.home, query: { safe: address, [CREATION_MODAL_QUERY_PARM]: true } }
}

// Otherwise, redirect to the provided URL (e.g. from a Safe App)
Expand Down
9 changes: 8 additions & 1 deletion src/components/safe-messages/PaginatedMsgs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from '@mui/material'
import { Typography, Link, SvgIcon } from '@mui/material'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import type { ReactElement } from 'react'

import ErrorMessage from '@/components/tx/ErrorMessage'
Expand All @@ -12,6 +12,7 @@ import PagePlaceholder from '@/components/common/PagePlaceholder'
import MsgList from '@/components/safe-messages/MsgList'
import SkeletonTxList from '@/components/common/PaginatedTxns/SkeletonTxList'
import { HelpCenterArticle } from '@/config/constants'
import useSafeInfo from '@/hooks/useSafeInfo'

const NoMessages = (): ReactElement => {
return (
Expand Down Expand Up @@ -62,12 +63,18 @@ const MsgPage = ({

const PaginatedMsgs = (): ReactElement => {
const [pages, setPages] = useState<string[]>([''])
const { safeAddress, safe } = useSafeInfo()

// Trigger the next page load
const onNextPage = (pageUrl: string) => {
setPages((prev) => prev.concat(pageUrl))
}

// Reset the pages when the Safe Account changes
useEffect(() => {
setPages([''])
}, [safe.chainId, safeAddress])

return (
<Box mb={4} position="relative">
{pages.map((pageUrl, index) => (
Expand Down

0 comments on commit 2cc1c42

Please sign in to comment.