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.
This commit is contained in:
parent
b2255de04e
commit
978237bf84
8 changed files with 96 additions and 64 deletions
|
|
@ -222,6 +222,7 @@ function commonRequestToState(
|
|||
return {
|
||||
details: {
|
||||
blueprintName: request.name || '',
|
||||
isCustomName: true,
|
||||
blueprintDescription: request.description || '',
|
||||
},
|
||||
users:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,6 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/hooks';
|
||||
import { Distributions, ImageRequest } from '../../../store/imageBuilderApi';
|
||||
import {
|
||||
changeBlueprintName,
|
||||
selectArchitecture,
|
||||
selectBlueprintName,
|
||||
selectDistribution,
|
||||
} from '../../../store/wizardSlice';
|
||||
|
||||
const generateDefaultName = (
|
||||
export const generateDefaultName = (
|
||||
distribution: Distributions,
|
||||
arch: ImageRequest['architecture']
|
||||
) => {
|
||||
|
|
@ -24,19 +15,3 @@ const generateDefaultName = (
|
|||
|
||||
return `${distribution}-${arch}-${dateTimeString}`;
|
||||
};
|
||||
|
||||
export const useGenerateDefaultName = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const blueprintName = useAppSelector(selectBlueprintName);
|
||||
const distribution = useAppSelector(selectDistribution);
|
||||
const arch = useAppSelector(selectArchitecture);
|
||||
|
||||
useEffect(() => {
|
||||
if (!blueprintName) {
|
||||
dispatch(changeBlueprintName(generateDefaultName(distribution, arch)));
|
||||
}
|
||||
// This useEffect hook should run *only* on mount and therefore has an empty
|
||||
// dependency array. eslint's exhaustive-deps rule does not support this use.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue