From 388069ec112688d17c337250a565e124b2a37a4d Mon Sep 17 00:00:00 2001 From: regexowl Date: Mon, 10 Jun 2024 14:20:01 +0200 Subject: [PATCH] V2Wizard: Move targets to a constant This moves mapping between target short and full names to the const to make it reusable. --- .../steps/Review/ReviewStep.tsx | 15 +++++++---- .../steps/Review/ReviewStepTextLists.tsx | 9 ++++--- src/Components/ImagesTable/Target.tsx | 26 +++---------------- src/constants.ts | 20 ++++++++++++++ 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/Components/CreateImageWizardV2/steps/Review/ReviewStep.tsx b/src/Components/CreateImageWizardV2/steps/Review/ReviewStep.tsx index e937c323..89c9401b 100644 --- a/src/Components/CreateImageWizardV2/steps/Review/ReviewStep.tsx +++ b/src/Components/CreateImageWizardV2/steps/Review/ReviewStep.tsx @@ -27,6 +27,7 @@ import { } from './ReviewStepTextLists'; import isRhel from '../../../../../src/Utilities/isRhel'; +import { targetOptions } from '../../../../constants'; import { useAppSelector } from '../../../../store/hooks'; import { selectBlueprintDescription, @@ -143,20 +144,24 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => { {environments.includes('oci') && } {environments.includes('vsphere') && ( - VMware vSphere (.vmdk) + + {targetOptions.vsphere} (.vmdk) + )} {environments.includes('vsphere-ova') && ( - VMware vSphere (.ova) + + {targetOptions['vsphere-ova']} (.ova) + )} {environments.includes('guest-image') && ( - Virtualization - Guest image (.qcow2) + {targetOptions['guest-image']} (.qcow2) @@ -164,7 +169,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => { {environments.includes('image-installer') && ( - Bare metal - Installer (.iso) + {targetOptions['image-installer']} (.iso) @@ -172,7 +177,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => { {environments.includes('wsl') && ( - WSL - Windows Subsystem for Linux (.tar.gz) + WSL - {targetOptions.wsl} (.tar.gz) diff --git a/src/Components/CreateImageWizardV2/steps/Review/ReviewStepTextLists.tsx b/src/Components/CreateImageWizardV2/steps/Review/ReviewStepTextLists.tsx index e227c417..51938df7 100644 --- a/src/Components/CreateImageWizardV2/steps/Review/ReviewStepTextLists.tsx +++ b/src/Components/CreateImageWizardV2/steps/Review/ReviewStepTextLists.tsx @@ -29,6 +29,7 @@ import { RHEL_8_FULL_SUPPORT, RHEL_8_MAINTENANCE_SUPPORT, RHEL_9, + targetOptions, UNIT_GIB, } from '../../../../constants'; import { useListSnapshotsByDateMutation } from '../../../../store/contentSourcesApi'; @@ -221,7 +222,7 @@ export const TargetEnvAWSList = () => { return ( - AWS + {targetOptions.aws} { const email = useAppSelector(selectGcpEmail); return ( - GCP + {targetOptions.gcp} { return ( - Microsoft Azure + {targetOptions.azure} { export const TargetEnvOciList = () => { return ( - Oracle Cloud Infrastructure + {targetOptions.oci} { return ; } - const text = `Amazon Web Services (${data.data.length + 1})`; + const text = `${targetOptions.aws} (${data.data.length + 1})`; return <>{text}; }; diff --git a/src/constants.ts b/src/constants.ts index 97a3bdf1..1f55ec29 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,5 @@ +import { ImageTypes } from './store/imageBuilderApi'; + export const IMAGE_BUILDER_API = '/api/image-builder/v1'; export const RHSM_API = '/api/rhsm/v2'; 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 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_MIB = 1024 ** 2; export const UNIT_GIB = 1024 ** 3;