ImagesTable: add link to launch uploaded aws image

The images list now contains a link to the ec2 launch wizard for a
successfully uploaded aws image.
This commit is contained in:
Jacob Kozol 2021-05-17 15:57:57 +02:00 committed by Sanne Raymaekers
parent 5261dae56b
commit 7cd775cfb3
3 changed files with 72 additions and 28 deletions

View file

@ -0,0 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@patternfly/react-core';
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
const ImageLink = (props) => {
const uploadStatus = props.imageStatus ? props.imageStatus.upload_status : undefined;
if (uploadStatus && uploadStatus.type === 'aws') {
const url = 'https://console.aws.amazon.com/ec2/v2/home?region=' +
uploadStatus.options.region +
'#LaunchInstanceWizard:ami=' +
uploadStatus.options.ami;
return (
<Button
component="a"
target="_blank"
variant="link"
icon={ <ExternalLinkAltIcon /> }
iconPosition="right"
isInline
href={ url }>
Launch instance
</Button>
);
}
return null;
};
ImageLink.propTypes = {
imageStatus: PropTypes.object,
};
export default ImageLink;

View file

@ -14,6 +14,7 @@ import { ExternalLinkAltIcon, PlusCircleIcon } from '@patternfly/react-icons';
import ImageBuildStatus from './ImageBuildStatus';
import Release from './Release';
import Upload from './Upload';
import ImageLink from './ImageLink';
class ImagesTable extends Component {
constructor(props) {
super(props);
@ -95,6 +96,7 @@ class ImagesTable extends Component {
'Release',
'Target',
'Status',
''
];
// the state.page is not an index so must be reduced by 1 get the starting index
@ -110,6 +112,7 @@ class ImagesTable extends Component {
{ title: <Release release={ compose.request.distribution } /> },
{ title: <Upload uploadType={ compose.request.image_requests[0].upload_request.type } /> },
{ title: <ImageBuildStatus status={ compose.image_status ? compose.image_status.status : '' } /> },
{ title: <ImageLink imageStatus={ compose.image_status } /> },
]
};
});