Skip to content

[xc-admin] make UI responsive #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ import ClusterSwitch from '../ClusterSwitch'
import CopyPubkey from '../common/CopyPubkey'
import Loadbar from '../loaders/Loadbar'

// check if a string is a pubkey
const isPubkey = (str: string) => {
try {
new PublicKey(str)
return true
} catch (e) {
return false
}
}

const ProposalRow = ({
proposal,
setCurrentProposalPubkey,
Expand Down Expand Up @@ -85,15 +95,15 @@ const ProposalRow = ({

const SignerTag = () => {
return (
<div className="flex items-center justify-center rounded-full bg-[#605D72] py-1 px-2 text-xs">
<div className="flex max-h-[22px] max-w-[74px] items-center justify-center rounded-full bg-[#605D72] py-1 px-2 text-xs">
Signer
</div>
)
}

const WritableTag = () => {
return (
<div className="flex items-center justify-center rounded-full bg-offPurple py-1 px-2 text-xs">
<div className="flex max-h-[22px] max-w-[74px] items-center justify-center rounded-full bg-offPurple py-1 px-2 text-xs">
Writable
</div>
)
Expand Down Expand Up @@ -393,6 +403,9 @@ const Proposal = ({
<CopyPubkey
pubkey={instruction.args[key].toBase58()}
/>
) : typeof instruction.args[key] === 'string' &&
isPubkey(instruction.args[key]) ? (
<CopyPubkey pubkey={instruction.args[key]} />
) : (
<div className="max-w-sm break-all">
{typeof instruction.args[key] === 'string'
Expand Down Expand Up @@ -432,14 +445,18 @@ const Proposal = ({
key={index}
className="flex justify-between border-t border-beige-300 py-3"
>
<div>{key}</div>
<div className="flex space-x-2">
{instruction.accounts.named[key].isSigner ? (
<SignerTag />
) : null}
{instruction.accounts.named[key].isWritable ? (
<WritableTag />
) : null}
<div className="max-w-[80px] break-words sm:max-w-none sm:break-normal">
{key}
</div>
<div className="space-y-2 sm:flex sm:space-x-2">
<div className="flex items-center space-x-2 sm:mt-2 sm:ml-2">
{instruction.accounts.named[key].isSigner ? (
<SignerTag />
) : null}
{instruction.accounts.named[key].isWritable ? (
<WritableTag />
) : null}
</div>
<CopyPubkey
pubkey={instruction.accounts.named[
key
Expand Down Expand Up @@ -596,6 +613,14 @@ const Proposal = ({
key
].toBase58()}
/>
) : typeof instruction.args[key] ===
'string' &&
isPubkey(instruction.args[key]) ? (
<CopyPubkey
pubkey={
parsedInstruction.args[key]
}
/>
) : (
<div className="max-w-sm break-all">
{typeof parsedInstruction.args[
Expand Down Expand Up @@ -652,18 +677,22 @@ const Proposal = ({
key={index}
className="flex justify-between border-t border-beige-300 py-3"
>
<div>{key}</div>
<div className="flex space-x-2">
{parsedInstruction.accounts.named[
key
].isSigner ? (
<SignerTag />
) : null}
{parsedInstruction.accounts.named[
key
].isWritable ? (
<WritableTag />
) : null}
<div className="max-w-[80px] break-words sm:max-w-none sm:break-normal">
{key}
</div>
<div className="space-y-2 sm:flex sm:space-x-2">
<div className="flex items-center space-x-2 sm:mt-2 sm:ml-2">
{parsedInstruction.accounts.named[
key
].isSigner ? (
<SignerTag />
) : null}
{parsedInstruction.accounts.named[
key
].isWritable ? (
<WritableTag />
) : null}
</div>
<div
className="-ml-1 inline-flex cursor-pointer items-center px-1 hover:bg-dark hover:text-white active:bg-darkGray3"
onClick={() => {
Expand Down