-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1237 from oasisprotocol/mz/paraTimes
Consensus ParaTimes dashboard section
- Loading branch information
Showing
20 changed files
with
415 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Create ParaTimesCard for Consensus dashboard |
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,18 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { StyledBox, statusIcon } from '../StatusIcon' | ||
|
||
type RuntimeStatusIconProps = { | ||
hasStatus: boolean | ||
} | ||
|
||
export const RuntimeStatusIcon: FC<RuntimeStatusIconProps> = ({ hasStatus }) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<StyledBox gap={2} success={hasStatus} error={undefined} withText={true}> | ||
{hasStatus ? t('paratimes.active') : t('paratimes.inactive')} | ||
{hasStatus ? statusIcon.success : statusIcon.failure} | ||
</StyledBox> | ||
) | ||
} |
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
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 { FC } from 'react' | ||
import { Link as RouterLink } from 'react-router-dom' | ||
import { styled } from '@mui/material/styles' | ||
import Link from '@mui/material/Link' | ||
import ArrowForwardIcon from '@mui/icons-material/ArrowForward' | ||
import { COLORS } from 'styles/theme/colors' | ||
|
||
const styles = { | ||
width: '44px', | ||
height: '44px', | ||
borderRadius: '50%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
marginLeft: 'auto', | ||
backgroundColor: COLORS.brandDark, | ||
color: COLORS.white, | ||
boxShadow: '0px 10px 8px rgba(117, 60, 239, 0.1)', | ||
'&:hover, &:focus-visible': { | ||
backgroundColor: COLORS.cosmicCobalt, | ||
}, | ||
} | ||
const StyledAnchor = styled(Link)(() => styles) | ||
|
||
type AnchorCircleProps = { | ||
url: string | ||
} | ||
|
||
export const AnchorCircle: FC<AnchorCircleProps> = ({ url }) => { | ||
return ( | ||
<StyledAnchor href={url} rel="noopener noreferrer" target="_blank"> | ||
<ArrowForwardIcon sx={{ fontSize: 16 }} /> | ||
</StyledAnchor> | ||
) | ||
} | ||
|
||
const StyledRouterLink = styled(RouterLink)(() => styles) | ||
|
||
type RouterLinkCircleProps = { | ||
to: string | ||
} | ||
|
||
export const RouterLinkCircle: FC<RouterLinkCircleProps> = ({ to }) => { | ||
return ( | ||
<StyledRouterLink to={to}> | ||
<ArrowForwardIcon sx={{ fontSize: 16 }} /> | ||
</StyledRouterLink> | ||
) | ||
} |
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,79 @@ | ||
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 { styled } from '@mui/material/styles' | ||
import { Layer, Runtime } from '../../../oasis-nexus/api' | ||
import { isNotOnHiddenLayer } from '../../../types/layers' | ||
import { COLORS } from '../../../styles/theme/colors' | ||
import { CardHeaderWithCounter } from '../../components/CardHeaderWithCounter' | ||
import { 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}`, | ||
}, | ||
}, | ||
})) | ||
|
||
function shouldIncludeLayer(layer: Layer) { | ||
return layer !== Layer.consensus && isNotOnHiddenLayer({ layer }) | ||
} | ||
|
||
type ParaTimesCardProps = { scope: SearchScope } | ||
|
||
export const ParaTimesCard: FC<ParaTimesCardProps> = ({ 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 | ||
|
||
return ( | ||
<Card> | ||
<CardHeader | ||
disableTypography | ||
component="h3" | ||
title={ | ||
<CardHeaderWithCounter | ||
label={t('paratimes.listTitle')} | ||
totalCount={runtimesNumber} | ||
isTotalCountClipped={false} | ||
/> | ||
} | ||
/> | ||
<CardContent> | ||
<StyledBox> | ||
{!!enabledOasisRuntimes.length && | ||
enabledOasisRuntimes.map(runtime => ( | ||
<EnabledRuntimePreview key={runtime} network={scope.network} runtime={runtime} /> | ||
))} | ||
{!!disabledOasisRuntimes.length && | ||
disabledOasisRuntimes.map(runtime => ( | ||
<InactiveRuntimePreview key={runtime} network={scope.network} runtime={runtime} /> | ||
))} | ||
</StyledBox> | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
Oops, something went wrong.