diff --git a/src/app/components/AuthFlowsLoader.tsx b/src/app/components/AuthFlowsLoader.tsx index 616ccb7e4..ef3f8c1f6 100644 --- a/src/app/components/AuthFlowsLoader.tsx +++ b/src/app/components/AuthFlowsLoader.tsx @@ -16,7 +16,7 @@ import { fetch } from '$utils/fetch'; type AuthFlowsLoaderProps = { fallback?: () => ReactNode; - error?: (err: unknown) => ReactNode; + error?: (err: unknown, retry: () => void) => ReactNode; children: (authFlows: AuthFlows) => ReactNode; }; export function AuthFlowsLoader({ fallback, error, children }: AuthFlowsLoaderProps) { @@ -72,7 +72,7 @@ export function AuthFlowsLoader({ fallback, error, children }: AuthFlowsLoaderPr } if (state.status === AsyncStatus.Error) { - return error?.(state.error); + return error?.(state.error, load); } return children(state.data); diff --git a/src/app/pages/auth/AuthLayout.tsx b/src/app/pages/auth/AuthLayout.tsx index 5b844adb8..ef0b47ac6 100644 --- a/src/app/pages/auth/AuthLayout.tsx +++ b/src/app/pages/auth/AuthLayout.tsx @@ -1,6 +1,7 @@ import type { ReactNode } from 'react'; import { useCallback, useEffect } from 'react'; -import { Box, Chip, Header, Scroll, Spinner, Text, color } from 'folds'; +import { Box, Chip, Header, IconButton, Scroll, Spinner, Text, color } from 'folds'; +import { ArrowClockwiseIcon } from '@phosphor-icons/react'; import { Outlet, generatePath, @@ -26,6 +27,7 @@ import { AuthServerProvider } from '$hooks/useAuthServer'; import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH } from '$pages/paths'; import { getHomePath } from '$pages/pathUtils'; import { fetch } from '$utils/fetch'; +import { sizedIcon } from '$components/icons/phosphor'; import { AutoDiscoveryAction, autoDiscovery } from '../../cs-api'; import type { SpecVersions } from '../../cs-api'; import { ServerPicker } from './ServerPicker'; @@ -57,12 +59,23 @@ function AuthLayoutLoading({ message }: { message: string }) { ); } -function AuthLayoutError({ message }: { message: string }) { +function AuthLayoutError({ message, retry }: { message: string; retry: () => void }) { return ( {message} + + {sizedIcon(ArrowClockwiseIcon, '100')} + ); } @@ -71,9 +84,12 @@ function AuthHomeserverConnectFallback({ baseUrl }: { baseUrl: string }) { return ; } -function authHomeserverConnectError() { +function authHomeserverConnectError(_error: unknown, retry: () => void) { return ( - + ); } @@ -81,8 +97,8 @@ function authFlowsLoadingFallback() { return ; } -function authFlowsError() { - return ; +function authFlowsError(_error: unknown, retry: () => void) { + return ; } function AuthFlowsOutlet({ authFlows }: { authFlows: AuthFlows }) { @@ -138,6 +154,7 @@ export function AuthLayout() { }; }, []) ); + const retryHomeserverDiscovery = () => discoverServer(server); useEffect(() => { if (server) discoverServer(server); @@ -234,15 +251,22 @@ export function AuthLayout() { )} {discoveryState.status === AsyncStatus.Error && ( - + )} {autoDiscoveryError?.action === AutoDiscoveryAction.FAIL_PROMPT && ( )} {autoDiscoveryError?.action === AutoDiscoveryAction.FAIL_ERROR && ( - + )} {discoveryState.status === AsyncStatus.Success && autoDiscoveryInfo && (