Skip to content

Commit 28cce89

Browse files
authored
Merge pull request #1861 from oasisprotocol/mz/roflTweaks
ROFL apps minor UI tweaks
2 parents dba2d9e + c636272 commit 28cce89

File tree

7 files changed

+72
-27
lines changed

7 files changed

+72
-27
lines changed

.changelog/1861.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ROFL apps minor UI tweaks
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { COLORS } from 'styles/theme/colors'
21
import { styled } from '@mui/material/styles'
32
import Box from '@mui/material/Box'
43

54
export const VerticalList = styled(Box)(({ theme }) => ({
65
display: 'flex',
76
flexDirection: 'column',
87
gap: `0 ${theme.spacing(2)}`,
9-
backgroundColor: COLORS.brandDark,
8+
backgroundColor: theme.palette.background.default,
109
}))

src/app/pages/RoflAppDetailsPage/GridRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export const GridRow: FC<GridRowProps> = ({ label, children, tooltip }) => {
2626

2727
return (
2828
<>
29-
<StyledGrid item xs={12} md={5}>
29+
<StyledGrid item xs={4} md={5}>
3030
{label}:
3131
{tooltip && (
3232
<Tooltip title={tooltip} placement="top">
3333
<InfoIcon htmlColor={COLORS.brandDark} fontSize="small" />
3434
</Tooltip>
3535
)}
3636
</StyledGrid>
37-
<StyledGrid item xs={12} md={7}>
37+
<StyledGrid item xs={8} md={7}>
3838
{children ? <strong>{children}</strong> : t('common.missing')}
3939
</StyledGrid>
4040
</>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import { formatDistanceStrict } from 'date-fns'
4+
import Box from '@mui/material/Box'
5+
import { styled } from '@mui/material/styles'
6+
import { RuntimeTransaction } from '../../../oasis-nexus/api'
7+
import { SearchScope } from '../../../types/searchScope'
8+
import { TransactionLink } from '../../components/Transactions/TransactionLink'
9+
import { useScreenSize } from '../../hooks/useScreensize'
10+
11+
const StyledBox = styled(Box)(() => ({
12+
display: 'flex',
13+
alignItems: 'center',
14+
gap: 5,
15+
}))
16+
17+
type LastActivityProps = {
18+
transaction: RuntimeTransaction | undefined
19+
scope: SearchScope
20+
}
21+
22+
export const LastActivity: FC<LastActivityProps> = ({ scope, transaction }) => {
23+
const { t } = useTranslation()
24+
const { isTablet } = useScreenSize()
25+
26+
return (
27+
<>
28+
{transaction ? (
29+
<StyledBox>
30+
<TransactionLink
31+
scope={scope}
32+
hash={transaction.eth_hash ?? transaction.hash}
33+
alwaysTrim={isTablet}
34+
/>
35+
<span>
36+
(
37+
{formatDistanceStrict(transaction.timestamp, new Date(), {
38+
addSuffix: true,
39+
})}
40+
)
41+
</span>
42+
</StyledBox>
43+
) : (
44+
t('common.missing')
45+
)}
46+
</>
47+
)
48+
}

src/app/pages/RoflAppDetailsPage/index.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { FC } from 'react'
22
import { useHref, useParams } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4-
import { formatDistanceStrict } from 'date-fns'
5-
import Box from '@mui/material/Box'
64
import Grid from '@mui/material/Grid'
75
import Skeleton from '@mui/material/Skeleton'
86
import Typography from '@mui/material/Typography'
@@ -21,16 +19,17 @@ import { RoflAppStatusBadge } from '../../components/Rofl/RoflAppStatusBadge'
2119
import { RoflAppLink } from '../../components/Rofl/RoflAppLink'
2220
import { AccountLink } from '../../components/Account/AccountLink'
2321
import { CopyToClipboard } from '../../components/CopyToClipboard'
24-
import { TransactionLink } from '../../components/Transactions/TransactionLink'
2522
import { TeeType } from './TeeType'
2623
import { Endorsement } from './Endorsement'
2724
import { Enclaves } from './Enclaves'
2825
import { Secrets } from './Secrets'
2926
import { RouterTabs } from '../../components/RouterTabs'
27+
import { TableCellAge } from '../../components/TableCellAge'
3028
import { instancesContainerId } from '../../utils/tabAnchors'
3129
import { RoflAppDetailsContext } from '../RoflAppDetailsPage/hooks'
3230
import { MetaDataCard } from './MetaDataCard'
3331
import { PolicyCard } from './PolicyCard'
32+
import { LastActivity } from './LastActivity'
3433

3534
export const RoflAppDetailsPage: FC = () => {
3635
const { t } = useTranslation()
@@ -140,8 +139,12 @@ export const RoflAppDetailsView: FC<{
140139

141140
<dt>{t('rofl.adminAccount')}</dt>
142141
<dd>
143-
<AccountLink scope={{ network: app.network, layer: app.layer }} address={app.admin} />
144-
<CopyToClipboard value={app.admin} />
142+
<AccountLink
143+
scope={{ network: app.network, layer: app.layer }}
144+
address={app.admin_eth ?? app.admin}
145+
alwaysTrimOnTablet
146+
/>
147+
<CopyToClipboard value={app.admin_eth ?? app.admin} />
145148
</dd>
146149

147150
<dt>{t('rofl.stakedAmount')}</dt>
@@ -167,6 +170,8 @@ export const RoflAppDetailsView: FC<{
167170
<dd>
168171
<RoflAppLink id={app.id} network={app.network} withSourceIndicator={false} />
169172
</dd>
173+
<dt>{t('rofl.instances')}</dt>
174+
<dd>{app.num_active_instances.toLocaleString()}</dd>
170175
<dt>{t('rofl.created')}</dt>
171176
<dd>
172177
{t('common.formattedDateTime', {
@@ -181,32 +186,21 @@ export const RoflAppDetailsView: FC<{
181186
})}
182187
</dd>
183188
<dt>{t('rofl.lastActivity')}</dt>
184-
<dd>{t('common.missing')}</dd>
189+
<dd>{<TableCellAge sinceTimestamp={app.last_activity} />}</dd>
185190
</>
186191
)}
187192

188193
{detailsPage && (
189194
<>
190195
<dt>{t('rofl.lastActivity')}</dt>
191196
<dd>
192-
{app.last_activity_tx ? (
193-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
194-
<TransactionLink
195-
scope={{ network: app.network, layer: app.layer }}
196-
hash={app.last_activity_tx.eth_hash || app.last_activity_tx.hash}
197-
/>
198-
(
199-
{formatDistanceStrict(app.last_activity_tx.timestamp, new Date(), {
200-
addSuffix: true,
201-
})}
202-
)
203-
</Box>
204-
) : (
205-
t('common.missing')
206-
)}
197+
<LastActivity
198+
scope={{ network: app.network, layer: app.layer }}
199+
transaction={app.last_activity_tx}
200+
/>
207201
</dd>
208202

209-
<dt>{t('rofl.instances')}</dt>
203+
<dt>{t('rofl.activeInstances')}</dt>
210204
<dd>{app.num_active_instances.toLocaleString()}</dd>
211205

212206
<dt>{t('rofl.endorsement')}</dt>

src/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@
658658
},
659659
"rofl": {
660660
"active": "Active",
661+
"activeInstances": "Active instances",
661662
"inactive": "Inactive",
662663
"rakAbbreviation": "RAK",
663664
"rak": "Runtime Attestation Key",

src/oasis-nexus/generated/api.ts

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)