Skip to content

Commit

Permalink
ui: improve connection error page (#738)
Browse files Browse the repository at this point in the history
Co-authored-by: Zachary Johnson <[email protected]>
Co-authored-by: theborakompanioni <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 69e8fa7 commit 09e2d75
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
33 changes: 31 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense, lazy, useCallback, useEffect, useMemo, useState } from 'react'
import * as rb from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import {
createBrowserRouter,
createRoutesFromElements,
Expand Down Expand Up @@ -87,6 +87,8 @@ export default function App() {
[reloadCurrentWalletInfo],
)

debugger

const router = createBrowserRouter(
createRoutesFromElements(
<Route
Expand Down Expand Up @@ -132,7 +134,34 @@ export default function App() {
path="*"
element={
<rb.Alert variant="danger">
{t('app.alert_no_connection', { connectionError: sessionConnectionError.message })}.
<h5 className="alert-heading">
{t('app.alert_no_connection', { connectionError: sessionConnectionError.message })}
</h5>
{!sessionConnectionError.response?.ok && (
<>
<p>
<Trans
i18nKey="app.alert_no_connection_details"
components={{
1: (
<a
className="alert-link"
href="https://jamdocs.org/FAQ/#how-to-resolve-no-connection-to-gateway"
target="_blank"
rel="noopener noreferrer"
>
the docs
</a>
),
}}
/>
</p>
<pre>
{sessionConnectionError.response.status}&nbsp;{sessionConnectionError.response.statusText}&nbsp;
{sessionConnectionError.response.url}
</pre>
</>
)}
</rb.Alert>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/context/ServiceInfoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface ServiceInfoContextEntry {
serviceInfo: ServiceInfo | null
reloadServiceInfo: ({ signal }: { signal: AbortSignal }) => Promise<ServiceInfo>
dispatchServiceInfo: Dispatch<Partial<ServiceInfo>>
connectionError?: Error
connectionError?: Api.JmApiError
}

const ServiceInfoContext = createContext<ServiceInfoContextEntry | undefined>(undefined)
Expand All @@ -107,7 +107,7 @@ const ServiceInfoProvider = ({ children }: PropsWithChildren<{}>) => {
(state: ServiceInfo | null, obj: Partial<ServiceInfo>) => ({ ...state, ...obj }) as ServiceInfo | null,
null,
)
const [connectionError, setConnectionError] = useState<Error>()
const [connectionError, setConnectionError] = useState<Api.JmApiError>()

useEffect(() => {
const abortCtrl = new AbortController()
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"app": {
"alert_no_connection": "No connection to backend: {{ connectionError }}",
"alert_no_connection_details": "Please confirm that the backend is running and <1>see the docs for more information</1>.",
"alert_rescan_in_progress": "Rescanning in progress..."
},
"navbar": {
Expand Down

0 comments on commit 09e2d75

Please sign in to comment.