remove deprecated select (#29082)

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-04-26 09:51:22 +02:00 committed by GitHub
parent cca660067a
commit aeed5eee17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 11 deletions

View file

@ -10,7 +10,7 @@ export default class PasswordPolicies {
}
addPolicy(name: string) {
cy.get(".pf-v5-c-select").click().contains(name).click();
cy.findByTestId("add-policy").click().parent().contains(name).click();
return this;
}

View file

@ -16,8 +16,11 @@ import {
EmptyStateActions,
EmptyStateHeader,
EmptyStateFooter,
Select,
SelectOption,
MenuToggle,
SelectList,
} from "@patternfly/react-core";
import { Select, SelectOption } from "@patternfly/react-core/deprecated";
import { PlusCircleIcon } from "@patternfly/react-icons";
import { useEffect, useMemo, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
@ -51,21 +54,33 @@ const PolicySelect = ({ onSelect, selectedPolicies }: PolicySelectProps) => {
return (
<Select
width={300}
style={{
width: "300px",
}}
onSelect={(_, selection) => {
onSelect(selection as PasswordPolicyTypeRepresentation);
setOpen(false);
}}
onToggle={(_event, value) => setOpen(value)}
toggle={(ref) => (
<MenuToggle
ref={ref}
onClick={() => setOpen(!open)}
isExpanded={open}
isDisabled={policies?.length === 0}
data-testid="add-policy"
>
{t("addPolicy")}
</MenuToggle>
)}
isOpen={open}
selections={t("addPolicy")}
isDisabled={policies?.length === 0}
>
{policies?.map((policy) => (
<SelectOption key={policy.id} value={policy}>
{policy.displayName}
</SelectOption>
))}
<SelectList>
{policies?.map((policy) => (
<SelectOption key={policy.id} value={policy}>
{policy.displayName}
</SelectOption>
))}
</SelectList>
</Select>
);
};