Skip to content

Commit c73e6d4

Browse files
committed
Setup ROFL app details page
1 parent 1529ab8 commit c73e6d4

File tree

7 files changed

+74
-2
lines changed

7 files changed

+74
-2
lines changed

.changelog/1848.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable ROFL app details page

src/app/components/ErrorDisplay/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const errorMap: Record<AppErrors, (t: TFunction, error: ErrorPayload) => Formatt
5353
message: t('errors.validateURL'),
5454
}),
5555
[AppErrors.NotFoundTxHash]: t => ({ title: t('errors.notFoundTx'), message: t('errors.validateURL') }),
56+
[AppErrors.NotFoundRoflApp]: t => ({
57+
title: t('errors.notFoundRoflApp'),
58+
message: t('errors.validateURL'),
59+
}),
5660
[AppErrors.NotFoundProposalId]: t => ({
5761
title: t('errors.notFoundProposal'),
5862
message: t('errors.validateURL'),

src/app/pages/RoflAppDetailsPage/hooks.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { SearchScope } from '../../../types/searchScope'
33
export type RoflAppDetailsContext = {
44
scope: SearchScope
55
id: string
6+
method: string
7+
setMethod: (value: string) => void
68
}
79

810
// TOOD: Placeholder file for a hook used within a router. Add when details page is ready

src/app/pages/RoflAppDetailsPage/index.tsx

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { FC } from 'react'
2+
import { useHref, useParams } from 'react-router-dom'
23
import { useTranslation } from 'react-i18next'
34
import { formatDistanceStrict } from 'date-fns'
45
import Box from '@mui/material/Box'
56
import Grid from '@mui/material/Grid'
67
import Typography from '@mui/material/Typography'
78
import { styled } from '@mui/material/styles'
8-
import { RoflApp } from '../../../oasis-nexus/api'
9+
import { Layer, RoflApp, useGetRuntimeRoflAppsId } from '../../../oasis-nexus/api'
910
import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
11+
import { AppErrors } from '../../../types/errors'
12+
import { useRequiredScopeParam } from '../../hooks/useScopeParam'
13+
import { useTypedSearchParam } from '../../hooks/useTypedSearchParam'
1014
import { useScreenSize } from '../../hooks/useScreensize'
15+
import { PageLayout } from '../../components/PageLayout'
16+
import { SubPageCard } from '../../components/SubPageCard'
1117
import { TextSkeleton } from '../../components/Skeleton'
1218
import { StyledDescriptionList } from '../../components/StyledDescriptionList'
1319
import { RoflAppStatusBadge } from '../../components/Rofl/RoflAppStatusBadge'
@@ -19,6 +25,55 @@ import { TeeType } from './TeeType'
1925
import { Endorsement } from './Endorsement'
2026
import { Enclaves } from './Enclaves'
2127
import { Secrets } from './Secrets'
28+
import { RouterTabs } from '../../components/RouterTabs'
29+
import { instancesContainerId } from '../../utils/tabAnchors'
30+
import { RoflAppDetailsContext } from '../RoflAppDetailsPage/hooks'
31+
32+
export const RoflAppDetailsPage: FC = () => {
33+
const { t } = useTranslation()
34+
const scope = useRequiredScopeParam()
35+
const id = useParams().id!
36+
const txLink = useHref('')
37+
const instancesLink = useHref(`instances#${instancesContainerId}`)
38+
const [method, setMethod] = useTypedSearchParam('method', 'any', {
39+
deleteParams: ['page'],
40+
})
41+
const context: RoflAppDetailsContext = { scope, id, method, setMethod }
42+
const { isFetched, isLoading, data } = useGetRuntimeRoflAppsId(scope.network, Layer.sapphire, id)
43+
const roflApp = data?.data
44+
45+
if (!roflApp && isFetched) {
46+
throw AppErrors.NotFoundRoflApp
47+
}
48+
49+
return (
50+
<PageLayout>
51+
<SubPageCard featured title={roflApp?.metadata['net.oasis.rofl.name'] || t('rofl.header')}>
52+
<RoflAppDetailsView detailsPage isLoading={isLoading} app={roflApp} />
53+
</SubPageCard>
54+
<Grid container spacing={4}>
55+
<StyledGrid item xs={12} md={6}>
56+
{/* TODO: uncomment when other PRs are merged */}
57+
{/* <MetaDataCard isFetched={isFetched} metadata={roflApp?.metadata} /> */}
58+
</StyledGrid>
59+
<StyledGrid item xs={12} md={6}>
60+
{/* TODO: uncomment when other PRs are merged */}
61+
{/* <PolicyCard isFetched={isFetched} policy={roflApp?.policy} /> */}
62+
</StyledGrid>
63+
</Grid>
64+
<RouterTabs
65+
tabs={[
66+
{ label: t('common.transactions'), to: txLink },
67+
{
68+
label: t('rofl.instances'),
69+
to: instancesLink,
70+
},
71+
]}
72+
context={context}
73+
/>
74+
</PageLayout>
75+
)
76+
}
2277

2378
export const StyledGrid = styled(Grid)(({ theme }) => ({
2479
[theme.breakpoints.up('sm')]: {

src/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
"invalidTxHash": "Invalid transaction hash",
262262
"notFoundBlockHeight": "Block not found",
263263
"notFoundTx": "Transaction not found",
264+
"notFoundRoflApp": "ROFL app not found",
264265
"notFoundProposal": "Proposal not found",
265266
"pageDoesNotExist": "The page you are looking for does not exist.",
266267
"validateURL": "Please validate provided URL",
@@ -703,7 +704,8 @@
703704
"adminAccount": "Admin account",
704705
"stakedAmount": "Staked amount",
705706
"endorsement": "Endorsement",
706-
"secrets": "Secrets"
707+
"secrets": "Secrets",
708+
"header": "ROFL App"
707709
},
708710
"search": {
709711
"placeholder": "Address, Block, Contract, Transaction hash, Token name, etc.",

src/routes.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
fixedLayer,
2727
RouteUtils,
2828
skipGraph,
29+
roflAppParamLoader,
2930
} from './app/utils/route-utils'
3031
import { RoutingErrorPage } from './app/pages/RoutingErrorPage'
3132
import { ThemeByScope, withDefaultTheme } from './app/components/ThemeByScope'
@@ -64,6 +65,7 @@ import { ConsensusAccountEventsCard } from './app/pages/ConsensusAccountDetailsP
6465
import { useConsensusAccountDetailsProps } from './app/pages/ConsensusAccountDetailsPage/hooks'
6566
import { ConsensusAccountTransactionsCard } from './app/pages/ConsensusAccountDetailsPage/ConsensusAccountTransactionsCard'
6667
import { RoflAppsPage } from './app/pages/RoflAppsPage'
68+
import { RoflAppDetailsPage } from 'app/pages/RoflAppDetailsPage'
6769
import { FC, useEffect } from 'react'
6870
import { AnalyticsConsentProvider } from './app/components/AnalyticsConsent'
6971
import { HighlightingContextProvider } from './app/components/HighlightingContext'
@@ -300,6 +302,11 @@ export const routes: RouteObject[] = [
300302
path: `rofl/app`,
301303
element: <RoflAppsPage />,
302304
},
305+
{
306+
path: `rofl/app/:id`,
307+
element: <RoflAppDetailsPage />,
308+
loader: roflAppParamLoader(),
309+
},
303310
],
304311
},
305312
],

src/types/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export enum AppErrors {
2121
PageDoesNotExist = 'page_does_not_exist',
2222
NotFoundBlockHeight = 'not_found_block_height',
2323
NotFoundTxHash = 'not_found_tx_hash',
24+
NotFoundRoflApp = 'not_found_rofl_app',
2425
NotFoundProposalId = 'not_found_proposal_id',
2526
InvalidUrl = 'invalid_url',
2627
InvalidVote = 'invalid_vote',

0 commit comments

Comments
 (0)