Skip to content

Commit

Permalink
Resolve eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Matsuoka committed Jul 29, 2024
1 parent 8c2e7b2 commit 24f700a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';

Check warning on line 51 in src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

`@app/ErrorView/types` import should occur before import of `@app/Settings/types`

Check warning on line 51 in src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

`@app/ErrorView/types` import should occur before import of `@app/Settings/types`

export interface MBeanMetricsChartCardProps extends DashboardCardTypeProps {
Expand Down
4 changes: 2 additions & 2 deletions src/app/RecordingMetadata/BulkEditLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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';
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/app/Recordings/ArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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[] = [
{
Expand Down Expand Up @@ -304,6 +304,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
handleError,
queryTargetRecordings,
queryUploadedRecordings,
context.target,
isUploadsTable,
propsDirectory,
propsTarget,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<boolean>(1);
Expand Down
78 changes: 40 additions & 38 deletions src/app/Topology/Entity/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check warning on line 20 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

'MBeanMetricsResponse' is defined but never used

Check warning on line 20 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

'MBeanMetricsResponse' is defined but never used
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';
Expand Down Expand Up @@ -101,6 +101,45 @@ export const EntityDetails: React.FC<EntityDetailsProps> = ({
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)) {
Expand All @@ -110,44 +149,7 @@ export const EntityDetails: React.FC<EntityDetailsProps> = ({

const _actions = actionFactory(entity, 'dropdownItem', actionFilter);

const [errorMessage, setErrorMessage] = React.useState('');
const addSubscription = useSubscriptions();
const services = React.useContext(ServiceContext);

Check failure on line 152 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

React Hook "React.useContext" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function

Check failure on line 152 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

React Hook "React.useContext" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function

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(() => {

Check failure on line 153 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

React Hook "React.useCallback" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function

Check failure on line 153 in src/app/Topology/Entity/EntityDetails.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

React Hook "React.useCallback" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function
services.target.setAuthRetry();
}, [services.target]);
Expand Down

0 comments on commit 24f700a

Please sign in to comment.