Skip to content

Commit

Permalink
fix: fix broken status filter selection
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Aug 27, 2024
1 parent f177c53 commit e273bd9
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/app/SecurityPanel/Credentials/CredentialTestTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { LinearDotSpinner } from '@app/Shared/Components/LinearDotSpinner';
import { LoadingView } from '@app/Shared/Components/LoadingView';
import { Target } from '@app/Shared/Services/api.types';
import { FeatureLevel } from '@app/Shared/Services/service.types';

Check warning on line 19 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

'FeatureLevel' is defined but never used

Check warning on line 19 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

'FeatureLevel' is defined but never used
import { ServiceContext } from '@app/Shared/Services/Services';
import { useMatchExpressionSvc } from '@app/utils/hooks/useMatchExpressionSvc';
import { useSort } from '@app/utils/hooks/useSort';
Expand All @@ -42,6 +43,9 @@ import {
DropdownList,

Check warning on line 43 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

'DropdownList' is defined but never used

Check warning on line 43 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

'DropdownList' is defined but never used
Select,
SelectOption,
SelectList,
MenuToggle,
MenuToggleElement,
} from '@patternfly/react-core';
import { ExclamationCircleIcon, SearchIcon, WarningTriangleIcon } from '@patternfly/react-icons';
import {
Expand All @@ -55,6 +59,7 @@ import {
Thead,
Tr,
} from '@patternfly/react-table';
import { t } from 'i18next';
import _ from 'lodash';
import * as React from 'react';
import { catchError, combineLatest, of, switchMap, tap } from 'rxjs';
Expand Down Expand Up @@ -371,23 +376,32 @@ const StatusFilter: React.FC<StatusFilterProps> = ({ onChange, filters, ...props
[onChange, filters],
);

const toggle = React.useCallback(
(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle ref={toggleRef} onClick={handleToggle} isExpanded={isOpen}>
Status
</MenuToggle>
),
[handleToggle, open, isOpen, t],

Check failure on line 385 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

React Hook React.useCallback has unnecessary dependencies: 'open' and 't'. Either exclude them or remove the dependency array. Outer scope values like 'open' aren't valid dependencies because mutating them doesn't re-render the component

Check failure on line 385 in src/app/SecurityPanel/Credentials/CredentialTestTable.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

React Hook React.useCallback has unnecessary dependencies: 'open' and 't'. Either exclude them or remove the dependency array. Outer scope values like 'open' aren't valid dependencies because mutating them doesn't re-render the component
);

return (
<Select
{...props}
role="menu"
aria-label="Status"
toggle={handleToggle}
aria-label="Test Status"
toggle={toggle}
onSelect={handleSelect}
selected={filters}
isOpen={isOpen}
onOpenChange={setIsOpen}
onOpenChangeKeys={['Escape']}
>
<DropdownList>
<SelectList>
{Object.values(CredentialTestState).map((state) => (
<SelectOption key={state} value={state}>
<SelectOption key={state} value={state} hasCheckbox isSelected={filters.includes(state)}>
<Label color={getColor(state)}>{state}</Label>
</SelectOption>
))}
</DropdownList>
</SelectList>
</Select>
);
};

0 comments on commit e273bd9

Please sign in to comment.