Skip to content

Commit

Permalink
Wizard: Swap arch select
Browse files Browse the repository at this point in the history
This replaces deprecated PF4 select with non-deprecated PF5 one.
  • Loading branch information
regexowl committed Feb 18, 2025
1 parent 0c8b6b3 commit e846816
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
35 changes: 27 additions & 8 deletions src/Components/CreateImageWizard/steps/ImageOutput/ArchSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { ReactElement, useState } from 'react';

import { FormGroup } from '@patternfly/react-core';
import {
FormGroup,
MenuToggle,
MenuToggleElement,
Select,
SelectList,
SelectOption,
SelectVariant,
} from '@patternfly/react-core/deprecated';
} from '@patternfly/react-core';

import { ARCHES } from '../../../../constants';
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
Expand Down Expand Up @@ -49,17 +51,34 @@ const ArchSelect = () => {
return options;
};

const onToggleClick = () => {
setIsOpen(!isOpen);
};

const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={onToggleClick}
isExpanded={isOpen}
isFullWidth
data-testid="arch_select"
>
{arch}
</MenuToggle>
);

return (
<FormGroup isRequired={true} label="Architecture">
<Select
ouiaId="arch_select"
variant={SelectVariant.single}
onToggle={() => setIsOpen(!isOpen)}
onSelect={setArch}
selections={arch}
isOpen={isOpen}
selected={arch}
onSelect={setArch}
onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
toggle={toggle}
shouldFocusToggleOnSelect
>
{setSelectOptions()}
<SelectList>{setSelectOptions()}</SelectList>
</Select>
</FormGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ const selectCentos9 = async () => {

const openArchitectureMenu = async () => {
const user = userEvent.setup();
const releaseMenu = screen.getAllByRole('button', {
name: /options menu/i,
})[1];
const releaseMenu = screen.getByTestId('arch_select');
await waitFor(() => user.click(releaseMenu));
};

Expand Down

0 comments on commit e846816

Please sign in to comment.