From 3453264c35275af52a2fdcde33f6e8347a65d15b Mon Sep 17 00:00:00 2001 From: marine Date: Fri, 18 Jun 2021 17:51:46 +0200 Subject: External license as "toggleable feature" Code modification in onboarding BE and onboarding UI so that the External License can be seen as a toggleable feature. By default this will set to true but could be disabled. Issue-ID: SDC-3618 Signed-off-by: sebdet Change-Id: I01690c4cb44d3df590987bb340e8fbb58fe960e0 Signed-off-by: marine --- .../landingPage/SoftwareProductLandingPage.js | 2 + .../landingPage/SoftwareProductLandingPageView.jsx | 77 +++++++++++++++++++++- 2 files changed, 76 insertions(+), 3 deletions(-) (limited to 'openecomp-ui/src/sdc-app/onboarding') diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js index 5dc0aab0d7..fa136f2f1b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js @@ -24,6 +24,7 @@ import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import VNFImportActionHelper from '../vnfMarketPlace/VNFImportActionHelper.js'; export const mapStateToProps = ({ + features, softwareProduct, licenseModel: { licenseAgreement }, currentScreen: { itemPermission: { isCertified } } @@ -63,6 +64,7 @@ export const mapStateToProps = ({ fullCategoryDisplayName = `${subCategoryName} (${categoryName})`; return { + features, currentSoftwareProduct: { ...currentSoftwareProduct, licenseAgreementName, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx index f5cd4c6e71..3e320c4a24 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx @@ -23,6 +23,7 @@ import Configuration from 'sdc-app/config/Configuration.js'; import DraggableUploadFileBox from 'nfvo-components/fileupload/DraggableUploadFileBox.jsx'; import VnfRepositorySearchBox from 'nfvo-components/vnfMarketPlace/VnfRepositorySearchBox.jsx'; +import { SVGIcon } from 'onap-ui-react'; import SoftwareProductComponentsList from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js'; const SoftwareProductPropType = PropTypes.shape({ @@ -52,6 +53,13 @@ class SoftwareProductLandingPageView extends React.Component { files: [] }; + constructor(props) { + super(props); + this.getExternalLicenceFeatureState = this.getExternalLicenceFeatureState.bind( + this + ); + } + static propTypes = { currentSoftwareProduct: SoftwareProductPropType, isReadOnlyMode: PropTypes.bool, @@ -76,10 +84,19 @@ class SoftwareProductLandingPageView extends React.Component { } licenceChange = (e, currentSoftwareProduct, onLicenseChange) => { - currentSoftwareProduct.licenseType = e.target.value; + currentSoftwareProduct.licenseType = e.target.value + ? e.target.value + : 'INTERNAL'; onLicenseChange(currentSoftwareProduct); }; + getExternalLicenceFeatureState() { + var licenseFeature = this.props.features.find( + feature => feature.name === 'EXTERNAL_LICENCE' + ); + return licenseFeature ? licenseFeature.active : true; + } + render() { let { currentSoftwareProduct, @@ -115,6 +132,7 @@ class SoftwareProductLandingPageView extends React.Component { } licenceChange={licenceChange} onLicenseChange={onLicenseChange} + externalLicenceEnabled={this.getExternalLicenceFeatureState()} /> {this.renderProductDetails( isManual, @@ -234,7 +252,8 @@ class SoftwareProductLandingPageView extends React.Component { const ProductSummary = ({ currentSoftwareProduct, licenceChange, - onLicenseChange + onLicenseChange, + externalLicenceEnabled }) => { let { name = '', @@ -277,6 +296,9 @@ const ProductSummary = ({ currentSoftwareProduct } onLicenseChange={onLicenseChange} + externalLicenceEnabled={ + externalLicenceEnabled + } /> @@ -292,7 +314,7 @@ const ProductSummary = ({ ); }; -const LicenseAgreement = ({ +const LicenseAgreementWithExternal = ({ licenceChange, currentSoftwareProduct, onLicenseChange @@ -340,4 +362,53 @@ const LicenseAgreement = ({ ); }; +const LicenseAgreementWithoutExternal = ({ + licenceChange, + currentSoftwareProduct, + onLicenseChange +}) => { + if (!currentSoftwareProduct.licenseAgreementName) { + return ( +
+ licenceChange( + event, + currentSoftwareProduct, + onLicenseChange + ) + }> + +
{i18n('Missing')}
+
+ ); + } + return
{currentSoftwareProduct.licenseAgreementName}
; +}; + +const LicenseAgreement = ({ + licenceChange, + currentSoftwareProduct, + onLicenseChange, + externalLicenceEnabled +}) => { + if (externalLicenceEnabled) { + return ( + + ); + } else { + return ( + + ); + } +}; + export default SoftwareProductLandingPageView; -- cgit 1.2.3-korg