Skip to content

Commit a4ac7bd

Browse files
authored
Merge pull request #1894 from oasisprotocol/mz/roflDashboard
Enable latest ROFL apps list in dashboard
2 parents 6cb0b0e + 70d9cec commit a4ac7bd

File tree

4 files changed

+62
-8
lines changed

4 files changed

+62
-8
lines changed

.changelog/1894.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable latest ROFL apps list in dashboard

src/app/components/Rofl/RoflAppsList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type RoflAppsListProps = {
1313
apps?: RoflApp[]
1414
isLoading: boolean
1515
limit: number
16-
pagination: TablePaginationProps
16+
pagination: TablePaginationProps | false
1717
}
1818

1919
export const RoflAppsList: FC<RoflAppsListProps> = ({ isLoading, limit, pagination, apps }) => {
@@ -42,7 +42,10 @@ export const RoflAppsList: FC<RoflAppsListProps> = ({ isLoading, limit, paginati
4242
key: app.id,
4343
data: [
4444
{
45-
content: index + 1 + (pagination.selectedPage - 1) * pagination.rowsPerPage,
45+
content: pagination
46+
? index + 1 + (pagination.selectedPage - 1) * pagination.rowsPerPage
47+
: // views without pagination enabled
48+
index + 1,
4649
key: 'order',
4750
},
4851
{
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import { Link as RouterLink } from 'react-router-dom'
4+
import Card from '@mui/material/Card'
5+
import CardHeader from '@mui/material/CardHeader'
6+
import CardContent from '@mui/material/CardContent'
7+
import Link from '@mui/material/Link'
8+
import { Layer, useGetRuntimeRoflApps } from '../../../oasis-nexus/api'
9+
import { SearchScope } from '../../../types/searchScope'
10+
import { NUMBER_OF_ITEMS_ON_DASHBOARD as limit } from '../../config'
11+
import { COLORS } from '../../../styles/theme/colors'
12+
import { AppErrors } from '../../../types/errors'
13+
import { RouteUtils } from '../../utils/route-utils'
14+
import { RoflAppsList } from '../../components/Rofl/RoflAppsList'
15+
16+
export const LatestRoflApps: FC<{ scope: SearchScope }> = ({ scope }) => {
17+
const { t } = useTranslation()
18+
const { network, layer } = scope
19+
if (layer !== Layer.sapphire) {
20+
throw AppErrors.UnsupportedLayer
21+
}
22+
const roflAppsQuery = useGetRuntimeRoflApps(network, layer, { limit })
23+
const { isLoading, data } = roflAppsQuery
24+
const roflApps = data?.data.rofl_apps
25+
26+
if (!roflApps?.length) {
27+
return null
28+
}
29+
30+
return (
31+
<Card>
32+
<CardHeader
33+
disableTypography
34+
component="h3"
35+
title={t('rofl.listTitle')}
36+
action={
37+
<Link
38+
component={RouterLink}
39+
to={RouteUtils.getRoflAppsRoute(scope.network)}
40+
sx={{ color: COLORS.brandDark }}
41+
>
42+
{t('common.viewAll')}
43+
</Link>
44+
}
45+
/>
46+
<CardContent>
47+
<RoflAppsList apps={roflApps} isLoading={isLoading} limit={limit} pagination={false} />
48+
</CardContent>
49+
</Card>
50+
)
51+
}

src/app/pages/ParatimeDashboardPage/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ParaTimeSnapshot } from './ParaTimeSnapshot'
1414
import { TopTokens } from './TopTokens'
1515
import { useRequiredScopeParam } from '../../hooks/useScopeParam'
1616
import { useRuntimeTxMethodParam } from '../../hooks/useCommonParams'
17+
import { LatestRoflApps } from './LatestRoflApps'
1718

1819
export const ParatimeDashboardPage: FC = () => {
1920
const { isMobile } = useScreenSize()
@@ -33,13 +34,11 @@ export const ParatimeDashboardPage: FC = () => {
3334
<Grid item xs={12} md={6}>
3435
<LatestRuntimeBlocks scope={scope} />
3536
</Grid>
36-
{isMobile && (
37-
<Grid item xs={12}>
38-
<TopTokens scope={scope} />
39-
</Grid>
40-
)}
37+
<Grid item xs={12}>
38+
<TopTokens scope={scope} />
39+
{scope.layer === 'sapphire' && <LatestRoflApps scope={scope} />}
40+
</Grid>
4141
</Grid>
42-
{!isMobile && <TopTokens scope={scope} />}
4342
{!isLocal && (
4443
<>
4544
<Grid container spacing={4}>

0 commit comments

Comments
 (0)