Allow launch wizard for Azure images
This commit is contained in:
parent
e04be4d6d6
commit
78bc71fe6a
4 changed files with 91 additions and 8 deletions
|
|
@ -1,6 +1,11 @@
|
|||
import 'whatwg-fetch';
|
||||
import { server } from './src/test/mocks/server';
|
||||
|
||||
jest.mock('@unleash/proxy-client-react', () => ({
|
||||
useUnleashContext: () => jest.fn(),
|
||||
useFlag: jest.fn(() => true),
|
||||
}));
|
||||
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
|
|
|||
64
package-lock.json
generated
64
package-lock.json
generated
|
|
@ -18,6 +18,7 @@
|
|||
"@redhat-cloud-services/frontend-components-utilities": "3.3.13",
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@scalprum/react-core": "^0.4.1",
|
||||
"@unleash/proxy-client-react": "^3.5.2",
|
||||
"classnames": "2.3.2",
|
||||
"lodash": "4.17.21",
|
||||
"react": "17.0.2",
|
||||
|
|
@ -4813,6 +4814,14 @@
|
|||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@unleash/proxy-client-react": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@unleash/proxy-client-react/-/proxy-client-react-3.5.2.tgz",
|
||||
"integrity": "sha512-5Y3sfZadCPmJ3xaXrcIlrYeVVYzz7JQF8zDu9x46Ea2uBM7A5lVpYfdoIVkTnuK6xFoPxyByUGHhSNuH24x1bA==",
|
||||
"peerDependencies": {
|
||||
"unleash-proxy-client": "^2.4.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@webassemblyjs/ast": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",
|
||||
|
|
@ -17953,6 +17962,12 @@
|
|||
"integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/tiny-emitter": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tippy.js": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-5.1.2.tgz",
|
||||
|
|
@ -18385,6 +18400,25 @@
|
|||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/unleash-proxy-client": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/unleash-proxy-client/-/unleash-proxy-client-2.4.3.tgz",
|
||||
"integrity": "sha512-ILJIHNSeh7ajHczemNE19Rl3NpVU3voFouYIgWCbJd+OhuJ9elfpuD1LF5yucEJq8AuWKkEM2AzUFFOTiv/2Sw==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-emitter": "^2.1.0",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/unleash-proxy-client/node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
|
|
@ -23071,6 +23105,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@unleash/proxy-client-react": {
|
||||
"version": "3.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@unleash/proxy-client-react/-/proxy-client-react-3.5.2.tgz",
|
||||
"integrity": "sha512-5Y3sfZadCPmJ3xaXrcIlrYeVVYzz7JQF8zDu9x46Ea2uBM7A5lVpYfdoIVkTnuK6xFoPxyByUGHhSNuH24x1bA==",
|
||||
"requires": {}
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",
|
||||
|
|
@ -32874,6 +32914,12 @@
|
|||
"integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",
|
||||
"dev": true
|
||||
},
|
||||
"tiny-emitter": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
||||
"peer": true
|
||||
},
|
||||
"tippy.js": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-5.1.2.tgz",
|
||||
|
|
@ -33193,6 +33239,24 @@
|
|||
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
||||
"dev": true
|
||||
},
|
||||
"unleash-proxy-client": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/unleash-proxy-client/-/unleash-proxy-client-2.4.3.tgz",
|
||||
"integrity": "sha512-ILJIHNSeh7ajHczemNE19Rl3NpVU3voFouYIgWCbJd+OhuJ9elfpuD1LF5yucEJq8AuWKkEM2AzUFFOTiv/2Sw==",
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"tiny-emitter": "^2.1.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"peer": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"@redhat-cloud-services/frontend-components-utilities": "3.3.13",
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@scalprum/react-core": "^0.4.1",
|
||||
"@unleash/proxy-client-react": "^3.5.2",
|
||||
"classnames": "2.3.2",
|
||||
"lodash": "4.17.21",
|
||||
"react": "17.0.2",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import React, { Suspense, useState } from 'react';
|
|||
import { Button } from '@patternfly/react-core';
|
||||
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
|
||||
import { useLoadModule, useScalprum } from '@scalprum/react-core';
|
||||
import { useFlag } from '@unleash/proxy-client-react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
|
|
@ -14,8 +15,10 @@ const getImageProvider = ({ imageType }) => {
|
|||
switch (imageType) {
|
||||
case 'aws' || 'ami':
|
||||
return 'aws';
|
||||
case 'azure':
|
||||
return 'azure';
|
||||
default:
|
||||
'aws';
|
||||
return 'aws';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -35,9 +38,9 @@ const ProvisioningLink = ({ imageId, isExpired, isInClonesTable }) => {
|
|||
);
|
||||
|
||||
const provider = getImageProvider(image);
|
||||
if (!error && image.share_with_sources) {
|
||||
if (!error) {
|
||||
return (
|
||||
<Suspense fallback="loading">
|
||||
<Suspense fallback="loading...">
|
||||
<Button variant="link" isInline onClick={() => openWizard(true)}>
|
||||
Launch
|
||||
</Button>
|
||||
|
|
@ -50,7 +53,7 @@ const ProvisioningLink = ({ imageId, isExpired, isInClonesTable }) => {
|
|||
id: image.id,
|
||||
architecture: image.architecture,
|
||||
provider: provider,
|
||||
sourceId: image.share_with_sources[0],
|
||||
sourceId: image.share_with_sources?.[0],
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -75,6 +78,7 @@ const ImageLink = ({ imageId, isExpired, isInClonesTable }) => {
|
|||
isBeta,
|
||||
getEnvironment,
|
||||
} = useChrome();
|
||||
const azureFeatureFlag = useFlag('provisioning.azure');
|
||||
|
||||
const scalprum = useScalprum();
|
||||
const hasProvisioning =
|
||||
|
|
@ -84,13 +88,22 @@ const ImageLink = ({ imageId, isExpired, isInClonesTable }) => {
|
|||
|
||||
if (!uploadStatus || image.status !== 'success') return null;
|
||||
|
||||
if (
|
||||
hasProvisioning &&
|
||||
(image.imageType === 'aws' || image.imageType === 'ami')
|
||||
) {
|
||||
const provisioningLinkEnabled = (image) => {
|
||||
switch (getImageProvider(image)) {
|
||||
case 'aws':
|
||||
return !!image.share_with_sources;
|
||||
case 'azure':
|
||||
return !!azureFeatureFlag;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if (hasProvisioning && provisioningLinkEnabled(image)) {
|
||||
if (isInClonesTable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ProvisioningLink
|
||||
imageId={image.id}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue