From 4a0f9a95b1ef5aa486c8fd11b253da33eede3e53 Mon Sep 17 00:00:00 2001 From: Ming Wang Date: Mon, 26 Feb 2024 17:58:07 -0500 Subject: [PATCH] add fix in all archives view --- .../Archives/AllArchivedRecordingsTable.tsx | 45 +++++++++++++++++-- .../AllTargetsArchivedRecordingsTable.tsx | 19 +++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/app/Archives/AllArchivedRecordingsTable.tsx b/src/app/Archives/AllArchivedRecordingsTable.tsx index 5d405a627..96d021975 100644 --- a/src/app/Archives/AllArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllArchivedRecordingsTable.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 { authFailMessage, isAuthFail } from '@app/ErrorView/types'; import { ArchivedRecordingsTable } from '@app/Recordings/ArchivedRecordingsTable'; import { LoadingView } from '@app/Shared/Components/LoadingView'; import { ArchivedRecording, RecordingDirectory, Target, NotificationCategory } from '@app/Shared/Services/api.types'; @@ -78,6 +80,7 @@ export const AllArchivedRecordingsTable: React.FC([]); const [searchText, setSearchText] = React.useState(''); const [expandedDirectories, setExpandedDirectories] = React.useState<_RecordingDirectory[]>([]); + const [errorMessage, setErrorMessage] = React.useState(''); const [isLoading, setIsLoading] = React.useState(false); const addSubscription = useSubscriptions(); const [sortBy, getSortParams] = useSort(); @@ -90,12 +93,23 @@ export const AllArchivedRecordingsTable: React.FC { + setIsLoading(false); + setErrorMessage(error.message); + }, + [setIsLoading, setErrorMessage], + ); + const refreshDirectoriesAndCounts = React.useCallback(() => { setIsLoading(true); addSubscription( - context.api.doGet('fs/recordings', 'beta').subscribe(handleDirectoriesAndCounts), + context.api.doGet('fs/recordings', 'beta').subscribe({ + next: handleDirectoriesAndCounts, + error: handleError, + }), ); - }, [addSubscription, context.api, setIsLoading, handleDirectoriesAndCounts]); + }, [addSubscription, context.api, setIsLoading, handleDirectoriesAndCounts, handleError]); const handleSearchInput = React.useCallback( (searchInput: string) => { @@ -134,6 +148,14 @@ export const AllArchivedRecordingsTable: React.FC { + addSubscription( + context.target.authFailure().subscribe(() => { + setErrorMessage(authFailMessage); + }), + ); + }, [context, context.target, setErrorMessage, addSubscription]); + React.useEffect(() => { if (!context.settings.autoRefreshEnabled()) { return; @@ -262,7 +284,24 @@ export const AllArchivedRecordingsTable: React.FC { + context.target.setAuthRetry(); + }, [context.target]); + + const isError = React.useMemo(() => errorMessage != '', [errorMessage]); + + if (isError) { + view = ( + <> + + + ); + } else if (isLoading) { view = ; } else if (!searchedDirectories.length) { view = ( diff --git a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx index 19c305f19..e07ce82ed 100644 --- a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { ErrorView } from '@app/ErrorView/ErrorView'; -import { isAuthFail } from '@app/ErrorView/types'; +import { authFailMessage , 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'; @@ -108,6 +108,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC { setIsLoading(false); + setErrorMessage(''); setArchivesForTargets( targetNodes.map((node) => { const target: Target = { @@ -122,7 +123,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC { + addSubscription( + context.target.authFailure().subscribe(() => { + setErrorMessage(authFailMessage); + }), + ); + }, [context, context.target, setErrorMessage, addSubscription]); + React.useEffect(() => { if (!context.settings.autoRefreshEnabled()) { return; @@ -351,7 +360,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC + {archiveCount} @@ -399,9 +408,9 @@ export const AllTargetsArchivedRecordingsTable: React.FC );