diff --git a/libs/ui-lib-tests/cypress/support/interceptors.ts b/libs/ui-lib-tests/cypress/support/interceptors.ts index e0799b4fdb..72bd385979 100644 --- a/libs/ui-lib-tests/cypress/support/interceptors.ts +++ b/libs/ui-lib-tests/cypress/support/interceptors.ts @@ -7,7 +7,6 @@ const { day2FlowIds } = fixtures; const allInfraEnvsApiPath = '/api/assisted-install/v2/infra-envs/'; const allClustersApiPath = '/api/assisted-install/v2/clusters/'; -const allOperatorsApiPath = '/api/assisted-install/v2/operators/'; const x86 = 'x86_64'; const arm = 'arm64'; @@ -146,7 +145,6 @@ const mockUISettingsResponse: HttpRequestInterceptor = (req) => { const mockBundlesResponse: HttpRequestInterceptor = (req) => { const fixtureMapping = getScenarioFixtureMapping(); - console.log(fixtureMapping); req.reply(fixtureMapping?.bundles || []); }; @@ -436,7 +434,9 @@ const addAdditionalIntercepts = () => { cy.intercept('GET', '/api/accounts_mgmt/v1/current_account', (req) => { req.reply(fixtures.ocmUserAccount); }); - cy.intercept('GET', `${allOperatorsApiPath}/bundles`, mockBundlesResponse).as('bundles'); + cy.intercept('GET', '/api/assisted-install/v2/operators/bundles*', mockBundlesResponse).as( + 'bundles', + ); cy.intercept('GET', '/api/assisted-install/v2/supported-operators', mockSupportedOperators).as( 'supported-operators', ); diff --git a/libs/ui-lib/lib/common/api/assisted-service/BundleAPI.ts b/libs/ui-lib/lib/common/api/assisted-service/BundleAPI.ts index ac09f87112..a057a28a0e 100644 --- a/libs/ui-lib/lib/common/api/assisted-service/BundleAPI.ts +++ b/libs/ui-lib/lib/common/api/assisted-service/BundleAPI.ts @@ -6,8 +6,21 @@ const BundleAPI = { return `/v2/operators/bundles`; }, - list() { - return client.get(`${BundleAPI.makeBaseURI()}`); + list( + openshiftVersion?: string, + cpuArchitecture?: string, + platformType?: string, + featureIds?: string, + ) { + return client.get(`${BundleAPI.makeBaseURI()}`, { + params: { + openshift_version: openshiftVersion, + cpu_architecture: cpuArchitecture, + platform_type: platformType, + feature_ids: featureIds, + ...(platformType === 'external' ? { external_platform_name: 'oci' } : {}), + }, + }); }, listOperatorsForBundle(bundleName: string) { diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/bundleSpecs.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/bundleSpecs.tsx index 7a86b78462..77d261ac96 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/bundleSpecs.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/operators/bundleSpecs.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { List, ListItem } from '@patternfly/react-core'; export type BundleSpec = { - noSNO?: boolean; incompatibleBundles?: string[]; Description: React.ComponentType; docsLink?: string; @@ -10,7 +9,6 @@ export type BundleSpec = { export const bundleSpecs: { [key: string]: BundleSpec } = { virtualization: { - noSNO: true, Description: () => ( @@ -29,7 +27,6 @@ export const bundleSpecs: { [key: string]: BundleSpec } = { ), }, 'openshift-ai': { - noSNO: true, incompatibleBundles: [], Description: () => ( diff --git a/libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx b/libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx index c1e2958a2e..cb307be5ae 100644 --- a/libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx @@ -87,9 +87,13 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => { //For Assisted Migration we need the LVMs operator and also the virtualization bundle operators if (isAssistedMigration) { params.olmOperators = [{ name: 'lvm' }]; - const selectedBundle = (await BundleService.listBundles()).find( - (b) => b.id === 'virtualization', - ); + const selectedBundle = ( + await BundleService.listBundles( + params.openshiftVersion, + params.cpuArchitecture, + params.platform?.type, + ) + ).find((b) => b.id === 'virtualization'); const virtOperators = selectedBundle?.operators; params.olmOperators = [ ...params.olmOperators, diff --git a/libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsBundle.tsx b/libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsBundle.tsx index 86b05a1fd4..f0d46c89ed 100644 --- a/libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsBundle.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsBundle.tsx @@ -21,8 +21,6 @@ import { ExternalLink, OperatorsValues, PopoverIcon, singleClusterBundles } from import { useFormikContext } from 'formik'; import { useNewFeatureSupportLevel } from '../../../common/components/newFeatureSupportLevels'; import { useFeature } from '../../hooks/use-feature'; -import { useSelector } from 'react-redux'; -import { selectIsCurrentClusterSNO } from '../../store/slices/current-cluster/selectors'; import { getNewBundleOperators } from '../clusterConfiguration/operators/utils'; import { bundleSpecs } from '../clusterConfiguration/operators/bundleSpecs'; import { @@ -84,7 +82,6 @@ const BundleCard = ({ searchTerm?: string; }) => { const { values, setFieldValue } = useFormikContext(); - const isSNO = useSelector(selectIsCurrentClusterSNO); const { isFeatureSupported } = useNewFeatureSupportLevel(); const { byKey: opSpecs } = useOperatorSpecs(); const { uiSettings } = useClusterWizardContext(); @@ -105,16 +102,14 @@ const BundleCard = ({ const isAssistedMigration = uiSettings?.isAssistedMigration; const disabledReason = hasUnsupportedOperators ? 'Some operators in this bundle are not supported with the current configuration.' - : isSNO && bundleSpec?.noSNO - ? bundle.id === 'openshift-ai' - ? 'This bundle is not available when deploying a Single Node OpenShift, but you can use the standalone operator instead.' - : 'This bundle is not available when deploying a Single Node OpenShift.' : incompatibleBundle ? `Bundle cannot be installed together with ${ bundles.find(({ id }) => id === incompatibleBundle)?.title || incompatibleBundle }` : isAssistedMigration ? 'This bundle needs to be selected for clusters created from Migration Assessment' + : !bundles.some((b) => b.id === bundle.id) + ? 'This bundle is not available for the current configuration, you might be able to use the standalone operators instead.' : undefined; const onSelect = (checked: boolean) => { @@ -172,10 +167,12 @@ const BundleCard = ({ const OperatorsBundle = ({ bundles, + allBundles, preflightRequirements, searchTerm, }: { bundles: Bundle[]; + allBundles: Bundle[]; preflightRequirements: PreflightHardwareRequirements | undefined; searchTerm?: string; }) => { @@ -191,8 +188,8 @@ const OperatorsBundle = ({ {(isSingleClusterFeatureEnabled - ? bundles.filter((b) => b.id && singleClusterBundles.includes(b.id)) - : bundles + ? allBundles.filter((b) => b.id && singleClusterBundles.includes(b.id)) + : allBundles ).map((bundle) => ( { const { addAlert } = useAlerts(); const [bundlesLoading, setBundlesLoading] = React.useState(true); const [bundles, setBundles] = React.useState([]); + const [allBundles, setAllBundles] = React.useState([]); const { preflightRequirements, isLoading } = useClusterPreflightRequirements(cluster.id); const [searchTerm, setSearchTerm] = React.useState(''); React.useEffect(() => { const fetchBundles = async () => { try { - const fetchedBundles = await BundleService.listBundles(); + const fetchedBundles = await BundleService.listBundles( + cluster?.openshiftVersion || '', + cluster?.cpuArchitecture || '', + cluster?.platform?.type || '', + cluster?.controlPlaneCount === 1 ? 'SNO' : undefined, + ); + const allBundles = await BundleService.listBundles( + cluster?.openshiftVersion || '', + cluster?.cpuArchitecture || '', + cluster?.platform?.type || '', + undefined, + ); setBundles(fetchedBundles); + setAllBundles(allBundles); } catch (error) { handleApiError(error, () => addAlert({ @@ -38,7 +51,13 @@ export const OperatorsStep = ({ cluster }: ClusterOperatorProps) => { }; void fetchBundles(); - }, [addAlert]); + }, [ + addAlert, + cluster.cpuArchitecture, + cluster.openshiftVersion, + cluster.platform?.type, + cluster.controlPlaneCount, + ]); const filteredBundles = bundles.filter( (bundle) => @@ -75,6 +94,7 @@ export const OperatorsStep = ({ cluster }: ClusterOperatorProps) => { bundles={filteredBundles} preflightRequirements={preflightRequirements} searchTerm={searchTerm} + allBundles={allBundles} /> diff --git a/libs/ui-lib/lib/ocm/services/BundleService.ts b/libs/ui-lib/lib/ocm/services/BundleService.ts index 7e73c9f6ea..7cb10324f0 100644 --- a/libs/ui-lib/lib/ocm/services/BundleService.ts +++ b/libs/ui-lib/lib/ocm/services/BundleService.ts @@ -1,8 +1,18 @@ import BundleAPI from '../../common/api/assisted-service/BundleAPI'; const BundleService = { - async listBundles() { - const { data: bundles } = await BundleAPI.list(); + async listBundles( + openshiftVersion?: string, + cpuArchitecture?: string, + platformType?: string, + featureIds?: string, + ) { + const { data: bundles } = await BundleAPI.list( + openshiftVersion, + cpuArchitecture, + platformType, + featureIds, + ); return bundles; }, async listOperatorsByBundle(bundleName: string) {