Skip to content

Commit aa8e4f9

Browse files
committed
Wizard: Show Users under Base Settings in image mode
Users are configured in Base Settings when in image mode (cockpit-image-builder), but the Review step always displayed them under Advanced Settings. Show Users under Image Overview in image mode, and keep them under Advanced Settings in package mode.
1 parent 64fc1c6 commit aa8e4f9

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

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

Lines changed: 5 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 } from '@/store/slices';
7+
58
import {
69
Filesystem,
710
Firewall,
@@ -33,6 +36,7 @@ const AdvancedSettingsOverview = ({
3336
oscapKernelArgs = [],
3437
oscapServices,
3538
}: AdvancedSettingsOverviewProps) => {
39+
const isImageMode = useAppSelector(selectIsImageMode);
3640
return (
3741
<Card>
3842
<ReviewCardHeader
@@ -54,7 +58,7 @@ const AdvancedSettingsOverview = ({
5458
oscapServices={oscapServices}
5559
/>
5660
<Firewall shouldHide={restrictions.firewall.shouldHide} />
57-
<Users shouldHide={restrictions.users.shouldHide} />
61+
{!isImageMode && <Users shouldHide={restrictions.users.shouldHide} />}
5862
<Firstboot shouldHide={restrictions.firstBoot.shouldHide} />
5963
</ReviewList>
6064
</CardBody>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,19 @@ 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 image mode', () => {
906+
renderWithRedux(
907+
<AdvancedSettingsOverview restrictions={createDefaultRestrictions()} />,
908+
{
909+
imageTypes: ['guest-image'],
910+
blueprintMode: 'image',
911+
users: [adminUser],
912+
},
913+
);
914+
915+
expect(screen.queryByText('Users')).not.toBeInTheDocument();
916+
});
904917
});
905918

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

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

Lines changed: 8 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,7 @@ const ImageOverview = () => {
7076
<PrivateClouds environments={privateClouds} />
7177
<PublicClouds environments={publicClouds} />
7278
<MiscFormats environments={miscFormats} />
79+
{isImageMode && <Users shouldHide={restrictions.users.shouldHide} />}
7380
</ReviewList>
7481
</CardBody>
7582
</Card>

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

Lines changed: 24 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,27 @@ describe('ImageOverview', () => {
230231
).not.toBeInTheDocument();
231232
});
232233
});
234+
235+
describe('Users', () => {
236+
test('displays users section in image mode', () => {
237+
renderWithRedux(<ImageOverview />, {
238+
imageTypes: ['guest-image'],
239+
blueprintMode: 'image',
240+
users: [adminUser],
241+
});
242+
243+
expect(screen.getByText('Users')).toBeInTheDocument();
244+
expect(screen.getByText('admin')).toBeInTheDocument();
245+
});
246+
247+
test('does not display users section in package mode', () => {
248+
renderWithRedux(<ImageOverview />, {
249+
imageTypes: ['guest-image'],
250+
blueprintMode: 'package',
251+
users: [adminUser],
252+
});
253+
254+
expect(screen.queryByText('Users')).not.toBeInTheDocument();
255+
});
256+
});
233257
});

0 commit comments

Comments
 (0)