Skip to content

Commit a6dc200

Browse files
feat: add link to check.ipfs.network on block fetch failure (#469)
* feat: add link to check.ipfs.network on block fetch failure * revert: prior changes to locales * feat: improve self service with troubleshooting tips and improved error messages in explore component * fix: center IpldExploreErrorComponent --------- Co-authored-by: Russell Dempsey <[email protected]>
1 parent c82d7be commit a6dc200

File tree

5 files changed

+86
-37
lines changed

5 files changed

+86
-37
lines changed

package-lock.json

Lines changed: 33 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/locales/en/explore.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@
6969
}
7070
},
7171
"errors": {
72-
"BlockFetchTimeoutError": "Failed to fetch content in {timeout}s. Please refresh the page to retry or try a different CID."
72+
"BlockFetchTimeoutError": "Failed to fetch content in {timeout}s. Please refresh the page to retry or try a different CID.",
73+
"BlockFetchError": "Failed to fetch content: {error}. This could mean the content is not available on the network or there are connectivity issues.",
74+
"CidSyntaxError": "Invalid CID format: {cid}. Please ensure you are using a valid CID.",
75+
"checkIpfsNetwork": "Check content availability on IPFS Network",
76+
"troubleshootingTips": {
77+
"title": "Troubleshooting Tips",
78+
"refresh": "Try refreshing the page",
79+
"checkConnection": "Check your internet connection",
80+
"tryLater": "Try again later - the content may still be propagating through the network",
81+
"checkCidSyntax": "Verify that your CID is formatted correctly or that your CAR file is valid"
82+
}
7383
}
7484
}

src/components/ExplorePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const ExplorePage = ({
6363
: <div style={{ height: 54 }} />}
6464

6565
<div className='dt-l dt--fixed'>
66-
<div className='dtc-l w-100 w-two-thirds-l pr3-l v-top'>
66+
<div className={`${error != null ? 'w-100 dt-row-l' : 'dtc-l w-100 w-two-thirds-l pr3-l'} v-top`}>
6767
<IpldExploreErrorComponent error={error} />
6868

6969
{targetNode != null
Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
import React from 'react'
22
import { useTranslation } from 'react-i18next'
3+
import { useExplore } from '../../providers/explore'
34
import type IpldExploreError from '../../lib/errors'
45

56
export interface IpldExploreErrorComponentProps {
67
error: IpldExploreError | null
78
}
89

10+
const TroubleshootingTips: React.FC<{ cid: string }> = ({ cid }) => {
11+
const { t } = useTranslation('explore', { keyPrefix: 'errors' })
12+
if (cid == null) return null
13+
14+
return (
15+
<>
16+
<div className='mt3'>
17+
<h4 className='ma0 mb2'>{t('troubleshootingTips.title')}</h4>
18+
<ul className='ma0 pl3'>
19+
<li>{t('troubleshootingTips.refresh')}</li>
20+
<li>{t('troubleshootingTips.checkConnection')}</li>
21+
<li>{t('troubleshootingTips.tryLater')}</li>
22+
<li>{t('troubleshootingTips.checkCidSyntax')}</li>
23+
</ul>
24+
</div>
25+
<div className='mt2'>
26+
<a
27+
href={`https://check.ipfs.network/?cid=${cid}`}
28+
target="_blank"
29+
rel="noopener noreferrer"
30+
className='red-dark hover-red underline'
31+
>
32+
{t('checkIpfsNetwork')}
33+
</a>
34+
</div>
35+
</>
36+
)
37+
}
38+
939
export function IpldExploreErrorComponent ({ error }: IpldExploreErrorComponentProps): JSX.Element | null {
40+
const { exploreState } = useExplore()
41+
const { path } = exploreState
42+
const [cid] = path?.split('/') ?? []
1043
const { t } = useTranslation('explore', { keyPrefix: 'errors' })
1144
if (error == null) return null
1245

46+
// more self service
1347
return (
14-
<div className='bg-red white pa3 lh-copy'>
15-
<div>{error.toString(t)}</div>
48+
<div className="flex justify-center w-100 pa3">
49+
<div className="bg-red-muted red-dark pa3 br2 lh-copy mw7">
50+
<div>{error.toString(t)}</div>
51+
<TroubleshootingTips cid={cid} />
52+
</div>
1653
</div>
1754
)
1855
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"include": [
3838
"src/**/*",
3939
"dev/**/*",
40-
"test/**/*"
40+
"test/**/*",
41+
"vite.config.ts"
4142
],
4243
"exclude": [
4344
"src/**/*.stories.*",

0 commit comments

Comments
 (0)