ImagesTable: Instead of the image type show the upload target
Fixes #105
This commit is contained in:
parent
afd0a81236
commit
c325a310a2
4 changed files with 32 additions and 8 deletions
17
src/PresentationalComponents/ImagesTable/Upload.js
Normal file
17
src/PresentationalComponents/ImagesTable/Upload.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const Upload = (props) => {
|
||||
const uploadOptions = {
|
||||
aws: 'Amazon Web Services',
|
||||
azure: 'Microsoft Azure',
|
||||
gcp: 'Google Cloud Platform',
|
||||
};
|
||||
return <>{ uploadOptions[props.uploadType] ? uploadOptions[props.uploadType] : props.uploadType }</>;
|
||||
};
|
||||
|
||||
Upload.propTypes = {
|
||||
uploadType: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Upload;
|
||||
|
|
@ -374,6 +374,7 @@ class CreateImageWizard extends Component {
|
|||
distribution: request.distribution,
|
||||
architecture: request.image_requests[0].architecture,
|
||||
image_type: request.image_requests[0].image_type,
|
||||
upload_type: request.image_requests[0].upload_requests[0].type,
|
||||
};
|
||||
this.props.updateCompose(compose);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { PlusCircleIcon } from '@patternfly/react-icons';
|
|||
|
||||
import ImageBuildStatus from '../../PresentationalComponents/ImagesTable/ImageBuildStatus';
|
||||
import Release from '../../PresentationalComponents/ImagesTable/Release';
|
||||
import Upload from '../../PresentationalComponents/ImagesTable/Upload';
|
||||
|
||||
import api from '../../api.js';
|
||||
|
||||
|
|
@ -67,14 +68,11 @@ class ImagesTable extends Component {
|
|||
|
||||
render() {
|
||||
let { composes } = this.props;
|
||||
const uploadOptions = {
|
||||
aws: 'Amazon Web Services'
|
||||
};
|
||||
const rows = Object.entries(composes).map(([ id, compose ]) => {
|
||||
return {
|
||||
cells: [
|
||||
id,
|
||||
uploadOptions[compose.image_type] ? uploadOptions[compose.image_type] : compose.image_type,
|
||||
{ title: <Upload uploadType={ compose.upload_type } /> },
|
||||
{ title: <Release release={ compose.distribution } /> },
|
||||
{ title: <ImageBuildStatus status={ compose.image_status.status } /> },
|
||||
''
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { screen, render } from '@testing-library/react';
|
|||
import { renderWithReduxRouter } from '../../testUtils';
|
||||
import ImagesTable from '../../../SmartComponents/ImagesTable/ImagesTable';
|
||||
import ImageBuildStatus from '../../../PresentationalComponents/ImagesTable/ImageBuildStatus';
|
||||
import Upload from '../../../PresentationalComponents/ImagesTable/Upload';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
const store = {
|
||||
|
|
@ -17,19 +18,21 @@ const store = {
|
|||
},
|
||||
distribution: 'fedora-31',
|
||||
architecture: 'x86_64',
|
||||
image_type: 'qcow2'
|
||||
image_type: 'ami',
|
||||
upload_type: 'aws',
|
||||
},
|
||||
'61b0effa-c901-4ee5-86b9-2010b47f1b22': {
|
||||
image_status: {
|
||||
status: 'failure',
|
||||
upload_status: {
|
||||
type: 'aws',
|
||||
type: 'gcp',
|
||||
status: 'failure'
|
||||
}
|
||||
},
|
||||
distribution: 'fedora-31',
|
||||
architecture: 'x86_64',
|
||||
image_type: 'qcow2'
|
||||
image_type: 'vhd',
|
||||
upload_type: 'gcp',
|
||||
},
|
||||
'551de6f6-1533-4b46-a69f-7924051f9bc6': {
|
||||
image_status: {
|
||||
|
|
@ -41,7 +44,8 @@ const store = {
|
|||
},
|
||||
distribution: 'fedora-31',
|
||||
architecture: 'x86_64',
|
||||
image_type: 'qcow2'
|
||||
image_type: 'vhd',
|
||||
upload_type: 'azure',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -74,6 +78,10 @@ describe('Images Table', () => {
|
|||
let testElement = document.createElement('testElement');
|
||||
render(<ImageBuildStatus status={ compose.image_status.status } />, { container: testElement });
|
||||
expect(row.cells[3]).toHaveTextContent(testElement.textContent);
|
||||
|
||||
// do the same for the upload/target column
|
||||
render(<Upload uploadType={ compose.upload_type } />, { container: testElement });
|
||||
expect(row.cells[1]).toHaveTextContent(testElement.textContent);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue