Commit 888124f2 authored by tom's avatar tom

Merge branch 'main' of github.com:blockscout/frontend into block-sockets

parents e6aa65e7 b2cd2daa
...@@ -296,6 +296,10 @@ frontend: ...@@ -296,6 +296,10 @@ frontend:
- "/static" - "/static"
- "/auth/profile" - "/auth/profile"
- "/account" - "/account"
- "/txs"
- "/tx"
- "/blocks"
- "/block"
resources: resources:
limits: limits:
memory: memory:
......
...@@ -295,7 +295,10 @@ frontend: ...@@ -295,7 +295,10 @@ frontend:
- "/node-api" - "/node-api"
- "/static" - "/static"
- "/auth/profile" - "/auth/profile"
- "/account" - "/txs"
- "/tx"
- "/blocks"
- "/block"
resources: resources:
limits: limits:
memory: memory:
......
...@@ -7,13 +7,11 @@ type Props = { ...@@ -7,13 +7,11 @@ type Props = {
pageProps: PageProps; pageProps: PageProps;
} }
const AppContext = createContext<PageProps>({ cookies: '' }); const AppContext = createContext<PageProps>({ cookies: '', referrer: '' });
export function AppWrapper({ children, pageProps }: Props) { export function AppWrapper({ children, pageProps }: Props) {
const appProps = { cookies: pageProps.cookies };
return ( return (
<AppContext.Provider value={ appProps }> <AppContext.Provider value={ pageProps }>
{ children } { children }
</AppContext.Provider> </AppContext.Provider>
); );
......
...@@ -2,12 +2,14 @@ import type { GetServerSideProps, GetServerSidePropsResult } from 'next'; ...@@ -2,12 +2,14 @@ import type { GetServerSideProps, GetServerSidePropsResult } from 'next';
export type Props = { export type Props = {
cookies: string; cookies: string;
referrer: string;
} }
export const getServerSideProps: GetServerSideProps = async({ req }): Promise<GetServerSidePropsResult<Props>> => { export const getServerSideProps: GetServerSideProps = async({ req }): Promise<GetServerSidePropsResult<Props>> => {
return { return {
props: { props: {
cookies: req.headers.cookie || '', cookies: req.headers.cookie || '',
referrer: req.headers.referer || '',
}, },
}; };
}; };
...@@ -14,7 +14,7 @@ const $arrowBg = cssVar('popper-arrow-bg'); ...@@ -14,7 +14,7 @@ const $arrowBg = cssVar('popper-arrow-bg');
const $arrowShadowColor = cssVar('popper-arrow-shadow-color'); const $arrowShadowColor = cssVar('popper-arrow-shadow-color');
const baseStylePopper = defineStyle({ const baseStylePopper = defineStyle({
zIndex: 10, zIndex: 20,
}); });
const baseStyleContent = defineStyle((props) => { const baseStyleContent = defineStyle((props) => {
......
import { Box, Text, Show, Alert, Skeleton } from '@chakra-ui/react'; import { Box, Text, Show, Hide, Skeleton, Alert } from '@chakra-ui/react';
import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useQuery, useQueryClient } from '@tanstack/react-query';
import React from 'react'; import React from 'react';
...@@ -70,10 +70,10 @@ const BlocksContent = ({ type }: Props) => { ...@@ -70,10 +70,10 @@ const BlocksContent = ({ type }: Props) => {
<Show below="lg" key="skeleton-mobile"> <Show below="lg" key="skeleton-mobile">
<BlocksSkeletonMobile/> <BlocksSkeletonMobile/>
</Show> </Show>
<Show above="lg" key="skeleton-desktop"> <Hide below="lg" key="skeleton-desktop">
<Skeleton h={ 6 } mb={ 8 } w="150px"/> <Skeleton h={ 6 } mb={ 8 } w="150px"/>
<SkeletonTable columns={ [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] }/> <SkeletonTable columns={ [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] }/>
</Show> </Hide>
</> </>
); );
} }
...@@ -83,7 +83,7 @@ const BlocksContent = ({ type }: Props) => { ...@@ -83,7 +83,7 @@ const BlocksContent = ({ type }: Props) => {
} }
if (data.items.length === 0) { if (data.items.length === 0) {
return <Alert>There are no blocks.</Alert>; return <Text as="span">There are no blocks.</Text>;
} }
return ( return (
...@@ -91,7 +91,7 @@ const BlocksContent = ({ type }: Props) => { ...@@ -91,7 +91,7 @@ const BlocksContent = ({ type }: Props) => {
<Text as="span">Total of { data.items[0].height.toLocaleString() } blocks</Text> <Text as="span">Total of { data.items[0].height.toLocaleString() } blocks</Text>
{ socketAlert && <Alert status="warning" mt={ 8 } as="a" href={ window.document.location.href }>{ socketAlert }</Alert> } { socketAlert && <Alert status="warning" mt={ 8 } as="a" href={ window.document.location.href }>{ socketAlert }</Alert> }
<Show below="lg" key="content-mobile"><BlocksList data={ data.items }/></Show> <Show below="lg" key="content-mobile"><BlocksList data={ data.items }/></Show>
<Show above="lg" key="content-desktop"><BlocksTable data={ data.items }/></Show> <Hide below="lg" key="content-desktop"><BlocksTable data={ data.items }/></Hide>
<Box mx={{ base: 0, lg: 6 }} my={{ base: 6, lg: 3 }}> <Box mx={{ base: 0, lg: 6 }} my={{ base: 6, lg: 3 }}>
{ /* eslint-disable-next-line react/jsx-no-bind */ } { /* eslint-disable-next-line react/jsx-no-bind */ }
<Pagination page={ 1 } onNextPageClick={ () => {} } onPrevPageClick={ () => {} } resetPage={ () => {} } hasNextPage/> <Pagination page={ 1 } onNextPageClick={ () => {} } onPrevPageClick={ () => {} } resetPage={ () => {} } hasNextPage/>
......
...@@ -7,6 +7,7 @@ import type { Transaction } from 'types/api/transaction'; ...@@ -7,6 +7,7 @@ import type { Transaction } from 'types/api/transaction';
import type { RoutedTab } from 'ui/shared/RoutedTabs/types'; import type { RoutedTab } from 'ui/shared/RoutedTabs/types';
import eastArrowIcon from 'icons/arrows/east.svg'; import eastArrowIcon from 'icons/arrows/east.svg';
import { useAppContext } from 'lib/appContext';
import useFetch from 'lib/hooks/useFetch'; import useFetch from 'lib/hooks/useFetch';
import isBrowser from 'lib/isBrowser'; import isBrowser from 'lib/isBrowser';
import networkExplorers from 'lib/networks/networkExplorers'; import networkExplorers from 'lib/networks/networkExplorers';
...@@ -32,6 +33,12 @@ const TABS: Array<RoutedTab> = [ ...@@ -32,6 +33,12 @@ const TABS: Array<RoutedTab> = [
const TransactionPageContent = () => { const TransactionPageContent = () => {
const router = useRouter(); const router = useRouter();
const fetch = useFetch(); const fetch = useFetch();
const appProps = useAppContext();
const isInBrowser = isBrowser();
const referrer = isInBrowser ? window.document.referrer : appProps.referrer;
const hasGoBackLink = referrer && referrer.includes('/txs');
const { data } = useQuery<unknown, unknown, Transaction>( const { data } = useQuery<unknown, unknown, Transaction>(
[ 'tx', router.query.id ], [ 'tx', router.query.id ],
...@@ -48,12 +55,10 @@ const TransactionPageContent = () => { ...@@ -48,12 +55,10 @@ const TransactionPageContent = () => {
return <ExternalLink key={ explorer.baseUrl } title={ `Open in ${ explorer.title }` } href={ url.toString() }/>; return <ExternalLink key={ explorer.baseUrl } title={ `Open in ${ explorer.title }` } href={ url.toString() }/>;
}); });
const hasGoBackLink = isBrowser() && window.document.referrer.includes('/txs');
return ( return (
<Page> <Page>
{ hasGoBackLink && ( { hasGoBackLink && (
<Link mb={ 6 } display="inline-flex" href={ window.document.referrer }> <Link mb={ 6 } display="inline-flex" href={ referrer }>
<Icon as={ eastArrowIcon } boxSize={ 6 } mr={ 2 } transform="rotate(180deg)"/> <Icon as={ eastArrowIcon } boxSize={ 6 } mr={ 2 } transform="rotate(180deg)"/>
Transactions Transactions
</Link> </Link>
......
import { Box, Flex, Alert, Show } from '@chakra-ui/react'; import { Box, Flex, Text, Show, Hide } from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
...@@ -105,7 +105,7 @@ const TxInternals = () => { ...@@ -105,7 +105,7 @@ const TxInternals = () => {
return ( return (
<> <>
<Show below="lg"><TxInternalsSkeletonMobile/></Show> <Show below="lg"><TxInternalsSkeletonMobile/></Show>
<Show above="lg"><TxInternalsSkeletonDesktop/></Show> <Hide below="lg"><TxInternalsSkeletonDesktop/></Hide>
</> </>
); );
} }
...@@ -115,7 +115,7 @@ const TxInternals = () => { ...@@ -115,7 +115,7 @@ const TxInternals = () => {
} }
if (data.items.length === 0) { if (data.items.length === 0) {
return <Alert>There are no internal transactions for this transaction.</Alert>; return <Text as="span">There are no internal transactions for this transaction.</Text>;
} }
const content = (() => { const content = (() => {
......
import { Box, Alert } from '@chakra-ui/react'; import { Box, Text } from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
...@@ -46,7 +46,7 @@ const TxLogs = () => { ...@@ -46,7 +46,7 @@ const TxLogs = () => {
} }
if (data.items.length === 0) { if (data.items.length === 0) {
return <Alert>There are no logs for this transaction.</Alert>; return <Text as="span">There are no logs for this transaction.</Text>;
} }
return ( return (
......
import { Alert, Box, Show } from '@chakra-ui/react'; import { Text, Box, Show, Hide } from '@chakra-ui/react';
import React, { useState, useCallback } from 'react'; import React, { useState, useCallback } from 'react';
import type { TTxsFilters } from 'types/api/txsFilters'; import type { TTxsFilters } from 'types/api/txsFilters';
...@@ -71,13 +71,13 @@ const TxsContent = ({ ...@@ -71,13 +71,13 @@ const TxsContent = ({
const txs = data?.items; const txs = data?.items;
if (!isLoading && !txs) { if (!isLoading && !txs) {
return <Alert>There are no transactions.</Alert>; return <Text as="span">There are no transactions.</Text>;
} }
let content = ( let content = (
<> <>
<Show below="lg" ssr={ false }><TxsSkeletonMobile/></Show> <Show below="lg" ssr={ false }><TxsSkeletonMobile/></Show>
<Show above="lg" ssr={ false }><TxsSkeletonDesktop/></Show> <Hide below="lg" ssr={ false }><TxsSkeletonDesktop/></Hide>
</> </>
); );
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
PopoverBody, PopoverBody,
useColorModeValue, useColorModeValue,
Show, Show,
Hide,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
...@@ -113,7 +114,7 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => { ...@@ -113,7 +114,7 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => {
{ addressTo } { addressTo }
</Td> </Td>
</Show> </Show>
<Show below="xl" ssr={ false }> <Hide above="xl" ssr={ false }>
<Td colSpan={ 3 }> <Td colSpan={ 3 }>
<Box> <Box>
{ addressFrom } { addressFrom }
...@@ -128,7 +129,7 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => { ...@@ -128,7 +129,7 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => {
{ addressTo } { addressTo }
</Box> </Box>
</Td> </Td>
</Show> </Hide>
<Td isNumeric> <Td isNumeric>
<CurrencyValue value={ tx.value }/> <CurrencyValue value={ tx.value }/>
</Td> </Td>
......
import { Box, Show } from '@chakra-ui/react'; import { Box, Show, Hide } from '@chakra-ui/react';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import type { TransactionsResponse } from 'types/api/transaction'; import type { TransactionsResponse } from 'types/api/transaction';
...@@ -29,7 +29,7 @@ const TxsWithSort = ({ ...@@ -29,7 +29,7 @@ const TxsWithSort = ({
return ( return (
<> <>
<Show below="lg" ssr={ false }><Box>{ sortedTxs.map(tx => <TxsListItem tx={ tx } key={ tx.hash }/>) }</Box></Show> <Show below="lg" ssr={ false }><Box>{ sortedTxs.map(tx => <TxsListItem tx={ tx } key={ tx.hash }/>) }</Box></Show>
<Show above="lg" ssr={ false }><TxsTable txs={ sortedTxs } sort={ sort } sorting={ sorting }/></Show> <Hide below="lg" ssr={ false }><TxsTable txs={ sortedTxs } sort={ sort } sorting={ sorting }/></Hide>
</> </>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment