ImagesTable: Add expiring/expired status to OCI images

Pre-authenticated requests for the OCI images expire 7 days after creation. This adds "Expires in <x> days" and "Expired" as possible statuses for the OCI images.
This commit is contained in:
regexowl 2023-11-01 14:05:49 +01:00 committed by Klara Simickova
parent 7ec87dfa58
commit 1fd8deec1a
4 changed files with 129 additions and 85 deletions

View file

@ -180,9 +180,11 @@ const getImageProvider = (compose: ComposesResponseItem) => {
type OciInstancePropTypes = {
compose: ComposesResponseItem;
isExpired: boolean;
};
export const OciInstance = ({ compose }: OciInstancePropTypes) => {
export const OciInstance = ({ compose, isExpired }: OciInstancePropTypes) => {
const navigate = useNavigate();
const { data, isSuccess, isFetching, isError } = useGetComposeStatusQuery({
composeId: compose.id,
});
@ -199,79 +201,93 @@ export const OciInstance = ({ compose }: OciInstancePropTypes) => {
);
}
return (
<Popover
position="bottom"
headerContent={<div>Launch an OCI image</div>}
minWidth="30rem"
bodyContent={
<>
<p>
To run the image copy the link below and follow the steps below:
</p>
<List component={ListComponent.ol} type={OrderType.number}>
<ListItem>
Go to &quot;Compute&quot; in Oracle Cloud and choose &quot;Custom
Images&quot;.
</ListItem>
<ListItem>
Click on &quot;Import image&quot;, choose &quot;Import from an
object storage URL&quot;.
</ListItem>
<ListItem>
Choose &quot;Import from an object storage URL&quot; and paste the
URL in the &quot;Object Storage URL&quot; field. The image type
has to be set to QCOW2 and the launch mode should be
paravirtualized.
</ListItem>
</List>
<br />
{isSuccess && (
<ClipboardCopy
hoverTip="Copy"
clickTip="Copied"
variant="inline-compact"
ouiaId="oci-link"
isBlock
>
{options?.url}
</ClipboardCopy>
)}
{isFetching && <Skeleton />}
{isError && (
<Alert
title="The link to launch the image could not be loaded. Please refresh
the page and try again."
variant="danger"
isPlain
isInline
/>
)}
<br />
<Button
component="a"
target="_blank"
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
// TO DO update the link after documentation is up
href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/creating_customized_images_by_using_insights_image_builder/customizing-file-systems-during-the-image-creation"
className="pf-u-pl-0"
>
Read more about launching OCI images
</Button>
</>
}
>
if (isExpired) {
return (
<Button
component="a"
target="_blank"
variant="link"
className="pf-u-p-0 pf-u-font-size-sm"
isDisabled={data?.image_status.status === 'success' ? false : true}
onClick={() => navigate(resolveRelPath(`imagewizard/${compose.id}`))}
isInline
>
Image link
Recreate image
</Button>
</Popover>
);
);
} else {
return (
<Popover
position="bottom"
headerContent={<div>Launch an OCI image</div>}
minWidth="30rem"
bodyContent={
<>
<p>
To run the image copy the link below and follow the steps below:
</p>
<List component={ListComponent.ol} type={OrderType.number}>
<ListItem>
Go to &quot;Compute&quot; in Oracle Cloud and choose &quot;
Custom Images&quot;.
</ListItem>
<ListItem>
Click on &quot;Import image&quot;, choose &quot;Import from an
object storage URL&quot;.
</ListItem>
<ListItem>
Choose &quot;Import from an object storage URL&quot; and paste
the URL in the &quot;Object Storage URL&quot; field. The image
type has to be set to QCOW2 and the launch mode should be
paravirtualized.
</ListItem>
</List>
<br />
{isSuccess && (
<ClipboardCopy
hoverTip="Copy"
clickTip="Copied"
variant="inline-compact"
ouiaId="oci-link"
isBlock
>
{options?.url}
</ClipboardCopy>
)}
{isFetching && <Skeleton />}
{isError && (
<Alert
title="The link to launch the image could not be loaded. Please refresh
the page and try again."
variant="danger"
isPlain
isInline
/>
)}
<br />
<Button
component="a"
target="_blank"
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
// TO DO update the link after documentation is up
href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/creating_customized_images_by_using_insights_image_builder/customizing-file-systems-during-the-image-creation"
className="pf-u-pl-0"
>
Read more about launching OCI images
</Button>
</>
}
>
<Button
variant="link"
className="pf-u-p-0 pf-u-font-size-sm"
isDisabled={data?.image_status.status === 'success' ? false : true}
>
Image link
</Button>
</Popover>
);
}
};
type AwsS3InstancePropTypes = {