diff --git a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx index 51cfe0639..5af922798 100644 --- a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx +++ b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx @@ -15,7 +15,7 @@ */ import { ErrorView } from '@app/ErrorView/ErrorView'; -import { authFailMessage, isAuthFail } from '@app/ErrorView/types'; +import { authFailMessage, isAuthFail, missingSSLMessage } from '@app/ErrorView/types'; import { LoadingView } from '@app/Shared/Components/LoadingView'; import { emptyAutomatedAnalysisFilters, @@ -45,7 +45,7 @@ import { AutomatedAnalysisScore, AnalysisResult, } from '@app/Shared/Services/api.types'; -import { isGraphQLAuthError } from '@app/Shared/Services/api.utils'; +import { isGraphQLAuthError, isGraphQLError, isGraphQLSSLError } from '@app/Shared/Services/api.utils'; import { FeatureLevel } from '@app/Shared/Services/service.types'; import { automatedAnalysisConfigToRecordingAttributes } from '@app/Shared/Services/service.utils'; import { ServiceContext } from '@app/Shared/Services/Services'; @@ -359,10 +359,13 @@ export const AutomatedAnalysisCard: DashboardCardFC .pipe( first(), tap((resp) => { - if (resp.data == undefined) { + if (isGraphQLError(resp)) { if (isGraphQLAuthError(resp)) { context.target.setAuthFailure(); throw new Error(authFailMessage); + } else if (isGraphQLSSLError(resp)) { + context.target.setSslFailure(); + throw new Error(missingSSLMessage); } else { throw new Error(resp.errors[0].message); } diff --git a/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx b/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx index 016742443..febe86e16 100644 --- a/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx +++ b/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx @@ -20,6 +20,8 @@ import { DashboardCardSizes, DashboardCardDescriptor, } from '@app/Dashboard/types'; +import { ErrorView } from '@app/ErrorView/ErrorView'; +import { missingSSLMessage, authFailMessage, isAuthFail } from '@app/ErrorView/types'; import { ThemeType, ThemeSetting } from '@app/Settings/types'; import { MBeanMetrics } from '@app/Shared/Services/api.types'; import { FeatureLevel } from '@app/Shared/Services/service.types'; @@ -370,6 +372,8 @@ export const MBeanMetricsChartCard: DashboardCardFC const addSubscription = useSubscriptions(); const [samples, setSamples] = React.useState([] as Sample[]); const [isLoading, setLoading] = React.useState(true); + const [errorMessage, setErrorMessage] = React.useState(''); + const isError = React.useMemo(() => errorMessage != '', [errorMessage]); const resizeObserver = React.useRef((): void => undefined); const [cardWidth, setCardWidth] = React.useState(0); @@ -411,9 +415,34 @@ export const MBeanMetricsChartCard: DashboardCardFC addSubscription( serviceContext.target.target().subscribe((_) => { setSamples([]); + setErrorMessage(''); // Reset on change }), ); - }, [addSubscription, serviceContext, setSamples, refresh]); + }, [addSubscription, serviceContext, setSamples, setErrorMessage, refresh]); + + React.useEffect(() => { + addSubscription( + serviceContext.target.authRetry().subscribe(() => { + setErrorMessage(''); // Reset on retry + }), + ); + }, [addSubscription, serviceContext.target, setErrorMessage]); + + React.useEffect(() => { + addSubscription( + serviceContext.target.sslFailure().subscribe(() => { + setErrorMessage(missingSSLMessage); + }), + ); + }, [addSubscription, serviceContext.target, setErrorMessage]); + + React.useEffect(() => { + addSubscription( + serviceContext.target.authFailure().subscribe(() => { + setErrorMessage(authFailMessage); + }), + ); + }, [addSubscription, serviceContext.target, setErrorMessage]); React.useEffect(() => { refresh(); @@ -424,6 +453,10 @@ export const MBeanMetricsChartCard: DashboardCardFC addSubscription(controllerContext.mbeanController.loading().subscribe(setLoading)); }, [addSubscription, controllerContext, setLoading]); + const authRetry = React.useCallback(() => { + serviceContext.target.setAuthRetry(); + }, [serviceContext.target]); + const refreshButton = React.useMemo( () => (