V2Wizard: Add search parameter for target selection (HMS-3684)

Add an optional search parameter to the wizard like so:

`/insights/image-builder/imagewizard?target=iso`
or
`/insights/image-builder/imagewizard?target=qcow`

This results in wizard being opened and iso or qcow target being pre-selected. The Insights assistant chat bot will make use of this feature.
This commit is contained in:
regexowl 2024-03-18 09:41:13 +01:00 committed by Lucas Garfield
parent 7c5a040ad7
commit a7cc88af44
2 changed files with 60 additions and 1 deletions

View file

@ -53,6 +53,7 @@ import {
selectGcpShareMethod,
selectImageTypes,
selectRegistrationType,
addImageType,
} from '../../store/wizardSlice';
import { resolveRelPath } from '../../Utilities/path';
import { ImageBuilderHeader } from '../sharedComponents/ImageBuilderHeader';
@ -105,6 +106,10 @@ const CreateImageWizard = ({ startStepIndex = 1 }: CreateImageWizardProps) => {
dispatch(changeDistribution(RHEL_8));
searchParams.get('arch') === AARCH64 &&
dispatch(changeArchitecture(AARCH64));
searchParams.get('target') === 'iso' &&
dispatch(addImageType('image-installer'));
searchParams.get('target') === 'qcow' &&
dispatch(addImageType('guest-image'));
// 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