-
Notifications
You must be signed in to change notification settings - Fork 218
feat: improved transactions history errors #2556
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
Draft
brtkx
wants to merge
10
commits into
master
Choose a base branch
from
better-history-error-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5374ad
better history errors
brtkx 5d5d13b
format
brtkx 2c5db49
key
brtkx 83dbe4b
get help btn
brtkx be3724e
nit
brtkx ba5f2a5
fix
brtkx fffc2ef
fix
brtkx bcabf19
logs
brtkx 0cc1346
fix try
brtkx 536e3d5
log
brtkx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
134 changes: 134 additions & 0 deletions
134
packages/arb-token-bridge-ui/src/components/TransactionHistory/ChainErrorsInfo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { | ||
Disclosure, | ||
DisclosureButton, | ||
DisclosurePanel | ||
} from '@headlessui/react' | ||
import SyntaxHighlighter from 'react-syntax-highlighter' | ||
import { stackoverflowDark } from 'react-syntax-highlighter/dist/esm/styles/hljs' | ||
import { | ||
XCircleIcon, | ||
ChevronRightIcon, | ||
ArrowsRightLeftIcon, | ||
DocumentIcon, | ||
EyeIcon, | ||
ChatBubbleLeftRightIcon | ||
} from '@heroicons/react/24/outline' | ||
import { ChainError, ChainPair } from '../../hooks/useTransactionHistory' | ||
import { Tooltip } from '../common/Tooltip' | ||
import { getNetworkName } from '../../util/networks' | ||
import { NetworkImage } from '../common/NetworkImage' | ||
import { useCopyToClipboard } from '@uidotdev/usehooks' | ||
import { successToast } from '../common/atoms/Toast' | ||
import { ExternalLink } from '../common/ExternalLink' | ||
import { GET_HELP_LINK } from '../../constants' | ||
|
||
function Networks({ networks }: { networks: ChainPair }) { | ||
return ( | ||
<div className="flex items-center space-x-2"> | ||
<div className="flex items-center space-x-1"> | ||
<NetworkImage chainId={networks.parentChainId} className="h-5 w-5" /> | ||
<span>{getNetworkName(networks.parentChainId)}</span> | ||
</div> | ||
<ArrowsRightLeftIcon width={20} /> | ||
<div className="flex items-center space-x-1"> | ||
<NetworkImage chainId={networks.childChainId} className="h-5 w-5" /> | ||
<span>{getNetworkName(networks.childChainId)}</span> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
function ErrorTooltip({ error }: { error: string }) { | ||
return ( | ||
<Tooltip | ||
tippyProps={{ className: 'break-all', trigger: 'click' }} | ||
content={ | ||
<SyntaxHighlighter | ||
className="text-xs" | ||
language="json" | ||
style={stackoverflowDark} | ||
wrapLongLines | ||
> | ||
{error} | ||
</SyntaxHighlighter> | ||
} | ||
> | ||
<div className="arb-hover flex cursor-pointer space-x-1"> | ||
<EyeIcon width={20} /> | ||
<span>View details</span> | ||
</div> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
function CopyErrorToClipboard({ error }: { error: string }) { | ||
const [, copyToClipboard] = useCopyToClipboard() | ||
|
||
const handleCopy = () => { | ||
copyToClipboard(error) | ||
successToast('Error message copied to clipboard.') | ||
} | ||
|
||
return ( | ||
<button className="arb-hover flex space-x-1" onClick={handleCopy}> | ||
<DocumentIcon width={20} /> | ||
<span>Copy error</span> | ||
</button> | ||
) | ||
} | ||
|
||
function GetHelp() { | ||
return ( | ||
<ExternalLink | ||
className="arb-hover flex items-center space-x-1" | ||
href={GET_HELP_LINK} | ||
> | ||
<ChatBubbleLeftRightIcon width={20} /> | ||
<span>Get help</span> | ||
</ExternalLink> | ||
) | ||
} | ||
|
||
export function ChainErrorsInfo({ | ||
chainErrors | ||
}: { | ||
chainErrors: ChainError[] | ||
}) { | ||
if (chainErrors.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Disclosure | ||
as="div" | ||
className="text-red-dark my-3 flex w-full flex-col justify-start gap-1 overflow-scroll rounded border border-red-400 bg-red-900 px-3 py-2 text-sm text-white" | ||
> | ||
<DisclosureButton className="flex items-center text-left"> | ||
<div className="flex items-start gap-1"> | ||
<XCircleIcon width={20} /> | ||
<p> | ||
Errors occurred while fetching data for some of the chains and they | ||
may not show in the history. Click to expand the view and see more | ||
info. | ||
</p> | ||
</div> | ||
<ChevronRightIcon className="ml-auto h-3 w-3 shrink-0 ui-open:rotate-90 ui-open:transform" /> | ||
</DisclosureButton> | ||
<DisclosurePanel className="flex flex-col gap-2 pl-4"> | ||
<ul className="mt-1"> | ||
{chainErrors.map(chainError => ( | ||
<li | ||
key={`${chainError.chainPair.parentChainId}-${chainError.chainPair.childChainId}`} | ||
className="grid grid-cols-[1.5fr_1fr_1fr_auto] items-center border-t border-white/50 py-2" | ||
> | ||
<Networks networks={chainError.chainPair} /> | ||
<ErrorTooltip error={chainError.error} /> | ||
<CopyErrorToClipboard error={chainError.error} /> | ||
<GetHelp /> | ||
</li> | ||
))} | ||
</ul> | ||
</DisclosurePanel> | ||
</Disclosure> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated