From 159f12ae1a490cd936f826f4b36ddd4879334fb5 Mon Sep 17 00:00:00 2001 From: Michal Gold Date: Wed, 27 May 2026 12:04:22 +0300 Subject: [PATCH] Wizard: Show Users under Image Overview for on-prem image mode (HMS-4423) In the on-prem image mode wizard, Users are configured under Base Settings. The Review step now mirrors this by showing Users under Image Overview when both isOnPremise and isImageMode are true. For all other cases (hosted, or on-prem package mode), Users remain under Advanced Settings. --- .../components/AdvancedSettings/index.tsx | 11 ++++- .../tests/AdvancedSettings.test.tsx | 16 +++++++ .../Review/components/ImageOverview/index.tsx | 13 +++++- .../tests/ImageOverview.test.tsx | 45 +++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/index.tsx b/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/index.tsx index 4a53d3c908..1be5940f80 100644 --- a/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/index.tsx +++ b/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/index.tsx @@ -2,6 +2,9 @@ import React from 'react'; import { Card, CardBody } from '@patternfly/react-core'; +import { useAppSelector } from '@/store/hooks'; +import { selectIsImageMode, selectIsOnPremise } from '@/store/slices'; + import { Filesystem, Firewall, @@ -33,6 +36,8 @@ const AdvancedSettingsOverview = ({ oscapKernelArgs = [], oscapServices, }: AdvancedSettingsOverviewProps) => { + const isOnPremise = useAppSelector(selectIsOnPremise); + const isImageMode = useAppSelector(selectIsImageMode); return ( - + diff --git a/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/tests/AdvancedSettings.test.tsx b/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/tests/AdvancedSettings.test.tsx index 1ab81d7a0c..2ce27caf37 100644 --- a/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/tests/AdvancedSettings.test.tsx +++ b/src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/tests/AdvancedSettings.test.tsx @@ -901,6 +901,22 @@ echo 'Hello there, General Kenobi!'`; expect(screen.getByText('guest')).toBeInTheDocument(); expect(screen.getAllByText('*****')).toHaveLength(3); }); + + test('does not render users section in on-prem image mode', () => { + renderWithRedux( + , + { + imageTypes: ['guest-image'], + blueprintMode: 'image', + users: [adminUser], + }, + { + preloadedState: { env: { isOnPremise: true } }, + }, + ); + + expect(screen.queryByText('Users')).not.toBeInTheDocument(); + }); }); describe('Firewall', () => { diff --git a/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/index.tsx b/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/index.tsx index f8bf648c85..846e78cbd0 100644 --- a/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/index.tsx +++ b/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/index.tsx @@ -4,6 +4,7 @@ import { Card, CardBody } from '@patternfly/react-core'; import { ON_PREM_RELEASES, RELEASES } from '@/constants'; import { useTargetEnvironmentCategories } from '@/Hooks'; +import { useCustomizationRestrictions } from '@/store/api/distributions'; import { useAppSelector } from '@/store/hooks'; import { selectArchitecture, @@ -18,6 +19,7 @@ import { import { MiscFormats, PrivateClouds, PublicClouds } from './components'; +import { Users } from '../AdvancedSettings/components'; import { ReviewCardHeader, ReviewGroup, ReviewList } from '../shared'; const ImageOverview = () => { @@ -29,8 +31,12 @@ const ImageOverview = () => { const distribution = useAppSelector(selectDistribution); const arch = useAppSelector(selectArchitecture); + const environments = useAppSelector(selectImageTypes); const { publicClouds, privateClouds, miscFormats } = - useTargetEnvironmentCategories(useAppSelector(selectImageTypes)); + useTargetEnvironmentCategories(environments); + const { restrictions } = useCustomizationRestrictions({ + selectedImageTypes: environments, + }); const releases = isOnPremise ? ON_PREM_RELEASES : RELEASES; @@ -70,6 +76,11 @@ const ImageOverview = () => { + diff --git a/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/tests/ImageOverview.test.tsx b/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/tests/ImageOverview.test.tsx index 060783dbd1..bc8eedae9c 100644 --- a/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/tests/ImageOverview.test.tsx +++ b/src/Components/CreateImageWizard/steps/Review/components/ImageOverview/tests/ImageOverview.test.tsx @@ -5,6 +5,7 @@ import { screen } from '@testing-library/react'; import { RHEL_10, X86_64 } from '@/constants'; import { renderWithRedux } from '@/test/testUtils'; +import { adminUser } from '../../AdvancedSettings/tests/mocks'; import ImageOverview from '../index'; describe('ImageOverview', () => { @@ -230,4 +231,48 @@ describe('ImageOverview', () => { ).not.toBeInTheDocument(); }); }); + + describe('Users', () => { + test('displays users section in on-prem image mode', () => { + renderWithRedux( + , + { + imageTypes: ['guest-image'], + blueprintMode: 'image', + users: [adminUser], + }, + { + preloadedState: { env: { isOnPremise: true } }, + }, + ); + + expect(screen.getByText('Users')).toBeInTheDocument(); + expect(screen.getByText('admin')).toBeInTheDocument(); + }); + + test('does not display users section in hosted mode', () => { + renderWithRedux(, { + imageTypes: ['guest-image'], + users: [adminUser], + }); + + expect(screen.queryByText('Users')).not.toBeInTheDocument(); + }); + + test('does not display users section in on-prem package mode', () => { + renderWithRedux( + , + { + imageTypes: ['guest-image'], + blueprintMode: 'package', + users: [adminUser], + }, + { + preloadedState: { env: { isOnPremise: true } }, + }, + ); + + expect(screen.queryByText('Users')).not.toBeInTheDocument(); + }); + }); });