Fedora-services: add support for fedora env

This commit is contained in:
Amir 2025-03-12 19:05:44 +02:00 committed by Klara Simickova
parent 72aed71662
commit 1d86950f45
10 changed files with 111 additions and 45 deletions

View file

@ -21,6 +21,7 @@ import {
useComposeBlueprintMutation,
} from '../../../../../store/imageBuilderApi';
import { selectPackages } from '../../../../../store/wizardSlice';
import { useGetEnvironment } from '../../../../../Utilities/useGetEnvironment';
type CreateDropdownProps = {
getBlueprintPayload: () => Promise<'' | CreateBlueprintRequest | undefined>;
@ -41,11 +42,12 @@ export const CreateSaveAndBuildBtn = ({
fixedCacheKey: 'createBlueprintKey',
});
const dispatch = useAppDispatch();
const { isFedoraEnv } = useGetEnvironment();
const onSaveAndBuild = async () => {
const requestBody = await getBlueprintPayload();
setIsOpen(false);
if (!process.env.IS_ON_PREMISE) {
if (!process.env.IS_ON_PREMISE && !isFedoraEnv) {
analytics.track(`${AMPLITUDE_MODULE_NAME}-blueprintCreated`, {
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
@ -86,6 +88,7 @@ export const CreateSaveButton = ({
}: CreateDropdownProps) => {
const { analytics, isBeta } = useChrome();
const packages = useAppSelector(selectPackages);
const { isFedoraEnv } = useGetEnvironment();
const [createBlueprint, { isLoading }] = useCreateBlueprintMutation({
fixedCacheKey: 'createBlueprintKey',
@ -138,7 +141,7 @@ export const CreateSaveButton = ({
const requestBody = await getBlueprintPayload();
setIsOpen(false);
if (!process.env.IS_ON_PREMISE) {
if (!process.env.IS_ON_PREMISE && !isFedoraEnv) {
analytics.track(`${AMPLITUDE_MODULE_NAME}-blueprintCreated`, {
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
@ -146,13 +149,11 @@ export const CreateSaveButton = ({
packages: packages.map((pkg) => pkg.name),
});
}
const blueprint =
requestBody &&
(await createBlueprint({
createBlueprintRequest: requestBody,
}).unwrap());
if (blueprint) {
dispatch(setBlueprintId(blueprint?.id));
}

View file

@ -20,6 +20,7 @@ import {
useUpdateBlueprintMutation,
} from '../../../../../store/backendApi';
import { resolveRelPath } from '../../../../../Utilities/path';
import { useGetEnvironment } from '../../../../../Utilities/useGetEnvironment';
import { mapRequestFromState } from '../../../utilities/requestMapper';
import { useIsBlueprintValid } from '../../../utilities/useValidation';
@ -33,6 +34,7 @@ const ReviewWizardFooter = () => {
useUpdateBlueprintMutation({ fixedCacheKey: 'updateBlueprintKey' });
const { auth } = useChrome();
const { composeId } = useParams();
const { isFedoraEnv } = useGetEnvironment();
const [isOpen, setIsOpen] = useState(false);
const store = useStore();
const onToggleClick = () => {
@ -50,7 +52,7 @@ const ReviewWizardFooter = () => {
}, [isUpdateSuccess, isCreateSuccess, resetCreate, resetUpdate, navigate]);
const getBlueprintPayload = async () => {
if (!process.env.IS_ON_PREMISE) {
if (!process.env.IS_ON_PREMISE && !isFedoraEnv) {
const userData = await auth?.getUser();
const orgId = userData?.identity?.internal?.org_id;
const requestBody = orgId && mapRequestFromState(store, orgId);

View file

@ -61,7 +61,10 @@ import {
selectUsers,
selectKernel,
} from '../../../../store/wizardSlice';
import { useFlag } from '../../../../Utilities/useGetEnvironment';
import {
useFlag,
useGetEnvironment,
} from '../../../../Utilities/useGetEnvironment';
const Review = () => {
const { goToStepById } = useWizardContext();
@ -196,6 +199,7 @@ const Review = () => {
const isFirstBootEnabled = useFlag('image-builder.firstboot.enabled');
const isUsersEnabled = useFlag('image-builder.users.enabled');
const { isFedoraEnv } = useGetEnvironment();
return (
<>
<ExpandableSection
@ -355,21 +359,23 @@ const Review = () => {
>
<FSCList />
</ExpandableSection>
<ExpandableSection
toggleContent={composeExpandable(
'Content',
'revisit-custom-repositories',
'wizard-custom-repositories'
)}
onToggle={(_event, isExpandedContent) =>
onToggleContent(isExpandedContent)
}
isExpanded={isExpandedContent}
isIndented
data-testid="content-expandable"
>
<ContentList />
</ExpandableSection>
{!isFedoraEnv && (
<ExpandableSection
toggleContent={composeExpandable(
'Content',
'revisit-custom-repositories',
'wizard-custom-repositories'
)}
onToggle={(_event, isExpandedContent) =>
onToggleContent(isExpandedContent)
}
isExpanded={isExpandedContent}
isIndented
data-testid="content-expandable"
>
<ContentList />
</ExpandableSection>
)}
{isUsersEnabled && users.length > 0 && (
<ExpandableSection
toggleContent={composeExpandable(

View file

@ -26,6 +26,7 @@ import {
import { FSReviewTable } from './ReviewStepTables';
import {
FEDORA_RELEASES,
ON_PREM_RELEASES,
RELEASES,
RHEL_8,
@ -80,6 +81,7 @@ import {
selectServices,
} from '../../../../store/wizardSlice';
import { toMonthAndYear, yyyyMMddFormat } from '../../../../Utilities/time';
import { useGetEnvironment } from '../../../../Utilities/useGetEnvironment';
import {
getConversionFactor,
MinimumSizePopover,
@ -100,7 +102,12 @@ const ExpirationWarning = () => {
export const ImageOutputList = () => {
const distribution = useAppSelector(selectDistribution);
const arch = useAppSelector(selectArchitecture);
const releases = process.env.IS_ON_PREMISE ? ON_PREM_RELEASES : RELEASES;
const { isFedoraEnv } = useGetEnvironment();
const releases = isFedoraEnv
? FEDORA_RELEASES
: process.env.IS_ON_PREMISE
? ON_PREM_RELEASES
: RELEASES;
return (
<TextContent>
{distribution === RHEL_8 && (