From 24f700af6f0b1abd9f3988819ad8c4c957cf1e89 Mon Sep 17 00:00:00 2001 From: jmatsuok Date: Mon, 29 Jul 2024 17:19:49 -0400 Subject: [PATCH] Resolve eslint errors --- .../Charts/mbean/MBeanMetricsChartCard.tsx | 2 +- src/app/RecordingMetadata/BulkEditLabels.tsx | 4 +- .../Recordings/ArchivedRecordingsTable.tsx | 5 +- src/app/Shared/Services/Api.service.tsx | 2 +- src/app/Topology/Entity/EntityDetails.tsx | 78 ++++++++++--------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx b/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx index cccd0894e..43e1de1b6 100644 --- a/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx +++ b/src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx @@ -20,6 +20,7 @@ import { DashboardCardSizes, DashboardCardDescriptor, } from '@app/Dashboard/types'; +import { ErrorView } from '@app/ErrorView/ErrorView'; import { ThemeType, ThemeSetting } from '@app/Settings/types'; import { MBeanMetrics } from '@app/Shared/Services/api.types'; import { FeatureLevel } from '@app/Shared/Services/service.types'; @@ -47,7 +48,6 @@ import { useTranslation } from 'react-i18next'; import { interval } from 'rxjs'; import { DashboardCard } from '../../DashboardCard'; import { ChartContext } from '../context'; -import { ErrorView } from '@app/ErrorView/ErrorView'; import { missingSSLMessage, authFailMessage, isAuthFail } from '@app/ErrorView/types'; export interface MBeanMetricsChartCardProps extends DashboardCardTypeProps { diff --git a/src/app/RecordingMetadata/BulkEditLabels.tsx b/src/app/RecordingMetadata/BulkEditLabels.tsx index 148ccaefa..0745e78e8 100644 --- a/src/app/RecordingMetadata/BulkEditLabels.tsx +++ b/src/app/RecordingMetadata/BulkEditLabels.tsx @@ -14,6 +14,7 @@ * limitations under the License. */ import { uploadAsTarget } from '@app/Archives/Archives'; +import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; import { LabelCell } from '@app/RecordingMetadata/LabelCell'; import { LoadingProps } from '@app/Shared/Components/types'; import { @@ -26,6 +27,7 @@ import { Target, KeyValue, } from '@app/Shared/Services/api.types'; +import { isGraphQLAuthError, isGraphQLSSLError } from '@app/Shared/Services/api.utils'; import { ServiceContext } from '@app/Shared/Services/Services'; import { useSubscriptions } from '@app/utils/hooks/useSubscriptions'; import { hashCode, portalRoot } from '@app/utils/utils'; @@ -35,8 +37,6 @@ import * as React from 'react'; import { combineLatest, concatMap, filter, first, forkJoin, map, Observable, of, tap } from 'rxjs'; import { RecordingLabelFields } from './RecordingLabelFields'; import { includesLabel } from './utils'; -import { isGraphQLAuthError, isGraphQLSSLError } from '@app/Shared/Services/api.utils'; -import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; export interface BulkEditLabelsProps { isTargetRecording: boolean; diff --git a/src/app/Recordings/ArchivedRecordingsTable.tsx b/src/app/Recordings/ArchivedRecordingsTable.tsx index ad0cadbd2..81882cca4 100644 --- a/src/app/Recordings/ArchivedRecordingsTable.tsx +++ b/src/app/Recordings/ArchivedRecordingsTable.tsx @@ -19,6 +19,7 @@ import { ClickableAutomatedAnalysisLabel, clickableAutomatedAnalysisKey, } from '@app/Dashboard/AutomatedAnalysis/ClickableAutomatedAnalysisLabel'; +import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; import { DeleteWarningModal } from '@app/Modal/DeleteWarningModal'; import { DeleteOrDisableWarningType } from '@app/Modal/types'; import { LoadingProps } from '@app/Shared/Components/types'; @@ -43,6 +44,7 @@ import { CategorizedRuleEvaluations, AnalysisResult, } from '@app/Shared/Services/api.types'; +import { isGraphQLAuthError, isGraphQLSSLError } from '@app/Shared/Services/api.utils'; import { ServiceContext } from '@app/Shared/Services/Services'; import { useSort } from '@app/utils/hooks/useSort'; import { useSubscriptions } from '@app/utils/hooks/useSubscriptions'; @@ -83,8 +85,6 @@ import { RecordingActions } from './RecordingActions'; import { RecordingFiltersCategories, filterRecordings, RecordingFilters } from './RecordingFilters'; import { RecordingLabelsPanel } from './RecordingLabelsPanel'; import { ColumnConfig, RecordingsTable } from './RecordingsTable'; -import { isGraphQLAuthError, isGraphQLSSLError } from '@app/Shared/Services/api.utils'; -import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; const tableColumns: TableColumn[] = [ { @@ -304,6 +304,7 @@ export const ArchivedRecordingsTable: React.FC = ( handleError, queryTargetRecordings, queryUploadedRecordings, + context.target, isUploadsTable, propsDirectory, propsTarget, diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 8220c26e8..29241cba9 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -15,6 +15,7 @@ */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { LayoutTemplate, SerialLayoutTemplate } from '@app/Dashboard/types'; +import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; import { createBlobURL } from '@app/utils/utils'; import { ValidatedOptions } from '@patternfly/react-core'; import { EMPTY, forkJoin, from, Observable, ObservableInput, of, ReplaySubject, shareReplay, throwError } from 'rxjs'; @@ -68,7 +69,6 @@ import { LoginService } from './Login.service'; import { NotificationService } from './Notifications.service'; import { SessionState } from './service.types'; import { TargetService } from './Target.service'; -import { authFailMessage, missingSSLMessage } from '@app/ErrorView/types'; export class ApiService { private readonly archiveEnabled = new ReplaySubject(1); diff --git a/src/app/Topology/Entity/EntityDetails.tsx b/src/app/Topology/Entity/EntityDetails.tsx index 3f069d3df..4f5046dd8 100644 --- a/src/app/Topology/Entity/EntityDetails.tsx +++ b/src/app/Topology/Entity/EntityDetails.tsx @@ -18,7 +18,7 @@ import { authFailMessage, isAuthFail, missingSSLMessage } from '@app/ErrorView/types'; import { LinearDotSpinner } from '@app/Shared/Components/LinearDotSpinner'; import { EnvironmentNode, MBeanMetrics, MBeanMetricsResponse, TargetNode } from '@app/Shared/Services/api.types'; -import { isGraphQLAuthError, isGraphQLSSLError, isTargetNode } from '@app/Shared/Services/api.utils'; +import { isTargetNode } from '@app/Shared/Services/api.utils'; import { ServiceContext } from '@app/Shared/Services/Services'; import { ActionDropdown } from '@app/Topology/Actions/NodeActions'; import useDayjs from '@app/utils/hooks/useDayjs'; @@ -101,6 +101,45 @@ export const EntityDetails: React.FC = ({ alertOptions, ...props }) => { + + const services = React.useContext(ServiceContext); + const [errorMessage, setErrorMessage] = React.useState(''); + const addSubscription = useSubscriptions(); + + React.useEffect(() => { + addSubscription( + services.target.sslFailure().subscribe(() => { + // also triggered if api calls in Custom Recording form fail + setErrorMessage(missingSSLMessage); + }), + ); + }, [services.target, setErrorMessage, addSubscription]); + + React.useEffect(() => { + addSubscription( + services.target.authRetry().subscribe(() => { + setErrorMessage(''); // Reset on retry + }), + ); + }, [services.target, setErrorMessage, addSubscription]); + + React.useEffect(() => { + addSubscription( + services.target.authFailure().subscribe(() => { + // also triggered if api calls in Custom Recording form fail + setErrorMessage(authFailMessage); + }), + ); + }, [services.target, setErrorMessage, addSubscription]); + + React.useEffect(() => { + addSubscription( + services.target.target().subscribe(() => { + setErrorMessage(''); // Reset on change + }), + ); + }, [services.target, setErrorMessage, addSubscription]); + const [activeTab, setActiveTab] = React.useState(EntityTab.DETAIL); const viewContent = React.useMemo(() => { if (entity && isRenderable(entity)) { @@ -110,44 +149,7 @@ export const EntityDetails: React.FC = ({ const _actions = actionFactory(entity, 'dropdownItem', actionFilter); - const [errorMessage, setErrorMessage] = React.useState(''); - const addSubscription = useSubscriptions(); const services = React.useContext(ServiceContext); - - React.useEffect(() => { - addSubscription( - services.target.sslFailure().subscribe(() => { - // also triggered if api calls in Custom Recording form fail - setErrorMessage(missingSSLMessage); - }), - ); - }, [services.target, setErrorMessage, addSubscription]); - - React.useEffect(() => { - addSubscription( - services.target.authRetry().subscribe(() => { - setErrorMessage(''); // Reset on retry - }), - ); - }, [services.target, setErrorMessage, addSubscription]); - - React.useEffect(() => { - addSubscription( - services.target.authFailure().subscribe(() => { - // also triggered if api calls in Custom Recording form fail - setErrorMessage(authFailMessage); - }), - ); - }, [services.target, setErrorMessage, addSubscription]); - - React.useEffect(() => { - addSubscription( - services.target.target().subscribe(() => { - setErrorMessage(''); // Reset on change - }), - ); - }, [services.target, setErrorMessage, addSubscription]); - const authRetry = React.useCallback(() => { services.target.setAuthRetry(); }, [services.target]);