diff --git a/.changelog/1651.bugfix.md b/.changelog/1651.bugfix.md new file mode 100644 index 000000000..41dbea673 --- /dev/null +++ b/.changelog/1651.bugfix.md @@ -0,0 +1 @@ +Increase visibility of Sapphire in ParaTimes section diff --git a/src/app/pages/ConsensusDashboardPage/ParaTimesCard.tsx b/src/app/pages/ConsensusDashboardPage/ParaTimesCard.tsx index e16fa1381..9fb6cfb2e 100644 --- a/src/app/pages/ConsensusDashboardPage/ParaTimesCard.tsx +++ b/src/app/pages/ConsensusDashboardPage/ParaTimesCard.tsx @@ -1,53 +1,36 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' -import Box from '@mui/material/Box' import Card from '@mui/material/Card' import CardHeader from '@mui/material/CardHeader' import CardContent from '@mui/material/CardContent' +import Grid from '@mui/material/Unstable_Grid2' import { styled } from '@mui/material/styles' import { Layer, Runtime } from '../../../oasis-nexus/api' -import { COLORS } from '../../../styles/theme/colors' import { CardHeaderWithCounter } from '../../components/CardHeaderWithCounter' import { isNotOnHiddenLayer, RouteUtils } from '../../utils/route-utils' import { SearchScope } from '../../../types/searchScope' -import { EnabledRuntimePreview, InactiveRuntimePreview } from './RuntimePreview' - -const StyledBox = styled(Box)(({ theme }) => ({ - display: 'flex', - [theme.breakpoints.up('md')]: { - paddingRight: theme.spacing(4), - paddingLeft: theme.spacing(4), - }, - [theme.breakpoints.down('md')]: { - flexDirection: 'column', - }, - '> div:not(:last-child)': { - [theme.breakpoints.down('md')]: { - paddingBottom: theme.spacing(4), - borderBottom: `1px solid ${COLORS.grayMediumLight}`, - }, - [theme.breakpoints.up('md')]: { - paddingRight: theme.spacing(5), - marginRight: theme.spacing(5), - borderRight: `1px solid ${COLORS.grayMediumLight}`, - }, - }, -})) +import { EnabledRuntimePreview, DisabledRuntimePreview } from './RuntimePreview' function shouldIncludeLayer(layer: Layer) { return layer !== Layer.consensus && isNotOnHiddenLayer({ layer }) } +const StyledInnerGrid = styled(Grid)(({ theme }) => ({ + [theme.breakpoints.down('md')]: { + paddingTop: 0, + }, +})) + type ParaTimesCardProps = { scope: SearchScope } export const ParaTimesCard: FC = ({ scope }) => { const { t } = useTranslation() const { network } = scope const { enabled, disabled } = RouteUtils.getAllLayersForNetwork(network) - const enabledOasisRuntimes = enabled.filter(shouldIncludeLayer) as Runtime[] - const disabledOasisRuntimes = disabled.filter(shouldIncludeLayer) as Runtime[] - const runtimesNumber = enabledOasisRuntimes.length + disabledOasisRuntimes.length - + const enabledRuntimes = enabled.filter(shouldIncludeLayer) as Runtime[] + const disabledRuntimes = disabled.filter(shouldIncludeLayer) as Runtime[] + const runtimesNumber = enabledRuntimes.length + disabledRuntimes.length + const [firstEnabledRuntime, ...restEnabledRuntimes] = enabledRuntimes return ( = ({ scope }) => { } /> - - {!!enabledOasisRuntimes.length && - enabledOasisRuntimes.map(runtime => ( - - ))} - {!!disabledOasisRuntimes.length && - disabledOasisRuntimes.map(runtime => ( - - ))} - + + + + + + + {!!restEnabledRuntimes.length && + restEnabledRuntimes.map(runtime => ( + + ))} + + + {!!disabledRuntimes.length && + disabledRuntimes.map(runtime => )} + + + ) diff --git a/src/app/pages/ConsensusDashboardPage/RuntimePreview.tsx b/src/app/pages/ConsensusDashboardPage/RuntimePreview.tsx index 4d918fcef..df6660a17 100644 --- a/src/app/pages/ConsensusDashboardPage/RuntimePreview.tsx +++ b/src/app/pages/ConsensusDashboardPage/RuntimePreview.tsx @@ -1,4 +1,4 @@ -import { FC, useState } from 'react' +import { FC, ReactNode, useState } from 'react' import { Link as RouterLink } from 'react-router-dom' import { useTranslation } from 'react-i18next' import Box from '@mui/material/Box' @@ -42,6 +42,7 @@ const StyledBox = styled(Box)(() => ({ borderRadius: '12px', height: '180px', display: 'flex', + flex: 1, justifyContent: 'center', alignItems: 'center', boxShadow: '0px 34px 24px -9px #324DAB1F', @@ -58,12 +59,39 @@ const StyledTypography = styled(Typography)(() => ({ alignItems: 'center', })) +const StyledDisabledRuntime = styled(Box)(({ theme }) => ({ + display: 'flex', + gap: 3, + paddingTop: theme.spacing(3), + flexDirection: 'row', + alignItems: 'center', + [theme.breakpoints.between('md', 'xl')]: { + flexDirection: 'column', + alignItems: 'flex-start', + }, +})) + +const StyledEnabledRuntime = styled(Box)(({ theme }) => ({ + height: '100%', + paddingTop: theme.spacing(3), + paddingBottom: theme.spacing(3), + [theme.breakpoints.down('md')]: { + paddingBottom: theme.spacing(5), + borderBottom: `1px solid ${COLORS.grayMediumLight}`, + }, + [theme.breakpoints.up('md')]: { + paddingRight: theme.spacing(5), + borderRight: `1px solid ${COLORS.grayMediumLight}`, + }, +})) + type RuntimeProps = { + prominentItem?: boolean network: Network runtime: Runtime } -export const EnabledRuntimePreview: FC = ({ network, runtime }) => { +export const EnabledRuntimePreview: FC = ({ prominentItem, network, runtime }) => { const query = useGetRuntimeStatus(network, runtime) const { outOfDate } = useRuntimeFreshness({ network, @@ -73,6 +101,7 @@ export const EnabledRuntimePreview: FC = ({ network, runtime }) => return ( = ({ network, runtime }) => ) } -export const InactiveRuntimePreview: FC = ({ network, runtime }) => { - return +type DisabledRuntimePreviewProps = { + runtime: Runtime +} + +export const DisabledRuntimePreview: FC = ({ runtime }) => { + const { t } = useTranslation() + const layerLabels = getLayerLabels(t) + const runtimeLabel = layerLabels[runtime] + + return ( + + {runtimeLabel} + + + + + ) } type RuntimePreviewProps = RuntimeProps & { @@ -98,7 +142,7 @@ type RuntimePreviewProps = RuntimeProps & { type Panels = 'transactions' | 'accounts' -const RuntimePreview: FC = ({ network, runtime, status }) => { +const RuntimePreview: FC = ({ prominentItem, network, runtime, status }) => { const { t } = useTranslation() const [panel, setPanel] = useState('transactions') const layerLabels = getLayerLabels(t) @@ -106,7 +150,7 @@ const RuntimePreview: FC = ({ network, runtime, status }) = const dashboardLink = RouteUtils.getDashboardRoute({ network, layer: runtime }) const runtimeStatus = status ? (status.outOfDate ? 'outdated' : 'stable') : 'inactive' return ( - + {status ? ( @@ -145,57 +189,60 @@ const RuntimePreview: FC = ({ network, runtime, status }) =
{t('paratimes.nodes')}
{status?.activeNodes ? t('paratimes.activeNodes', { nodes: status?.activeNodes }) : '-'}
- - - {status && ( - - {panel === 'transactions' && ( - - )} - {panel === 'accounts' && ( - - )} - - )} - {!status && ( - <> - - {t('paratimes.noData')} - + + + {panel === 'transactions' && ( + )} - - - - {status && ( - <> - - + {prominentItem && ( + + - + )} -
+ {!prominentItem && ( + + {status && ( + <> + + + + )} + + )} +
) } @@ -219,3 +266,30 @@ const PanelButton: FC = ({ activePanel, ariaLabel, panel, setP ) } + +type ChartsContainerProps = { + children: ReactNode + status?: { + activeNodes: number | undefined + latestBlock: number | undefined + outOfDate: boolean | undefined + } +} + +const ChartsContainer: FC = ({ children, status }) => { + const { t } = useTranslation() + + return ( + + + {status && {children}} + {!status && ( + <> + + {t('paratimes.noData')} + + )} + + + ) +} diff --git a/src/app/utils/route-utils.ts b/src/app/utils/route-utils.ts index 90c26523b..24a9cbd15 100644 --- a/src/app/utils/route-utils.ts +++ b/src/app/utils/route-utils.ts @@ -9,6 +9,7 @@ import { isStableDeploy, specialScopePaths } from '../../config' import { getSearchTermFromRequest } from '../components/Search/search-utils' import type { HasLayer } from '../../types/layers' import { toChecksumAddress } from '@ethereumjs/util' +import { orderByLayer } from '../../types/layers' export const fixedNetwork = process.env.REACT_APP_FIXED_NETWORK as Network | undefined export const fixedLayer = process.env.REACT_APP_FIXED_LAYER as Layer | undefined @@ -185,14 +186,15 @@ export abstract class RouteUtils { static getAllLayersForNetwork(network: Network): { enabled: Layer[]; disabled: Layer[] } { const enabled: Layer[] = [] const disabled: Layer[] = [] - - Object.values(Layer).forEach(layer => { - if ((!fixedLayer || layer === fixedLayer) && RouteUtils.ENABLED_LAYERS_FOR_NETWORK[network][layer]) { - enabled.push(layer) - } else { - disabled.push(layer) - } - }) + Object.values(Layer) + .sort(orderByLayer) + .forEach(layer => { + if ((!fixedLayer || layer === fixedLayer) && RouteUtils.ENABLED_LAYERS_FOR_NETWORK[network][layer]) { + enabled.push(layer) + } else { + disabled.push(layer) + } + }) return { enabled, diff --git a/src/types/layers.ts b/src/types/layers.ts index 63df2956d..87b18ea09 100644 --- a/src/types/layers.ts +++ b/src/types/layers.ts @@ -20,8 +20,13 @@ const layerOrder: Record = { [Layer.pontusxtest]: 6, } -export const orderByLayer = (itemA: HasLayer, itemB: HasLayer): number => - layerOrder[itemA.layer] - layerOrder[itemB.layer] +export function orderByLayer(itemA: Layer, itemB: Layer): number +export function orderByLayer(itemA: HasLayer, itemB: HasLayer): number +export function orderByLayer(itemA: Layer | HasLayer, itemB: Layer | HasLayer): number { + const layerA = typeof itemA === 'string' ? itemA : itemA.layer + const layerB = typeof itemB === 'string' ? itemB : itemB.layer + return layerOrder[layerA] - layerOrder[layerB] +} const layersWithEncryptedTransactions: Layer[] = [Layer.sapphire, Layer.cipher]