V2Wizard: Move targets to a constant

This moves mapping between target short and full names to the const to make it reusable.
This commit is contained in:
regexowl 2024-06-10 14:20:01 +02:00 committed by Klara Simickova
parent b09e82f492
commit 388069ec11
4 changed files with 38 additions and 32 deletions

View file

@ -27,6 +27,7 @@ import {
} from './ReviewStepTextLists'; } from './ReviewStepTextLists';
import isRhel from '../../../../../src/Utilities/isRhel'; import isRhel from '../../../../../src/Utilities/isRhel';
import { targetOptions } from '../../../../constants';
import { useAppSelector } from '../../../../store/hooks'; import { useAppSelector } from '../../../../store/hooks';
import { import {
selectBlueprintDescription, selectBlueprintDescription,
@ -143,20 +144,24 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
{environments.includes('oci') && <TargetEnvOciList />} {environments.includes('oci') && <TargetEnvOciList />}
{environments.includes('vsphere') && ( {environments.includes('vsphere') && (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>VMware vSphere (.vmdk)</Text> <Text component={TextVariants.h3}>
{targetOptions.vsphere} (.vmdk)
</Text>
<TargetEnvOtherList /> <TargetEnvOtherList />
</TextContent> </TextContent>
)} )}
{environments.includes('vsphere-ova') && ( {environments.includes('vsphere-ova') && (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>VMware vSphere (.ova)</Text> <Text component={TextVariants.h3}>
{targetOptions['vsphere-ova']} (.ova)
</Text>
<TargetEnvOtherList /> <TargetEnvOtherList />
</TextContent> </TextContent>
)} )}
{environments.includes('guest-image') && ( {environments.includes('guest-image') && (
<TextContent> <TextContent>
<Text component={TextVariants.h3}> <Text component={TextVariants.h3}>
Virtualization - Guest image (.qcow2) {targetOptions['guest-image']} (.qcow2)
</Text> </Text>
<TargetEnvOtherList /> <TargetEnvOtherList />
</TextContent> </TextContent>
@ -164,7 +169,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
{environments.includes('image-installer') && ( {environments.includes('image-installer') && (
<TextContent> <TextContent>
<Text component={TextVariants.h3}> <Text component={TextVariants.h3}>
Bare metal - Installer (.iso) {targetOptions['image-installer']} (.iso)
</Text> </Text>
<TargetEnvOtherList /> <TargetEnvOtherList />
</TextContent> </TextContent>
@ -172,7 +177,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => {
{environments.includes('wsl') && ( {environments.includes('wsl') && (
<TextContent> <TextContent>
<Text component={TextVariants.h3}> <Text component={TextVariants.h3}>
WSL - Windows Subsystem for Linux (.tar.gz) WSL - {targetOptions.wsl} (.tar.gz)
</Text> </Text>
<TargetEnvOtherList /> <TargetEnvOtherList />
</TextContent> </TextContent>

View file

@ -29,6 +29,7 @@ import {
RHEL_8_FULL_SUPPORT, RHEL_8_FULL_SUPPORT,
RHEL_8_MAINTENANCE_SUPPORT, RHEL_8_MAINTENANCE_SUPPORT,
RHEL_9, RHEL_9,
targetOptions,
UNIT_GIB, UNIT_GIB,
} from '../../../../constants'; } from '../../../../constants';
import { useListSnapshotsByDateMutation } from '../../../../store/contentSourcesApi'; import { useListSnapshotsByDateMutation } from '../../../../store/contentSourcesApi';
@ -221,7 +222,7 @@ export const TargetEnvAWSList = () => {
return ( return (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>AWS</Text> <Text component={TextVariants.h3}>{targetOptions.aws}</Text>
<TextList component={TextListVariants.dl}> <TextList component={TextListVariants.dl}>
<TextListItem <TextListItem
component={TextListItemVariants.dt} component={TextListItemVariants.dt}
@ -263,7 +264,7 @@ export const TargetEnvGCPList = () => {
const email = useAppSelector(selectGcpEmail); const email = useAppSelector(selectGcpEmail);
return ( return (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>GCP</Text> <Text component={TextVariants.h3}>{targetOptions.gcp}</Text>
<TextList component={TextListVariants.dl}> <TextList component={TextListVariants.dl}>
<TextListItem <TextListItem
component={TextListItemVariants.dt} component={TextListItemVariants.dt}
@ -326,7 +327,7 @@ export const TargetEnvAzureList = () => {
return ( return (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>Microsoft Azure</Text> <Text component={TextVariants.h3}>{targetOptions.azure}</Text>
<TextList component={TextListVariants.dl}> <TextList component={TextListVariants.dl}>
<TextListItem <TextListItem
component={TextListItemVariants.dt} component={TextListItemVariants.dt}
@ -383,7 +384,7 @@ export const TargetEnvAzureList = () => {
export const TargetEnvOciList = () => { export const TargetEnvOciList = () => {
return ( return (
<TextContent> <TextContent>
<Text component={TextVariants.h3}>Oracle Cloud Infrastructure</Text> <Text component={TextVariants.h3}>{targetOptions.oci}</Text>
<TextList component={TextListVariants.dl}> <TextList component={TextListVariants.dl}>
<TextListItem <TextListItem
component={TextListItemVariants.dt} component={TextListItemVariants.dt}

View file

@ -2,30 +2,10 @@ import React from 'react';
import { Skeleton } from '@patternfly/react-core'; import { Skeleton } from '@patternfly/react-core';
import { import { targetOptions } from '../../constants';
ImageTypes, import { useGetComposeClonesQuery } from '../../store/imageBuilderApi';
useGetComposeClonesQuery,
} from '../../store/imageBuilderApi';
import { ComposesResponseItem } from '../../store/imageBuilderApi'; import { ComposesResponseItem } from '../../store/imageBuilderApi';
const targetOptions: { [key in ImageTypes]: string } = {
aws: 'Amazon Web Services',
azure: 'Microsoft Azure',
'edge-commit': 'Edge Commit',
'edge-installer': 'Edge Installer',
gcp: 'Google Cloud Platform',
'guest-image': 'Virtualization - Guest image',
'image-installer': 'Bare metal - Installer',
vsphere: 'VMware vSphere',
'vsphere-ova': 'VMware vSphere',
wsl: 'Windows Subsystem for Linux',
ami: 'Amazon Web Services',
'rhel-edge-commit': 'RHEL Edge Commit',
'rhel-edge-installer': 'RHEL Edge Installer',
vhd: '',
oci: 'Oracle Cloud Infrastructure',
};
type TargetPropTypes = { type TargetPropTypes = {
compose: ComposesResponseItem; compose: ComposesResponseItem;
}; };
@ -47,6 +27,6 @@ export const AwsTarget = ({ compose }: AwsTargetPropTypes) => {
return <Skeleton />; return <Skeleton />;
} }
const text = `Amazon Web Services (${data.data.length + 1})`; const text = `${targetOptions.aws} (${data.data.length + 1})`;
return <>{text}</>; return <>{text}</>;
}; };

View file

@ -1,3 +1,5 @@
import { ImageTypes } from './store/imageBuilderApi';
export const IMAGE_BUILDER_API = '/api/image-builder/v1'; export const IMAGE_BUILDER_API = '/api/image-builder/v1';
export const RHSM_API = '/api/rhsm/v2'; export const RHSM_API = '/api/rhsm/v2';
export const EDGE_API = '/api/edge/v1'; export const EDGE_API = '/api/edge/v1';
@ -46,6 +48,24 @@ export const CENTOS_9 = 'centos-9';
export const X86_64 = 'x86_64'; export const X86_64 = 'x86_64';
export const AARCH64 = 'aarch64'; export const AARCH64 = 'aarch64';
export const targetOptions: { [key in ImageTypes]: string } = {
aws: 'Amazon Web Services',
azure: 'Microsoft Azure',
'edge-commit': 'Edge Commit',
'edge-installer': 'Edge Installer',
gcp: 'Google Cloud Platform',
'guest-image': 'Virtualization - Guest image',
'image-installer': 'Bare metal - Installer',
vsphere: 'VMware vSphere',
'vsphere-ova': 'VMware vSphere',
wsl: 'Windows Subsystem for Linux',
ami: 'Amazon Web Services',
'rhel-edge-commit': 'RHEL Edge Commit',
'rhel-edge-installer': 'RHEL Edge Installer',
vhd: '',
oci: 'Oracle Cloud Infrastructure',
};
export const UNIT_KIB = 1024 ** 1; export const UNIT_KIB = 1024 ** 1;
export const UNIT_MIB = 1024 ** 2; export const UNIT_MIB = 1024 ** 2;
export const UNIT_GIB = 1024 ** 3; export const UNIT_GIB = 1024 ** 3;