Skip to content

Commit c6a6d68

Browse files
committed
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.
1 parent b9e8fee commit c6a6d68

4 files changed

Lines changed: 83 additions & 2 deletions

File tree

src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React from 'react';
22

33
import { Card, CardBody } from '@patternfly/react-core';
44

5+
import { useAppSelector } from '@/store/hooks';
6+
import { selectIsImageMode, selectIsOnPremise } from '@/store/slices';
7+
58
import {
69
Filesystem,
710
Firewall,
@@ -33,6 +36,8 @@ const AdvancedSettingsOverview = ({
3336
oscapKernelArgs = [],
3437
oscapServices,
3538
}: AdvancedSettingsOverviewProps) => {
39+
const isOnPremise = useAppSelector(selectIsOnPremise);
40+
const isImageMode = useAppSelector(selectIsImageMode);
3641
return (
3742
<Card>
3843
<ReviewCardHeader
@@ -54,7 +59,11 @@ const AdvancedSettingsOverview = ({
5459
oscapServices={oscapServices}
5560
/>
5661
<Firewall shouldHide={restrictions.firewall.shouldHide} />
57-
<Users shouldHide={restrictions.users.shouldHide} />
62+
<Users
63+
shouldHide={
64+
restrictions.users.shouldHide || (isOnPremise && isImageMode)
65+
}
66+
/>
5867
<Firstboot shouldHide={restrictions.firstBoot.shouldHide} />
5968
</ReviewList>
6069
</CardBody>

src/Components/CreateImageWizard/steps/Review/components/AdvancedSettings/tests/AdvancedSettings.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,22 @@ echo 'Hello there, General Kenobi!'`;
901901
expect(screen.getByText('guest')).toBeInTheDocument();
902902
expect(screen.getAllByText('*****')).toHaveLength(3);
903903
});
904+
905+
test('does not render users section in on-prem image mode', () => {
906+
renderWithRedux(
907+
<AdvancedSettingsOverview restrictions={createDefaultRestrictions()} />,
908+
{
909+
imageTypes: ['guest-image'],
910+
blueprintMode: 'image',
911+
users: [adminUser],
912+
},
913+
{
914+
preloadedState: { env: { isOnPremise: true } },
915+
},
916+
);
917+
918+
expect(screen.queryByText('Users')).not.toBeInTheDocument();
919+
});
904920
});
905921

906922
describe('Firewall', () => {

src/Components/CreateImageWizard/steps/Review/components/ImageOverview/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Card, CardBody } from '@patternfly/react-core';
44

55
import { ON_PREM_RELEASES, RELEASES } from '@/constants';
66
import { useTargetEnvironmentCategories } from '@/Hooks';
7+
import { useCustomizationRestrictions } from '@/store/api/distributions';
78
import { useAppSelector } from '@/store/hooks';
89
import {
910
selectArchitecture,
@@ -18,6 +19,7 @@ import {
1819

1920
import { MiscFormats, PrivateClouds, PublicClouds } from './components';
2021

22+
import { Users } from '../AdvancedSettings/components';
2123
import { ReviewCardHeader, ReviewGroup, ReviewList } from '../shared';
2224

2325
const ImageOverview = () => {
@@ -29,8 +31,12 @@ const ImageOverview = () => {
2931
const distribution = useAppSelector(selectDistribution);
3032
const arch = useAppSelector(selectArchitecture);
3133

34+
const environments = useAppSelector(selectImageTypes);
3235
const { publicClouds, privateClouds, miscFormats } =
33-
useTargetEnvironmentCategories(useAppSelector(selectImageTypes));
36+
useTargetEnvironmentCategories(environments);
37+
const { restrictions } = useCustomizationRestrictions({
38+
selectedImageTypes: environments,
39+
});
3440

3541
const releases = isOnPremise ? ON_PREM_RELEASES : RELEASES;
3642

@@ -70,6 +76,11 @@ const ImageOverview = () => {
7076
<PrivateClouds environments={privateClouds} />
7177
<PublicClouds environments={publicClouds} />
7278
<MiscFormats environments={miscFormats} />
79+
<Users
80+
shouldHide={
81+
restrictions.users.shouldHide || !(isOnPremise && isImageMode)
82+
}
83+
/>
7384
</ReviewList>
7485
</CardBody>
7586
</Card>

src/Components/CreateImageWizard/steps/Review/components/ImageOverview/tests/ImageOverview.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { screen } from '@testing-library/react';
55
import { RHEL_10, X86_64 } from '@/constants';
66
import { renderWithRedux } from '@/test/testUtils';
77

8+
import { adminUser } from '../../AdvancedSettings/tests/mocks';
89
import ImageOverview from '../index';
910

1011
describe('ImageOverview', () => {
@@ -230,4 +231,48 @@ describe('ImageOverview', () => {
230231
).not.toBeInTheDocument();
231232
});
232233
});
234+
235+
describe('Users', () => {
236+
test('displays users section in on-prem image mode', () => {
237+
renderWithRedux(
238+
<ImageOverview />,
239+
{
240+
imageTypes: ['guest-image'],
241+
blueprintMode: 'image',
242+
users: [adminUser],
243+
},
244+
{
245+
preloadedState: { env: { isOnPremise: true } },
246+
},
247+
);
248+
249+
expect(screen.getByText('Users')).toBeInTheDocument();
250+
expect(screen.getByText('admin')).toBeInTheDocument();
251+
});
252+
253+
test('does not display users section in hosted mode', () => {
254+
renderWithRedux(<ImageOverview />, {
255+
imageTypes: ['guest-image'],
256+
users: [adminUser],
257+
});
258+
259+
expect(screen.queryByText('Users')).not.toBeInTheDocument();
260+
});
261+
262+
test('does not display users section in on-prem package mode', () => {
263+
renderWithRedux(
264+
<ImageOverview />,
265+
{
266+
imageTypes: ['guest-image'],
267+
blueprintMode: 'package',
268+
users: [adminUser],
269+
},
270+
{
271+
preloadedState: { env: { isOnPremise: true } },
272+
},
273+
);
274+
275+
expect(screen.queryByText('Users')).not.toBeInTheDocument();
276+
});
277+
});
233278
});

0 commit comments

Comments
 (0)