Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -33,6 +36,8 @@ const AdvancedSettingsOverview = ({
oscapKernelArgs = [],
oscapServices,
}: AdvancedSettingsOverviewProps) => {
const isOnPremise = useAppSelector(selectIsOnPremise);
const isImageMode = useAppSelector(selectIsImageMode);
return (
<Card>
<ReviewCardHeader
Expand All @@ -54,7 +59,11 @@ const AdvancedSettingsOverview = ({
oscapServices={oscapServices}
/>
<Firewall shouldHide={restrictions.firewall.shouldHide} />
<Users shouldHide={restrictions.users.shouldHide} />
<Users
shouldHide={
restrictions.users.shouldHide || (isOnPremise && isImageMode)
}
/>
<Firstboot shouldHide={restrictions.firstBoot.shouldHide} />
</ReviewList>
</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<AdvancedSettingsOverview restrictions={createDefaultRestrictions()} />,
{
imageTypes: ['guest-image'],
blueprintMode: 'image',
users: [adminUser],
},
{
preloadedState: { env: { isOnPremise: true } },
},
);

expect(screen.queryByText('Users')).not.toBeInTheDocument();
});
});

describe('Firewall', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +19,7 @@ import {

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

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

const ImageOverview = () => {
Expand All @@ -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;

Expand Down Expand Up @@ -70,6 +76,11 @@ const ImageOverview = () => {
<PrivateClouds environments={privateClouds} />
<PublicClouds environments={publicClouds} />
<MiscFormats environments={miscFormats} />
<Users
shouldHide={
restrictions.users.shouldHide || !(isOnPremise && isImageMode)
}
/>
</ReviewList>
</CardBody>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -230,4 +231,48 @@ describe('ImageOverview', () => {
).not.toBeInTheDocument();
});
});

describe('Users', () => {
test('displays users section in on-prem image mode', () => {
renderWithRedux(
<ImageOverview />,
{
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(<ImageOverview />, {
imageTypes: ['guest-image'],
users: [adminUser],
});

expect(screen.queryByText('Users')).not.toBeInTheDocument();
});

test('does not display users section in on-prem package mode', () => {
renderWithRedux(
<ImageOverview />,
{
imageTypes: ['guest-image'],
blueprintMode: 'package',
users: [adminUser],
},
{
preloadedState: { env: { isOnPremise: true } },
},
);

expect(screen.queryByText('Users')).not.toBeInTheDocument();
});
});
});
Loading