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 { AwsDetailsStatus, StatusClone } from './Status';
|
||||||
|
|
||||||
|
import { useGetComposeStatusQuery } from '../../store/backendApi';
|
||||||
|
import {
|
||||||
|
CockpitAwsUploadRequestOptions,
|
||||||
|
CockpitComposesResponseItem,
|
||||||
|
} from '../../store/cockpit/types';
|
||||||
import {
|
import {
|
||||||
ClonesResponseItem,
|
ClonesResponseItem,
|
||||||
ComposesResponseItem,
|
ComposesResponseItem,
|
||||||
UploadStatus,
|
UploadStatus,
|
||||||
useGetCloneStatusQuery,
|
useGetCloneStatusQuery,
|
||||||
useGetComposeClonesQuery,
|
useGetComposeClonesQuery,
|
||||||
useGetComposeStatusQuery,
|
|
||||||
} from '../../store/imageBuilderApi';
|
} from '../../store/imageBuilderApi';
|
||||||
|
|
||||||
type RowPropTypes = {
|
type RowPropTypes = {
|
||||||
|
|
@ -42,8 +46,8 @@ const Ami = ({ status }: AmiPropTypes) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ComposeRegion = () => {
|
const ComposeRegion = ({ region }: { region?: string | undefined }) => {
|
||||||
return <p>us-east-1</p>;
|
return <p>{region || 'us-east-1'}</p>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CloneRegionPropTypes = {
|
type CloneRegionPropTypes = {
|
||||||
|
|
@ -98,17 +102,27 @@ const CloneRow = ({ clone }: CloneRowPropTypes) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
type ComposeRowPropTypes = {
|
type ComposeRowPropTypes = {
|
||||||
compose: ComposesResponseItem;
|
compose: ComposesResponseItem | CockpitComposesResponseItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ComposeRow = ({ compose }: ComposeRowPropTypes) => {
|
const ComposeRow = ({ compose }: ComposeRowPropTypes) => {
|
||||||
const { data, isSuccess } = useGetComposeStatusQuery({
|
const { data, isSuccess } = useGetComposeStatusQuery({
|
||||||
composeId: compose.id,
|
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 ? (
|
return isSuccess ? (
|
||||||
<Row
|
<Row
|
||||||
ami={<Ami status={data?.image_status.upload_status} />}
|
ami={<Ami status={data?.image_status.upload_status} />}
|
||||||
region={<ComposeRegion />}
|
region={<ComposeRegion region={region} />}
|
||||||
status={<AwsDetailsStatus compose={compose} />}
|
status={<AwsDetailsStatus compose={compose} />}
|
||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import {
|
||||||
OCI_STORAGE_EXPIRATION_TIME_IN_DAYS,
|
OCI_STORAGE_EXPIRATION_TIME_IN_DAYS,
|
||||||
} from '../../constants';
|
} from '../../constants';
|
||||||
import { useGetComposeStatusQuery } from '../../store/backendApi';
|
import { useGetComposeStatusQuery } from '../../store/backendApi';
|
||||||
|
import { CockpitComposesResponseItem } from '../../store/cockpit/types';
|
||||||
import {
|
import {
|
||||||
ClonesResponseItem,
|
ClonesResponseItem,
|
||||||
ComposesResponseItem,
|
ComposesResponseItem,
|
||||||
|
|
@ -70,7 +71,7 @@ export const StatusClone = ({ clone, status }: StatusClonePropTypes) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
type ComposeStatusPropTypes = {
|
type ComposeStatusPropTypes = {
|
||||||
compose: ComposesResponseItem;
|
compose: ComposesResponseItem | CockpitComposesResponseItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AwsDetailsStatus = ({ compose }: ComposeStatusPropTypes) => {
|
export const AwsDetailsStatus = ({ compose }: ComposeStatusPropTypes) => {
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,20 @@ type AwsTargetPropTypes = {
|
||||||
compose: ComposesResponseItem;
|
compose: ComposesResponseItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AwsTarget = ({ compose }: AwsTargetPropTypes) => {
|
export const AwsTarget = process.env.IS_ON_PREMISE
|
||||||
const { data, isSuccess } = useGetComposeClonesQuery({
|
? // we don't need to clone composes for on-prem
|
||||||
composeId: compose.id,
|
// since we can upload directly to the desired
|
||||||
});
|
// region
|
||||||
|
() => <>{targetOptions.aws}</>
|
||||||
|
: ({ compose }: AwsTargetPropTypes) => {
|
||||||
|
const { data, isSuccess } = useGetComposeClonesQuery({
|
||||||
|
composeId: compose.id,
|
||||||
|
});
|
||||||
|
|
||||||
if (!isSuccess) {
|
if (!isSuccess) {
|
||||||
return <Skeleton />;
|
return <Skeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`;
|
const text = `${targetOptions.aws} (${(data?.data.length ?? 0) + 1})`;
|
||||||
return <>{text}</>;
|
return <>{text}</>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue