-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a9bb17
commit a795e14
Showing
12 changed files
with
245 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web/5.7.0 | ||
web/5.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Trans } from '@lingui/macro' | ||
import { ChainId } from '@uniswap/sdk-core' | ||
import { Container, PopupContainer, StyledXButton, TextContainer } from 'components/Banner/shared/styled' | ||
import { chainIdToBackendName } from 'graphql/data/util' | ||
import { useState } from 'react' | ||
import { Globe } from 'react-feather' | ||
import styled, { useTheme } from 'styled-components' | ||
import { ExternalLink, ThemedText } from 'theme/components' | ||
import { capitalize } from 'tsafe' | ||
|
||
const IconContainer = styled.div` | ||
height: 100%; | ||
margin: 12px 0 0 12px; | ||
align-self: flex-start; | ||
` | ||
|
||
const IconBackground = styled.div` | ||
background-color: #1f1e02; | ||
padding: 10px; | ||
border-radius: 12px; | ||
` | ||
|
||
const StyledPopupContainer = styled(PopupContainer)` | ||
height: unset; | ||
` | ||
|
||
const OutageTextContainer = styled(TextContainer)` | ||
padding: 10px 10px 10px 0; | ||
` | ||
|
||
const HelpCenterLink = styled(ExternalLink)` | ||
font-size: 14px; | ||
margin-top: 4px; | ||
` | ||
|
||
export function getOutageBannerSessionStorageKey(chainId: ChainId) { | ||
return `hideOutageBanner-${chainId}` | ||
} | ||
|
||
export function OutageBanner({ chainId }: { chainId: ChainId }) { | ||
const [hidden, setHidden] = useState(false) | ||
const theme = useTheme() | ||
|
||
return ( | ||
<StyledPopupContainer show={!hidden}> | ||
<Container> | ||
<IconContainer> | ||
<IconBackground> | ||
<Globe size={28} color={theme.warning2} /> | ||
</IconBackground> | ||
</IconContainer> | ||
<OutageTextContainer> | ||
<ThemedText.BodySmall lineHeight="20px"> | ||
<Trans>Data will be back soon</Trans> | ||
</ThemedText.BodySmall> | ||
<ThemedText.LabelMicro> | ||
<Trans> | ||
The subgraph for {capitalize(chainIdToBackendName(chainId).toLowerCase())} is down right now, but we | ||
expect the issue to be resolved shortly. | ||
</Trans> | ||
</ThemedText.LabelMicro> | ||
<ThemedText.LabelMicro> | ||
<Trans>You can still swap and provide liquidity for this token without issue.</Trans> | ||
</ThemedText.LabelMicro> | ||
<HelpCenterLink href="https://support.uniswap.org/hc/en-us/articles/23952001935373-Subgraph-downtime"> | ||
<Trans>Learn more</Trans> | ||
</HelpCenterLink> | ||
</OutageTextContainer> | ||
<StyledXButton | ||
data-testid="uniswap-outage-banner" | ||
size={24} | ||
onClick={() => { | ||
setHidden(true) | ||
sessionStorage.setItem(getOutageBannerSessionStorageKey(chainId), 'true') | ||
}} | ||
/> | ||
</Container> | ||
</StyledPopupContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { InterfacePageName } from '@uniswap/analytics-events' | ||
import { ChainId } from '@uniswap/sdk-core' | ||
import WalletAppPromoBanner from 'components/Banner/MobileAppAnnouncementBanner' | ||
import { OutageBanner, getOutageBannerSessionStorageKey } from 'components/Banner/Outage/OutageBanner' | ||
import { useOutageBanners } from 'featureFlags/flags/outageBanner' | ||
import { getValidUrlChainId } from 'graphql/data/util' | ||
import { useMemo } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
import { getCurrentPageFromLocation } from 'utils/urlRoutes' | ||
|
||
export function Banners() { | ||
const { pathname } = useLocation() | ||
const currentPage = getCurrentPageFromLocation(pathname) | ||
|
||
const outageBanners = useOutageBanners() | ||
|
||
// Calculate the chainId for the current page's contextual chain (e.g. /tokens/ethereum or /tokens/arbitrum), if it exists. | ||
const pageChainId = useMemo(() => { | ||
const chainName = pathname.split('/').find((maybeChainName) => { | ||
const validatedChainId = getValidUrlChainId(maybeChainName) | ||
return validatedChainId !== undefined | ||
}) | ||
return chainName ? getValidUrlChainId(chainName) : undefined | ||
}, [pathname]) | ||
|
||
const showOutageBanner = useMemo(() => { | ||
return ( | ||
currentPage && | ||
pageChainId && | ||
outageBanners[pageChainId as ChainId] && | ||
!sessionStorage.getItem(getOutageBannerSessionStorageKey(pageChainId)) && | ||
[ | ||
InterfacePageName.EXPLORE_PAGE, | ||
InterfacePageName.TOKEN_DETAILS_PAGE, | ||
// InterfacePageName.POOL_DETAILS_PAGE, | ||
InterfacePageName.TOKENS_PAGE, | ||
].includes(currentPage) | ||
) | ||
}, [currentPage, outageBanners, pageChainId]) | ||
|
||
// Outage Banners should take precedence over the Wallet Download Banner | ||
if (pageChainId && showOutageBanner) { | ||
return <OutageBanner chainId={pageChainId} /> | ||
} | ||
|
||
return <WalletAppPromoBanner /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ChainId } from '@uniswap/sdk-core' | ||
import { BaseVariant, FeatureFlag, useBaseFlag } from '../index' | ||
|
||
export function useOutageBannerOptimism(): BaseVariant { | ||
return useBaseFlag(FeatureFlag.outageBannerOptimism) | ||
} | ||
|
||
function useShowOutageBannerOptimism(): boolean { | ||
return useOutageBannerOptimism() === BaseVariant.Enabled | ||
} | ||
|
||
export function useOutageBannerArbitrum(): BaseVariant { | ||
return useBaseFlag(FeatureFlag.outageBannerArbitrum) | ||
} | ||
|
||
function useShowOutageBannerArbitrum(): boolean { | ||
return useOutageBannerArbitrum() === BaseVariant.Enabled | ||
} | ||
|
||
export function useOutageBannerPolygon(): BaseVariant { | ||
return useBaseFlag(FeatureFlag.outageBannerPolygon) | ||
} | ||
|
||
function useShowOutageBannerPolygon(): boolean { | ||
return useOutageBannerPolygon() === BaseVariant.Enabled | ||
} | ||
|
||
export function useOutageBanners(): Record<ChainId, boolean> { | ||
return { | ||
[ChainId.OPTIMISM]: useShowOutageBannerOptimism(), | ||
[ChainId.ARBITRUM_ONE]: useShowOutageBannerArbitrum(), | ||
[ChainId.POLYGON]: useShowOutageBannerPolygon(), | ||
|
||
[ChainId.MAINNET]: false, | ||
[ChainId.GOERLI]: false, | ||
[ChainId.SEPOLIA]: false, | ||
[ChainId.OPTIMISM_GOERLI]: false, | ||
[ChainId.ARBITRUM_GOERLI]: false, | ||
[ChainId.POLYGON_MUMBAI]: false, | ||
[ChainId.CELO]: false, | ||
[ChainId.CELO_ALFAJORES]: false, | ||
[ChainId.GNOSIS]: false, | ||
[ChainId.MOONBEAM]: false, | ||
[ChainId.BNB]: false, | ||
[ChainId.AVALANCHE]: false, | ||
[ChainId.BASE_GOERLI]: false, | ||
[ChainId.BASE]: false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.