Skip to content

Commit acd2782

Browse files
authored
Merge pull request #1841 from oasisprotocol/mz/roflAppDetails
ROFL app details card
2 parents 66089c5 + 3dea543 commit acd2782

File tree

16 files changed

+338
-33
lines changed

16 files changed

+338
-33
lines changed

.changelog/1841.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Create ROFL app details card content
File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import Typography from '@mui/material/Typography'
4+
import { RoflAppPolicy } from '../../../oasis-nexus/api'
5+
import { CopyToClipboard } from 'app/components/CopyToClipboard'
6+
7+
type EnclavesProps = {
8+
policy: RoflAppPolicy
9+
}
10+
11+
export const Enclaves: FC<EnclavesProps> = ({ policy }) => {
12+
const { t } = useTranslation()
13+
14+
if (!policy.enclaves || policy.enclaves.length === 0) {
15+
return <>{t('common.missing')}</>
16+
}
17+
18+
return (
19+
<table>
20+
{policy.enclaves.map((enclave: string) => (
21+
<tr key={enclave}>
22+
<td>
23+
<Typography variant="mono" component="span">
24+
{enclave}
25+
</Typography>
26+
</td>
27+
<td>
28+
<CopyToClipboard value={enclave} />
29+
</td>
30+
</tr>
31+
))}
32+
</table>
33+
)
34+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import Box from '@mui/material/Box'
4+
import Typography from '@mui/material/Typography'
5+
import { RoflAppPolicy } from '../../../oasis-nexus/api'
6+
7+
type EndorsementProps = {
8+
policy: RoflAppPolicy
9+
}
10+
11+
export const Endorsement: FC<EndorsementProps> = ({ policy }) => {
12+
const { t } = useTranslation()
13+
14+
if (!policy.endorsements || policy.endorsements.length === 0) {
15+
return <>{t('common.missing')}</>
16+
}
17+
18+
// Nexus is not parsing ROFL app policy, but we can expect object to be similar to this:
19+
// https://github.com/oasisprotocol/oasis-sdk/blob/41480106d585debd33391cb0dfcad32d2f3cdc9d/runtime-sdk/src/modules/rofl/policy.rs#L27
20+
21+
const getEndorsementLabel = (key: string): string => {
22+
const labelMap: Record<string, string> = {
23+
any: t('rofl.any'),
24+
role_compute: t('rofl.roleCompute'),
25+
role_observer: t('rofl.roleObserver'),
26+
entity: t('rofl.entity'),
27+
node: t('rofl.node'),
28+
}
29+
return labelMap[key] || key
30+
}
31+
32+
return (
33+
<>
34+
{policy.endorsements.map((endorsement: { [key: string]: any }, index: number) => {
35+
const key = Object.keys(endorsement)[0]
36+
const value = endorsement[key]
37+
38+
return (
39+
<Box key={index}>
40+
{getEndorsementLabel(key)}
41+
{(key === 'entity' || key === 'node') && value ? (
42+
<>
43+
: <Typography variant="mono">{value}</Typography>
44+
</>
45+
) : (
46+
''
47+
)}
48+
</Box>
49+
)
50+
})}
51+
</>
52+
)
53+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import Typography from '@mui/material/Typography'
4+
import { RoflAppSecrets } from '../../../oasis-nexus/api'
5+
6+
type SecretsProps = {
7+
secrets: RoflAppSecrets
8+
}
9+
10+
export const Secrets: FC<SecretsProps> = ({ secrets }) => {
11+
const { t } = useTranslation()
12+
13+
if (!secrets || secrets.length === 0) {
14+
return <>{t('common.missing')}</>
15+
}
16+
17+
return (
18+
<table>
19+
{Object.keys(secrets).map(key => (
20+
<tr key={key}>
21+
<td>
22+
<Typography
23+
variant="mono"
24+
component="span"
25+
sx={{
26+
wordWrap: 'break-word',
27+
pr: 5,
28+
}}
29+
>
30+
{key}:
31+
</Typography>
32+
</td>
33+
<td>
34+
<Typography variant="mono">{secrets[key]}</Typography>
35+
</td>
36+
</tr>
37+
))}
38+
</table>
39+
)
40+
}

0 commit comments

Comments
 (0)