Skip to content

Commit b9c84bb

Browse files
committed
use table and add copy text function
1 parent c1b8103 commit b9c84bb

File tree

3 files changed

+65
-21
lines changed

3 files changed

+65
-21
lines changed

governance/xc-admin/packages/xc-admin-frontend/components/tabs/MinPublishers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { usePythContext } from '../../contexts/PythContext'
22
import ClusterSwitch from '../ClusterSwitch'
33
import Loadbar from '../loaders/Loadbar'
44

5-
function MinPublishers() {
5+
const MinPublishers = () => {
66
const { rawConfig, dataIsLoading } = usePythContext()
77

88
return (

governance/xc-admin/packages/xc-admin-frontend/components/tabs/UpdatePermissions.tsx

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
11
import { PublicKey } from '@solana/web3.js'
2+
import copy from 'copy-to-clipboard'
3+
import React from 'react'
24
import { usePythContext } from '../../contexts/PythContext'
5+
import CopyIcon from '../../images/icons/copy.inline.svg'
36
import ClusterSwitch from '../ClusterSwitch'
47
import Loadbar from '../loaders/Loadbar'
58

6-
function UpdatePermissions() {
9+
interface UpdatePermissionsProps {
10+
account: string
11+
pubkey?: PublicKey
12+
}
13+
14+
const UpdatePermissionsRow: React.FunctionComponent<UpdatePermissionsProps> = ({
15+
account,
16+
pubkey = new PublicKey(0),
17+
}) => {
18+
return (
19+
<tr key={account} className="border-t border-beige-300">
20+
<td className="py-3 pl-4 pr-2 lg:pl-14">{account}</td>
21+
<td className="py-3 pl-1 lg:pl-14">
22+
<div
23+
className="-ml-1 inline-flex cursor-pointer items-center px-1 hover:bg-dark hover:text-white active:bg-darkGray3"
24+
onClick={() => {
25+
copy(pubkey.toBase58())
26+
}}
27+
>
28+
<span className="mr-2 hidden lg:block">{pubkey.toBase58()}</span>
29+
<span className="mr-2 lg:hidden">
30+
{pubkey.toBase58().slice(0, 6) +
31+
'...' +
32+
pubkey.toBase58().slice(-6)}
33+
</span>{' '}
34+
<CopyIcon className="shrink-0" />
35+
</div>
36+
</td>
37+
</tr>
38+
)
39+
}
40+
41+
const UpdatePermissions = () => {
742
const { rawConfig, dataIsLoading } = usePythContext()
843

944
return (
@@ -23,25 +58,33 @@ function UpdatePermissions() {
2358
<Loadbar theme="light" />
2459
</div>
2560
) : (
26-
<div className="mt-3">
27-
<p className="h5 mb-8">
28-
Master Authority:{' '}
29-
{rawConfig.permissionAccount
30-
? rawConfig.permissionAccount.masterAuthority.toBase58()
31-
: new PublicKey(0).toBase58()}
32-
</p>
33-
<p className="h5 mb-8">
34-
Data Curation Authority:{' '}
35-
{rawConfig.permissionAccount
36-
? rawConfig.permissionAccount.dataCurationAuthority.toBase58()
37-
: new PublicKey(0).toBase58()}
38-
</p>
39-
<p className="h5 mb-8">
40-
Security Authority:{' '}
41-
{rawConfig.permissionAccount
42-
? rawConfig.permissionAccount.securityAuthority.toBase58()
43-
: new PublicKey(0).toBase58()}
44-
</p>
61+
<div className="table-responsive mb-10">
62+
<table className="w-full bg-darkGray text-left">
63+
<thead>
64+
<tr>
65+
<th className="base16 pt-8 pb-6 pl-4 pr-2 font-semibold opacity-60 lg:pl-14">
66+
Account
67+
</th>
68+
<th className="base16 pt-8 pb-6 pl-1 pr-2 font-semibold opacity-60 lg:pl-14">
69+
Public Key
70+
</th>
71+
</tr>
72+
</thead>
73+
<tbody>
74+
<UpdatePermissionsRow
75+
account="Master Authority"
76+
pubkey={rawConfig.permissionAccount?.masterAuthority}
77+
/>
78+
<UpdatePermissionsRow
79+
account="Data Curation Authority"
80+
pubkey={rawConfig.permissionAccount?.dataCurationAuthority}
81+
/>
82+
<UpdatePermissionsRow
83+
account="Security Authority"
84+
pubkey={rawConfig.permissionAccount?.securityAuthority}
85+
/>
86+
</tbody>
87+
</table>
4588
</div>
4689
)}
4790
</div>

governance/xc-admin/packages/xc-admin-frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@types/node": "18.11.18",
2020
"@types/react": "18.0.26",
2121
"@types/react-dom": "18.0.10",
22+
"copy-to-clipboard": "^3.3.3",
2223
"gsap": "^3.11.4",
2324
"next": "12.2.5",
2425
"next-seo": "^5.15.0",

0 commit comments

Comments
 (0)