diff --git a/src/Components/ImagesTable/ClonesTable.tsx b/src/Components/ImagesTable/ClonesTable.tsx index 436e1459..165b39cc 100644 --- a/src/Components/ImagesTable/ClonesTable.tsx +++ b/src/Components/ImagesTable/ClonesTable.tsx @@ -5,13 +5,17 @@ import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; import { AwsDetailsStatus, StatusClone } from './Status'; +import { useGetComposeStatusQuery } from '../../store/backendApi'; +import { + CockpitAwsUploadRequestOptions, + CockpitComposesResponseItem, +} from '../../store/cockpit/types'; import { ClonesResponseItem, ComposesResponseItem, UploadStatus, useGetCloneStatusQuery, useGetComposeClonesQuery, - useGetComposeStatusQuery, } from '../../store/imageBuilderApi'; type RowPropTypes = { @@ -42,8 +46,8 @@ const Ami = ({ status }: AmiPropTypes) => { } }; -const ComposeRegion = () => { - return

us-east-1

; +const ComposeRegion = ({ region }: { region?: string | undefined }) => { + return

{region || 'us-east-1'}

; }; type CloneRegionPropTypes = { @@ -98,17 +102,27 @@ const CloneRow = ({ clone }: CloneRowPropTypes) => { }; type ComposeRowPropTypes = { - compose: ComposesResponseItem; + compose: ComposesResponseItem | CockpitComposesResponseItem; }; const ComposeRow = ({ compose }: ComposeRowPropTypes) => { const { data, isSuccess } = useGetComposeStatusQuery({ composeId: compose.id, }); + + const region = !process.env.IS_ON_PREMISE + ? 'us-east-1' + : // since this is on-premise, we know the type casting + // is okay to do here. + ( + compose.request.image_requests[0].upload_request + .options as CockpitAwsUploadRequestOptions + ).region; + return isSuccess ? ( } - region={} + region={} status={} /> ) : null; diff --git a/src/Components/ImagesTable/Status.tsx b/src/Components/ImagesTable/Status.tsx index 80f1bdf6..7d0dba19 100644 --- a/src/Components/ImagesTable/Status.tsx +++ b/src/Components/ImagesTable/Status.tsx @@ -32,6 +32,7 @@ import { OCI_STORAGE_EXPIRATION_TIME_IN_DAYS, } from '../../constants'; import { useGetComposeStatusQuery } from '../../store/backendApi'; +import { CockpitComposesResponseItem } from '../../store/cockpit/types'; import { ClonesResponseItem, ComposesResponseItem, @@ -70,7 +71,7 @@ export const StatusClone = ({ clone, status }: StatusClonePropTypes) => { }; type ComposeStatusPropTypes = { - compose: ComposesResponseItem; + compose: ComposesResponseItem | CockpitComposesResponseItem; }; export const AwsDetailsStatus = ({ compose }: ComposeStatusPropTypes) => { diff --git a/src/Components/ImagesTable/Target.tsx b/src/Components/ImagesTable/Target.tsx index 9d6c50de..33a7dea5 100644 --- a/src/Components/ImagesTable/Target.tsx +++ b/src/Components/ImagesTable/Target.tsx @@ -17,15 +17,20 @@ type AwsTargetPropTypes = { compose: ComposesResponseItem; }; -export const AwsTarget = ({ compose }: AwsTargetPropTypes) => { - const { data, isSuccess } = useGetComposeClonesQuery({ - composeId: compose.id, - }); +export const AwsTarget = process.env.IS_ON_PREMISE + ? // we don't need to clone composes for on-prem + // since we can upload directly to the desired + // region + () => <>{targetOptions.aws} + : ({ compose }: AwsTargetPropTypes) => { + const { data, isSuccess } = useGetComposeClonesQuery({ + composeId: compose.id, + }); - if (!isSuccess) { - return ; - } + if (!isSuccess) { + return ; + } - const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`; - return <>{text}; -}; + const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`; + return <>{text}; + };