Skip to content

Commit d1e5cd2

Browse files
authored
fix: diagnostics tab urls electron (#2481)
* fix: remove hyphens from diagnostics tab URLs Electron's `webui://` protocol truncates hash fragments at hyphens, causing blank screens on Retrieval Check and DHT Provide tabs. - src/diagnostics/diagnostics-content.tsx: rename tab URL segments `retrieval-check` -> `retrieval`, `dht-provide` -> `provider`, remove unused imports and dead code - src/files/FilesPage.js: update retrieval diagnostics link - src/files/file-not-found/index.tsx: update retrieval diagnostics link - src/settings/SettingsPage.js: update retrieval diagnostics link - src/components/unsupported-kubo-version/unsupported-kubo-version.tsx: show loading text instead of blank when agent version is not yet known - src/contexts/ProvideStat/provide-context.tsx: reorder deps array * chore: update package-lock.json * fix(test): update e2e test to use new diagnostics tab URL update `/#/diagnostics/dht-provide` -> `/#/diagnostics/provider` in playwright e2e test to match the URL rename from prior commit
1 parent 4879de2 commit d1e5cd2

File tree

8 files changed

+25
-39
lines changed

8 files changed

+25
-39
lines changed

package-lock.json

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

src/components/unsupported-kubo-version/unsupported-kubo-version.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const UnsupportedKuboVersion: React.FC<UnsupportedKuboVersionProps> = () => {
2626
}, [agentVersionObject])
2727

2828
if (agentVersionObject == null) {
29-
return null
29+
return <div className='pa4'>{t('dhtProvide.screen.loading')}</div>
3030
}
3131

3232
return (

src/contexts/ProvideStat/provide-context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const ProvideProvider: React.FC<{ children: React.ReactNode }> = ({ child
9999
autoRefreshEnabled,
100100
setAutoRefreshEnabled,
101101
isAgentVersionSupported
102-
}), [data, loading, error, lastUpdated, refresh, autoRefreshEnabled, isAgentVersionSupported, setAutoRefreshEnabled])
102+
}), [data, loading, error, lastUpdated, refresh, autoRefreshEnabled, setAutoRefreshEnabled, isAgentVersionSupported])
103103

104104
return (
105105
<ProvideContext.Provider value={value}>

src/diagnostics/diagnostics-content.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef } from 'react'
1+
import React, { useEffect } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import LogsScreen from './logs-screen/logs-screen.js'
44
import { LogsProvider } from '../contexts/logs/index'
@@ -8,10 +8,7 @@ import { useBridgeSelector } from '../helpers/context-bridge'
88
import { RouteInfo } from '../bundles/routes-types'
99
import { ProvideProvider } from '../contexts/ProvideStat'
1010

11-
interface DiagnosticsContentProps {
12-
}
13-
14-
type TabKey = 'logs' | 'retrieval-check' | 'dht-provide'
11+
type TabKey = 'logs' | 'retrieval' | 'provider'
1512

1613
function getTabKeyFromUrl (path: string): { tab: TabKey, remainder?: string } {
1714
const parts = path.split('/').filter(p => p) // Remove empty strings
@@ -57,32 +54,21 @@ const TabButton = ({ tabKey, label, active }: TabButtonProps) => (
5754
</a>
5855
)
5956

60-
const DiagnosticsContent: React.FC<DiagnosticsContentProps> = () => {
57+
const DiagnosticsContent: React.FC = () => {
6158
const { t } = useTranslation('diagnostics')
6259
const routeInfo = useBridgeSelector<RouteInfo>('selectRouteInfo')
63-
const path = routeInfo?.params.path ?? ''
60+
const path = routeInfo?.params?.path ?? ''
6461
const { tab: activeTab, remainder } = getTabKeyFromUrl(path)
6562

6663
// Redirect from /diagnostics or /diagnostics/ to /diagnostics/logs
6764
useEffect(() => {
68-
// Check if we're still loading route info
6965
if (!routeInfo) return
70-
71-
// Only redirect from true root paths
7266
const isRootDiagnostics = routeInfo.url === '/diagnostics' || routeInfo.url === '/diagnostics/'
7367
if (isRootDiagnostics && (path === '' || path === '/')) {
7468
window.location.replace('#/diagnostics/logs')
7569
}
7670
}, [path, routeInfo])
7771

78-
const isMounted = useRef(false)
79-
useEffect(() => {
80-
isMounted.current = true
81-
return () => {
82-
isMounted.current = false
83-
}
84-
}, [])
85-
8672
const renderTabContent = () => {
8773
switch (activeTab) {
8874
case 'logs':
@@ -93,12 +79,11 @@ const DiagnosticsContent: React.FC<DiagnosticsContentProps> = () => {
9379
</LogsProvider>
9480
</IdentityProvider>
9581
)
96-
case 'retrieval-check':
82+
case 'retrieval':
9783
return (
9884
<CheckScreen cid={remainder} />
9985
)
100-
case 'dht-provide': {
101-
// Lazy-load the DHT provide screen to keep bundle size small
86+
case 'provider': {
10287
const DhtProvideScreen = require('./dht-provide/dht-provide-screen').default
10388
return (
10489
<IdentityProvider>
@@ -119,8 +104,8 @@ const DiagnosticsContent: React.FC<DiagnosticsContentProps> = () => {
119104
<div className='mb4 pb2' style={{ borderBottom: '1px solid #e1e5eb' }}>
120105
<nav className='flex items-center'>
121106
<TabButton tabKey='logs' label={t('tabs.logs')} active={activeTab === 'logs'} />
122-
<TabButton tabKey='retrieval-check' label={t('tabs.retrieval-check')} active={activeTab === 'retrieval-check'} />
123-
<TabButton tabKey='dht-provide' label={t('tabs.dht-provide')} active={activeTab === 'dht-provide'} />
107+
<TabButton tabKey='retrieval' label={t('tabs.retrieval-check')} active={activeTab === 'retrieval'} />
108+
<TabButton tabKey='provider' label={t('tabs.dht-provide')} active={activeTab === 'provider'} />
124109
</nav>
125110
</div>
126111

src/files/FilesPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const FilesPage = ({
161161
const onInspect = (cid) => doUpdateHash(`/explore/${cid}`)
162162
const onCheckRetrieval = (cid) => {
163163
doFilesCidProvide(cid) // Trigger background provide
164-
doUpdateHash(`/diagnostics/retrieval-check/${cid}`)
164+
doUpdateHash(`/diagnostics/retrieval/${cid}`)
165165
}
166166
const showModal = (modal, files = null) => setModals({ show: modal, files })
167167
const hideModal = () => setModals({})

src/files/file-not-found/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const FileNotFound = ({ path, error }: FileNotFoundProps) => {
3838
</li>
3939
<li className='mb2'>
4040
<Trans i18nKey='previewNotFound.helpListItemRetrieval' t={t}>
41-
If you have a CID you believe should work, <a className='link blue' href='#/diagnostics/retrieval-check'>run Retrieval Diagnostics</a>.
41+
If you have a CID you believe should work, <a className='link blue' href='#/diagnostics/retrieval'>run Retrieval Diagnostics</a>.
4242
</Trans>
4343
</li>
4444
<li className='mb2'>

src/settings/SettingsPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const SettingsPage = ({
105105
<p className='ma0 mr2 lh-copy charcoal f6'>
106106
<Trans i18nKey='retrievalDiagnosticService.description' t={t}>
107107
<a className='link blue' href='https://github.com/ipfs/ipfs-check' target='_blank' rel='noopener noreferrer'>ipfs-check</a>
108-
<a className='link blue' href='#/diagnostics/retrieval-check'>retrieval diagnostics</a>
108+
<a className='link blue' href='#/diagnostics/retrieval'>retrieval diagnostics</a>
109109
</Trans>
110110
</p>
111111
<IpfsCheckForm/>

test/e2e/diagnostics-dht-provide.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const dhtProvide = {
1919

2020
test.describe('DHT Provide diagnostics page', () => {
2121
test.beforeEach(async ({ page }) => {
22-
await page.goto('/#/diagnostics/dht-provide')
22+
await page.goto('/#/diagnostics/provider')
2323
// wait for the stats grid to appear (indicates data has loaded)
2424
await expect(dhtProvide.grid(page)).toBeVisible({ timeout: 15000 })
2525
})

0 commit comments

Comments
 (0)