From ddc1088c78aeec24da559eae362f2f1eae5007a1 Mon Sep 17 00:00:00 2001 From: Amir Fefer Date: Thu, 3 Aug 2023 13:18:53 +0300 Subject: [PATCH] fix(HMS-2256): enhance wizard first page interface --- .../InstanceTypesSelect.test.js | 4 +- src/Components/InstanceTypesSelect/index.js | 34 ++++----- .../steps/AccountCustomizations/aws.js | 73 +++++++++---------- .../steps/AccountCustomizations/azure.js | 11 ++- .../steps/AccountCustomizations/gcp.js | 71 +++++++++--------- src/Components/RegionsSelect/index.js | 2 +- src/Components/SourcesSelect/index.js | 1 + src/Components/TemplateSelect/index.js | 2 + src/mocks/fixtures/instanceTypes.fixtures.js | 13 ---- 9 files changed, 99 insertions(+), 112 deletions(-) diff --git a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js index c4cb53ad..069392f8 100644 --- a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js +++ b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js @@ -40,8 +40,8 @@ describe('InstanceTypesSelect', () => { await mountSelectAndClick(); const unsupportedInstance = await screen.findByText('t1.nano'); await userEvent.click(unsupportedInstance); - const alert = await screen.findByTestId('unsupported_type_alert'); - expect(alert).toBeDefined(); + const selectWrapper = document.querySelector('[data-ouia-component-id=select_instance_type]'); + expect(selectWrapper).toHaveClass('pf-m-warning'); }); }); }); diff --git a/src/Components/InstanceTypesSelect/index.js b/src/Components/InstanceTypesSelect/index.js index 6b5b7b01..cd65ab43 100644 --- a/src/Components/InstanceTypesSelect/index.js +++ b/src/Components/InstanceTypesSelect/index.js @@ -1,11 +1,11 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Alert, Spinner, Select, SelectOption, TextInput } from '@patternfly/react-core'; +import { Spinner, Select, SelectOption, TextInput } from '@patternfly/react-core'; import { useQuery } from 'react-query'; import { fetchInstanceTypesList } from '../../API'; import { useWizardContext } from '../Common/WizardContext'; -const OPTIONS_PER_SCREEN = 5; +const OPTIONS_PER_SCREEN = 3; const sanitizeSearchValue = (str) => str.replace(/\\+$/, ''); const InstanceTypesSelect = ({ setValidation, architecture }) => { @@ -23,6 +23,9 @@ const InstanceTypesSelect = ({ setValidation, architecture }) => { staleTime: 5 * (60 * 1000), // data is considered fresh for 5 minutes (same as cacheTime) select: (types) => types.filter((type) => type.architecture === architecture), enabled: !!chosenRegion && !!chosenSource, + onError: () => { + setValidation('error'); + }, }); if (!chosenSource || chosenSource === '') { @@ -51,7 +54,7 @@ const InstanceTypesSelect = ({ setValidation, architecture }) => { ...prevState, chosenInstanceType: selection, })); - setValidation('success'); + chosenInstanceType.supported ? setValidation('success') : setValidation('warning'); setIsOpen(false); } }; @@ -96,38 +99,35 @@ const InstanceTypesSelect = ({ setValidation, architecture }) => { }; if (error) { - console.warn('Failed to fetch instance types list'); return ( <> - - ); } if (isLoading) { - return ; + return ; } const types = filteredTypes || instanceTypes; return ( <> - {!isTypeSupported && ( - - )} setIsOpen(openState)} selections={chosenTemplateName} onSelect={onSelect} + maxHeight="180px" placeholderText={templates?.length === 0 ? 'No template found' : 'Select templates'} aria-label="Select templates" clearSelectionsAriaLabel="clear template selection" diff --git a/src/mocks/fixtures/instanceTypes.fixtures.js b/src/mocks/fixtures/instanceTypes.fixtures.js index 1f28d08c..88954d80 100644 --- a/src/mocks/fixtures/instanceTypes.fixtures.js +++ b/src/mocks/fixtures/instanceTypes.fixtures.js @@ -76,19 +76,6 @@ export const azureInstanceTypeList = [ gen_v2: false, }, }, - { - name: 'Standard_B1ls', - vcpus: 1, - cores: 1, - memory_mib: 500, - storage_gb: 4, - supported: false, - architecture: 'x86_64', - azure: { - gen_v1: true, - gen_v2: true, - }, - }, { name: 'Standard_D16ps_v5', vcpus: 16,