V2Wizard: Make useHas<target>TargetOnly hook re-usable

This refines `useHasIsoTargetOnly` hook into `useHasSpecificTargetOnly` hook which takes an image type as an argument and can be re-used for non-iso targets as well.
This commit is contained in:
regexowl 2024-05-28 14:40:50 +02:00 committed by Sanne Raymaekers
parent a8112410b6
commit f48bfd7c21
3 changed files with 10 additions and 9 deletions

View file

@ -8,12 +8,12 @@ import FileSystemPartition from './FileSystemPartition';
import { useAppSelector } from '../../../../store/hooks';
import { selectFileSystemPartitionMode } from '../../../../store/wizardSlice';
import { useHasIsoTargetOnly } from '../../utilities/hasIsoTargetOnly';
import { useHasSpecificTargetOnly } from '../../utilities/hasSpecificTargetOnly';
export type FileSystemPartitionMode = 'automatic' | 'manual';
const FileSystemStep = () => {
const fileSystemPartitionMode = useAppSelector(selectFileSystemPartitionMode);
const hasIsoTargetOnly = useHasIsoTargetOnly();
const hasIsoTargetOnly = useHasSpecificTargetOnly('image-installer');
return (
<Form>

View file

@ -1,7 +0,0 @@
import { useAppSelector } from '../../../store/hooks';
import { selectImageTypes } from '../../../store/wizardSlice';
export const useHasIsoTargetOnly = () => {
const environments = useAppSelector(selectImageTypes);
return environments.length === 1 && environments.includes('image-installer');
};

View file

@ -0,0 +1,8 @@
import { useAppSelector } from '../../../store/hooks';
import { ImageTypes } from '../../../store/imageBuilderApi';
import { selectImageTypes } from '../../../store/wizardSlice';
export const useHasSpecificTargetOnly = (target: ImageTypes) => {
const environments = useAppSelector(selectImageTypes);
return environments.length === 1 && environments.includes(target);
};