debian-image-builder-frontend/src/Components/CreateImageWizard/steps/ImageOutput/index.tsx
Michal Gold 978237bf84 Wizard: Fix blueprint name update on Architecture/Distribution changes
This commit resolves an issue where the blueprint name did not update when the user changed the Architecture or Distribution.
Additionally, it sets an initial value for blueprintName in the WizardSlice.
2025-03-31 16:10:05 -05:00

56 lines
1.8 KiB
TypeScript

import React, { useEffect } from 'react';
import { Text, Form, Title } from '@patternfly/react-core';
import ArchSelect from './ArchSelect';
import CentOSAcknowledgement from './CentOSAcknowledgement';
import ReleaseLifecycle from './ReleaseLifecycle';
import ReleaseSelect from './ReleaseSelect';
import TargetEnvironment from './TargetEnvironment';
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
import {
changeBlueprintName,
selectArchitecture,
selectBlueprintName,
selectDistribution,
selectIsCustomName,
} from '../../../../store/wizardSlice';
import DocumentationButton from '../../../sharedComponents/DocumentationButton';
import { generateDefaultName } from '../../utilities/useGenerateDefaultName';
const ImageOutputStep = () => {
const dispatch = useAppDispatch();
const blueprintName = useAppSelector(selectBlueprintName);
const distribution = useAppSelector(selectDistribution);
const arch = useAppSelector(selectArchitecture);
const isCustomName = useAppSelector(selectIsCustomName);
useEffect(() => {
const defaultName = generateDefaultName(distribution, arch);
if (!isCustomName && blueprintName !== defaultName) {
dispatch(changeBlueprintName(defaultName));
}
}, [dispatch, distribution, arch, isCustomName]);
return (
<Form>
<Title headingLevel="h1" size="xl">
Image output
</Title>
<Text>
Images enables you to create customized blueprints, create custom images
from the blueprints, and push them to target environments
<br />
<DocumentationButton />
</Text>
<ReleaseSelect />
{distribution.match('centos-*') && <CentOSAcknowledgement />}
<ReleaseLifecycle />
<ArchSelect />
<TargetEnvironment />
</Form>
);
};
export default ImageOutputStep;