Table: fix the image table status for on prem aws uploads
We need to make some minor tweaks to get this to show properly for the on-prem frontend.
This commit is contained in:
parent
c88171da19
commit
fe5abaeb45
3 changed files with 36 additions and 16 deletions
|
|
@ -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 <p>us-east-1</p>;
|
||||
const ComposeRegion = ({ region }: { region?: string | undefined }) => {
|
||||
return <p>{region || 'us-east-1'}</p>;
|
||||
};
|
||||
|
||||
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 ? (
|
||||
<Row
|
||||
ami={<Ami status={data?.image_status.upload_status} />}
|
||||
region={<ComposeRegion />}
|
||||
region={<ComposeRegion region={region} />}
|
||||
status={<AwsDetailsStatus compose={compose} />}
|
||||
/>
|
||||
) : null;
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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 <Skeleton />;
|
||||
}
|
||||
if (!isSuccess) {
|
||||
return <Skeleton />;
|
||||
}
|
||||
|
||||
const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`;
|
||||
return <>{text}</>;
|
||||
};
|
||||
const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`;
|
||||
return <>{text}</>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue