Skip to content

Commit b9e8fee

Browse files
kingsleyzissouregexowl
authored andcommitted
multi: remove dummy 'image-mode' distribution
Now that hosted and on-prem share a unified approach to image mode builds (via the bootc field and a proper getDistributions query), the 'image-mode' dummy distribution is no longer needed. This removes the IMAGE_MODE constant, asDistribution/isImageMode type guards, and the 'image-mode' union from all types. The on-prem getArchitectures endpoint now uses the hosted GetArchitecturesApiArg directly, and toComposerComposeRequest clears the distribution based on the bootc field rather than matching a magic string.
1 parent e806d5e commit b9e8fee

35 files changed

Lines changed: 307 additions & 217 deletions

src/Components/CreateImageWizard/steps/ImageOutput/components/BlueprintMode.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
selectDistribution,
2323
selectIsImageMode,
2424
} from '@/store/slices/wizard';
25-
import { asDistribution } from '@/store/typeGuards';
2625
import { getHostDistro } from '@/Utilities/getHostInfo';
2726

2827
const BlueprintMode = () => {
@@ -40,11 +39,9 @@ const BlueprintMode = () => {
4039
const fetchDefaultDistro = async () => {
4140
try {
4241
const distro = await getHostDistro();
43-
setDefaultDistro(asDistribution(distro as Distributions));
42+
setDefaultDistro(distro as Distributions);
4443
} catch {
4544
// defaultDistro remains RHEL_10
46-
// this is fine since image-mode is
47-
// limited to RHEL_10 for now
4845
}
4946
};
5047

@@ -81,14 +78,12 @@ const BlueprintMode = () => {
8178
isSelected={isImageMode}
8279
onChange={() => {
8380
if (!isOnPremise) {
84-
previousDistro.current = distribution as Distributions;
81+
previousDistro.current = distribution;
8582
previousArch.current = architecture;
8683
}
8784
dispatch(changeBlueprintMode('image'));
8885
dispatch(changeImageTypes([]));
89-
if (isOnPremise) {
90-
dispatch(changeDistribution('image-mode'));
91-
} else {
86+
if (!isOnPremise) {
9287
dispatch(changeArchitecture(X86_64));
9388
dispatch(changeImageSource(RHEL_10_IMAGE_MODE_IMAGE));
9489
}

src/Components/CreateImageWizard/steps/ImageOutput/tests/BlueprintMode.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ describe('BlueprintMode', () => {
103103
expect(store.getState().wizard.blueprintMode).toBe('image');
104104
});
105105

106-
test('updates distribution when switching to image mode', async () => {
106+
test('does not change distribution when switching to image mode', async () => {
107107
const { store } = renderBlueprintMode();
108108
const user = createUser();
109+
const distributionBefore = store.getState().wizard.distribution;
109110

110111
await toggleBlueprintMode(user, 'image');
111112

112-
expect(store.getState().wizard.distribution).toBe('image-mode');
113+
expect(store.getState().wizard.distribution).toBe(distributionBefore);
113114
});
114115

115116
test('updates store when switching to package mode', async () => {

src/Components/CreateImageWizard/steps/ImageOutput/tests/ImageSourceSelect.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React from 'react';
33
import { screen, waitFor } from '@testing-library/react';
44
import { vi } from 'vitest';
55

6-
import { IMAGE_MODE } from '@/constants';
76
import {
87
selectDistribution,
98
selectImageSource as selectImageSourceState,
@@ -39,7 +38,6 @@ vi.mock('@/store/api/backend', async (importOriginal) => {
3938

4039
const renderHostedImageSourceSelect = () => {
4140
return renderWithRedux(<ImageSourceSelect />, {
42-
distribution: IMAGE_MODE,
4341
blueprintMode: 'image',
4442
});
4543
};

src/Components/CreateImageWizard/steps/ImageOutput/tests/helpers.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import { screen } from '@testing-library/react';
44

5-
import { IMAGE_MODE, RHEL_10 } from '@/constants';
5+
import { RHEL_10 } from '@/constants';
66
import {
77
clickWithWait,
88
renderWithRedux,
@@ -136,7 +136,6 @@ export const renderImageSourceSelect = (
136136
return renderWithRedux(
137137
<ImageSourceSelect />,
138138
{
139-
distribution: IMAGE_MODE,
140139
blueprintMode: 'image',
141140
...wizardStateOverrides,
142141
},

src/Components/CreateImageWizard/steps/Kernel/components/KernelArguments.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
selectDistribution,
1515
selectKernel,
1616
} from '@/store/slices/wizard';
17-
import { asDistribution } from '@/store/typeGuards';
1817

1918
const KernelArguments = () => {
2019
const kernelAppend = useAppSelector(selectKernel).append;
@@ -26,7 +25,7 @@ const KernelArguments = () => {
2625

2726
const { data: oscapProfileInfo } = useGetOscapCustomizationsQuery(
2827
{
29-
distribution: asDistribution(release),
28+
distribution: release,
3029
// @ts-ignore if complianceProfileID is undefined the query is going to get skipped, so it's safe here to ignore the linter here
3130
profile: complianceProfileID,
3231
},

src/Components/CreateImageWizard/steps/Locale/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
selectLocaleLangpackCandidates,
1313
selectVerifiedLocaleLangpacks,
1414
} from '@/store/slices/wizard';
15-
import { asDistribution } from '@/store/typeGuards';
1615

1716
import KeyboardDropDown from './components/KeyboardDropDown';
1817
import LanguagesDropDown from './components/LanguagesDropDown';
@@ -23,7 +22,7 @@ const LocaleStep = () => {
2322
const candidateLangpacks = useAppSelector(selectLocaleLangpackCandidates);
2423
const { data: distroRepositories, isLoading: isArchitecturesLoading } =
2524
useGetArchitecturesQuery({
26-
distribution: asDistribution(distribution),
25+
distribution: distribution,
2726
});
2827

2928
const distroUrls = useMemo(() => {

src/Components/CreateImageWizard/steps/Oscap/components/PolicySelector.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
setCompliancePolicy,
2727
setOscapProfile,
2828
} from '@/store/slices/wizard';
29-
import { asDistribution } from '@/store/typeGuards';
3029

3130
import { useSelectorHandlers } from './useSelectorHandlers';
3231

@@ -74,9 +73,7 @@ type PolicySelectorProps = {
7473
const PolicySelector = ({ isDisabled = false }: PolicySelectorProps) => {
7574
const policyID = useAppSelector(selectCompliancePolicyID);
7675
const policyTitle = useAppSelector(selectCompliancePolicyTitle);
77-
const release = removeBetaFromRelease(
78-
asDistribution(useAppSelector(selectDistribution)),
79-
);
76+
const release = removeBetaFromRelease(useAppSelector(selectDistribution));
8077
const majorVersion = release.split('-')[1];
8178
const dispatch = useAppDispatch();
8279
const [isOpen, setIsOpen] = useState(false);

src/Components/CreateImageWizard/steps/Oscap/components/ProfileDetails.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import {
2121
selectComplianceProfileID,
2222
selectDistribution,
2323
} from '@/store/slices/wizard';
24-
import { asDistribution } from '@/store/typeGuards';
2524

2625
import { removeBetaFromRelease } from '../removeBetaFromRelease';
2726

2827
const ProfileDetails = (): JSX.Element => {
2928
const releaseRaw = useAppSelector(selectDistribution);
30-
const release = removeBetaFromRelease(asDistribution(releaseRaw));
29+
const release = removeBetaFromRelease(releaseRaw);
3130
const profileID = useAppSelector(selectComplianceProfileID);
3231

3332
const { data, isFetching, error } = useGetOscapCustomizationsQuery(

src/Components/CreateImageWizard/steps/Oscap/components/ProfileSelector.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
selectDistribution,
3636
setOscapProfile,
3737
} from '@/store/slices/wizard';
38-
import { asDistribution } from '@/store/typeGuards';
3938

4039
import { useSelectorHandlers } from './useSelectorHandlers';
4140

@@ -63,9 +62,7 @@ const ProfileSelector = ({
6362
}: ProfileSelectorProps) => {
6463
const isOnPremise = useAppSelector(selectIsOnPremise);
6564
const profileID = useAppSelector(selectComplianceProfileID);
66-
const release = removeBetaFromRelease(
67-
asDistribution(useAppSelector(selectDistribution)),
68-
);
65+
const release = removeBetaFromRelease(useAppSelector(selectDistribution));
6966
const dispatch = useAppDispatch();
7067
const [isOpen, setIsOpen] = useState(false);
7168
const [inputValue, setInputValue] = useState<string>('');

src/Components/CreateImageWizard/steps/Oscap/components/SecurityInformation.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
selectDistribution,
2727
selectFips,
2828
} from '@/store/slices/wizard';
29-
import { asDistribution } from '@/store/typeGuards';
3029

3130
export const SecurityInformation = (): JSX.Element => {
3231
const release = useAppSelector(selectDistribution);
@@ -44,7 +43,7 @@ export const SecurityInformation = (): JSX.Element => {
4443
error: profileError,
4544
} = useGetOscapCustomizationsQuery(
4645
{
47-
distribution: asDistribution(release),
46+
distribution: release,
4847
profile: complianceProfileID as unknown as DistributionProfileItem,
4948
},
5049
{
@@ -59,7 +58,7 @@ export const SecurityInformation = (): JSX.Element => {
5958
error: complianceError,
6059
} = useGetComplianceCustomizationsQuery(
6160
{
62-
distribution: asDistribution(release),
61+
distribution: release,
6362
policy: compliancePolicyID!,
6463
},
6564
{

0 commit comments

Comments
 (0)