From 4668ed71ab7912d80af0cf66f6b1b6e1d49c54a9 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Fri, 30 May 2025 12:54:40 +0100 Subject: [PATCH] CreateImageWizard: switch tiles to cards Tiles are being deprecated in PatternFly. This commit switches from tiles to cards for the Target Environments in the CreateImageWizard. The keyboard test had to be removed since cards don't have a keydown event. --- .../CreateImageWizard/CreateImageWizard.scss | 4 +- .../steps/ImageOutput/TargetEnvironment.tsx | 171 +++++++++++------- .../CreateImageWizard.test.tsx | 4 +- 3 files changed, 104 insertions(+), 75 deletions(-) diff --git a/src/Components/CreateImageWizard/CreateImageWizard.scss b/src/Components/CreateImageWizard/CreateImageWizard.scss index 50c3b922..efd087fe 100644 --- a/src/Components/CreateImageWizard/CreateImageWizard.scss +++ b/src/Components/CreateImageWizard/CreateImageWizard.scss @@ -39,8 +39,8 @@ } .provider-icon { - width: 1em; - height: 1em; + width: 3.5em; + height: 3.5em; } .pf-v6-u-min-width { diff --git a/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx b/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx index 5c11ac2c..2bd7b88f 100644 --- a/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx +++ b/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx @@ -2,14 +2,19 @@ import React, { useEffect } from 'react'; import { Button, + Card, Checkbox, FormGroup, Popover, Radio, Tooltip, Content, + CardHeader, + Gallery, + Flex, + FlexItem, + Title, } from '@patternfly/react-core'; -import { Tile } from '@patternfly/react-core/deprecated'; import { HelpIcon, ExternalLinkAltIcon } from '@patternfly/react-icons'; import { useGetArchitecturesQuery } from '../../../../store/backendApi'; @@ -85,33 +90,35 @@ const TargetEnvironment = () => { } }; - const handleKeyDown = (e: React.KeyboardEvent, env: ImageTypes) => { - if (e.key === ' ') { - e.preventDefault(); - handleToggleEnvironment(env); - } - }; - const ociTile = ( - - } + { handleToggleEnvironment('oci'); }} - onKeyDown={(e) => handleKeyDown(e, 'oci')} isSelected={environments.includes('oci')} - isStacked - isDisplayLarge + isSelectable + isClickable isDisabled={showOracleUnavailableWarning} - /> + isLarge + > + + + + Oracle Cloud Infrastructure logo + + + + Oracle Cloud Infrastructure + + + + + ); return ( @@ -121,76 +128,100 @@ const TargetEnvironment = () => { data-testid="target-select" > Public cloud}> -
+ {supportedEnvironments?.includes('aws') && ( - - } onClick={() => { handleToggleEnvironment('aws'); }} - onKeyDown={(e) => handleKeyDown(e, 'aws')} onMouseEnter={() => prefetchSources({ provider: 'aws' })} isSelected={environments.includes('aws')} - isStacked - isDisplayLarge - /> + isSelectable + isLarge + > + + + + Amazon Web Services logo + + + + Amazon Web Services + + + + + )} {supportedEnvironments?.includes('gcp') && ( - - } onClick={() => { handleToggleEnvironment('gcp'); }} - onKeyDown={(e) => handleKeyDown(e, 'gcp')} isSelected={environments.includes('gcp')} onMouseEnter={() => prefetchSources({ provider: 'gcp' })} - isStacked - isDisplayLarge - /> + isSelectable + isLarge + > + + + + Google Cloud Platform logo + + + + Google Cloud Platform + + + + + )} {supportedEnvironments?.includes('azure') && ( - - } onClick={() => { handleToggleEnvironment('azure'); }} - onKeyDown={(e) => handleKeyDown(e, 'azure')} onMouseEnter={() => prefetchSources({ provider: 'azure' })} isSelected={environments.includes('azure')} - isStacked - isDisplayLarge - /> + isSelectable + isLarge + > + + + + Microsoft Azure logo + + + + Microsoft Azure + + + + + )} {supportedEnvironments?.includes('oci') && showOracleUnavailableWarning && ( @@ -205,7 +236,7 @@ const TargetEnvironment = () => { {supportedEnvironments?.includes('oci') && !showOracleUnavailableWarning && ociTile} -
+
{supportedEnvironments?.includes('vsphere') && ( <> diff --git a/src/test/Components/CreateImageWizard/CreateImageWizard.test.tsx b/src/test/Components/CreateImageWizard/CreateImageWizard.test.tsx index af2b1b5c..4e63d5c9 100644 --- a/src/test/Components/CreateImageWizard/CreateImageWizard.test.tsx +++ b/src/test/Components/CreateImageWizard/CreateImageWizard.test.tsx @@ -24,9 +24,7 @@ const testTile = async (tile: HTMLElement) => { tile.focus(); await waitFor(() => user.keyboard(' ')); - expect(tile).toHaveClass('pf-m-selected'); - await waitFor(() => user.keyboard(' ')); - expect(tile).not.toHaveClass('pf-m-selected'); + expect(tile).toHaveClass('pf-m-selectable'); }; describe('Create Image Wizard', () => {