ImagesTable: add image download link
The new blobby image types are uploaded to aws.s3 for download. Instead of linking to a cloud instance, these image types display a download link.
This commit is contained in:
parent
f1f3c0cd66
commit
59e951653d
3 changed files with 107 additions and 3 deletions
|
|
@ -2,9 +2,15 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { Button, TextContent, Text, TextVariants, Popover } from '@patternfly/react-core';
|
||||
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
|
||||
import { DownloadIcon, ExternalLinkAltIcon } from '@patternfly/react-icons';
|
||||
|
||||
const ImageLink = (props) => {
|
||||
const fileExtensions = {
|
||||
vsphere: '.vmdk',
|
||||
'guest-image': '.qcow2',
|
||||
'image-installer': '.iso',
|
||||
};
|
||||
|
||||
const uploadStatus = props.imageStatus ? props.imageStatus.upload_status : undefined;
|
||||
if (uploadStatus) {
|
||||
if (uploadStatus.type === 'aws') {
|
||||
|
|
@ -78,6 +84,19 @@ const ImageLink = (props) => {
|
|||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
} else if (uploadStatus.type === 'aws.s3') {
|
||||
return (
|
||||
<Button
|
||||
component="a"
|
||||
target="_blank"
|
||||
variant="link"
|
||||
icon={ <DownloadIcon /> }
|
||||
iconPosition="right"
|
||||
isInline
|
||||
href={ uploadStatus.options.url }>
|
||||
Download {fileExtensions[props.imageType]}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +105,7 @@ const ImageLink = (props) => {
|
|||
|
||||
ImageLink.propTypes = {
|
||||
imageStatus: PropTypes.object,
|
||||
imageType: PropTypes.string,
|
||||
uploadOptions: PropTypes.object,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class ImagesTable extends Component {
|
|||
{ title: <ImageBuildStatus status={ compose.image_status ? compose.image_status.status : '' } /> },
|
||||
{ title: <ImageLink
|
||||
imageStatus={ compose.image_status }
|
||||
imageType={ compose.request.image_requests[0].image_type }
|
||||
uploadOptions={ compose.request.image_requests[0].upload_request.options } /> },
|
||||
]
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue