wizard: extand steps only if there are values in the step

add condition that check if there is value in Hostname, Locale, Timezone steps
and if there is no value, we dont see the extendable part in review step

FIX ISSUE: (#2718)

after changes when there is no value in Timezone step, we should update
test if we want to see the extendable section
This commit is contained in:
Michal Gold 2025-01-13 15:50:11 +02:00 committed by Klara Simickova
parent 8ddfca0fd7
commit 5a7ce1efee
2 changed files with 49 additions and 35 deletions

View file

@ -46,6 +46,11 @@ import {
selectDistribution,
selectImageTypes,
selectRegistrationType,
selectHostname,
selectLanguages,
selectKeyboard,
selectTimezone,
selectNtpServers,
} from '../../../../store/wizardSlice';
import { useFlag } from '../../../../Utilities/useGetEnvironment';
@ -60,6 +65,11 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
const complianceProfile = useAppSelector(selectComplianceProfileID);
const compliancePolicy = useAppSelector(selectCompliancePolicyID);
const registrationType = useAppSelector(selectRegistrationType);
const hostname = useAppSelector(selectHostname);
const languages = useAppSelector(selectLanguages);
const keyboard = useAppSelector(selectKeyboard);
const timezone = useAppSelector(selectTimezone);
const ntpServers = useAppSelector(selectNtpServers);
const [isExpandedImageOutput, setIsExpandedImageOutput] = useState(true);
const [isExpandedTargetEnvs, setIsExpandedTargetEnvs] = useState(true);
@ -334,41 +344,44 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
<UsersList />
</ExpandableSection>
)}
{isTimezoneEnabled && (
<ExpandableSection
toggleContent={composeExpandable(
'Timezone',
'revisit-timezone',
'wizard-timezone'
)}
onToggle={(_event, isExpandedTimezone) =>
onToggleTimezone(isExpandedTimezone)
}
isExpanded={isExpandedTimezone}
isIndented
data-testid="timezone-expandable"
>
<TimezoneList />
</ExpandableSection>
)}
{isLocaleEnabled && (
<ExpandableSection
toggleContent={composeExpandable(
'Locale',
'revisit-locale',
'wizard-locale'
)}
onToggle={(_event, isExpandedLocale) =>
onToggleLocale(isExpandedLocale)
}
isExpanded={isExpandedLocale}
isIndented
data-testid="locale-expandable"
>
<LocaleList />
</ExpandableSection>
)}
{isHostnameEnabled && (
{isTimezoneEnabled &&
(timezone || (ntpServers && ntpServers.length > 0)) && (
<ExpandableSection
toggleContent={composeExpandable(
'Timezone',
'revisit-timezone',
'wizard-timezone'
)}
onToggle={(_event, isExpandedTimezone) =>
onToggleTimezone(isExpandedTimezone)
}
isExpanded={isExpandedTimezone}
isIndented
data-testid="timezone-expandable"
>
<TimezoneList />
</ExpandableSection>
)}
{isLocaleEnabled &&
((languages && languages.length > 0) ||
(keyboard && keyboard.length > 0)) && (
<ExpandableSection
toggleContent={composeExpandable(
'Locale',
'revisit-locale',
'wizard-locale'
)}
onToggle={(_event, isExpandedLocale) =>
onToggleLocale(isExpandedLocale)
}
isExpanded={isExpandedLocale}
isIndented
data-testid="locale-expandable"
>
<LocaleList />
</ExpandableSection>
)}
{isHostnameEnabled && hostname && (
<ExpandableSection
toggleContent={composeExpandable(
'Hostname',

View file

@ -125,6 +125,7 @@ describe('Step Timezone', () => {
test('revisit step button on Review works', async () => {
await renderCreateMode();
await goToTimezoneStep();
await selectTimezone();
await goToReviewStep();
await clickRevisitButton();
await screen.findByRole('heading', { name: /Timezone/ });