From 01ab2b15e7f87ab15b854c1cfe383af32118d41d Mon Sep 17 00:00:00 2001 From: Ming Wang Date: Fri, 16 Feb 2024 14:29:41 -0500 Subject: [PATCH] add archives error page --- .../AllTargetsArchivedRecordingsTable.tsx | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx index df4d1b8bf..ebdf50248 100644 --- a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { ErrorView } from '@app/ErrorView/ErrorView'; +import { isAuthFail } from '@app/ErrorView/types'; import { ArchivedRecordingsTable } from '@app/Recordings/ArchivedRecordingsTable'; import { LoadingView } from '@app/Shared/Components/LoadingView'; import { Target, TargetDiscoveryEvent, NotificationCategory } from '@app/Shared/Services/api.types'; @@ -82,6 +84,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC([]); const [expandedTargets, setExpandedTargets] = React.useState([] as Target[]); const [hideEmptyTargets, setHideEmptyTargets] = React.useState(true); + const [errorMessage, setErrorMessage] = React.useState(''); const [isLoading, setIsLoading] = React.useState(false); const addSubscription = useSubscriptions(); const [sortBy, getSortParams] = useSort(); @@ -122,6 +125,14 @@ export const AllTargetsArchivedRecordingsTable: React.FC { + setIsLoading(false); + setErrorMessage(error.message); + }, + [setIsLoading, setErrorMessage], + ); + /* eslint-disable @typescript-eslint/no-explicit-any */ const refreshArchivesForTargets = React.useCallback(() => { setIsLoading(true); @@ -145,9 +156,12 @@ export const AllTargetsArchivedRecordingsTable: React.FC v.data.targetNodes)) - .subscribe(handleArchivesForTargets), + .subscribe({ + next: handleArchivesForTargets, + error: handleError, + }), ); - }, [addSubscription, context.api, setIsLoading, handleArchivesForTargets]); + }, [addSubscription, context.api, setIsLoading, handleArchivesForTargets, handleError]); /* eslint-disable @typescript-eslint/no-explicit-any */ const getCountForNewTarget = React.useCallback( @@ -374,7 +388,24 @@ export const AllTargetsArchivedRecordingsTable: React.FC { + context.target.setAuthRetry(); + }, [context.target]); + + const isError = React.useMemo(() => errorMessage != '', [errorMessage]); + + if (isError) { + view = ( + <> + + + ); + } else if (isLoading) { view = ; } else if (!searchedArchivesForTargets.length) { view = (