External license as "toggleable feature" 44/122044/8
authormarine <marine.de.dorlodot@intl.att.com>
Fri, 18 Jun 2021 15:51:46 +0000 (17:51 +0200)
committerMichael Morris <michael.morris@est.tech>
Mon, 5 Jul 2021 08:45:12 +0000 (08:45 +0000)
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 <sebastien.determe@intl.att.com>
Change-Id: I01690c4cb44d3df590987bb340e8fbb58fe960e0
Signed-off-by: marine <marine.de.dorlodot@intl.att.com>
common-be/src/main/java/org/openecomp/sdc/be/togglz/ToggleableFeature.java
common-be/src/main/java/org/openecomp/sdc/be/togglz/TogglzConfiguration.java
openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/features.properties.erb [new file with mode: 0644]
openecomp-be/dist/sdc-onboard-backend-docker/artifacts/startup.sh
openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js
openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx
openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js

index bc60eb9..7cd5bbd 100644 (file)
@@ -25,7 +25,7 @@ import org.togglz.core.annotation.Label;
 import org.togglz.core.context.FeatureContext;
 
 public enum ToggleableFeature implements Feature {
-    @Label("Default Feature") DEFAULT_FEATURE, @Label("Healing") HEALING;
+    @Label("Default Feature") DEFAULT_FEATURE, @Label("Healing") HEALING, @Label("External License") EXTERNAL_LICENSE;
 
     public static Feature getFeatureByName(String featureName) {
         return Arrays.stream(values()).filter(e -> e.name().equals(featureName)).findFirst().orElse(null);
index 9278b4f..9f5b486 100644 (file)
@@ -29,7 +29,10 @@ import org.togglz.core.user.UserProvider;
 
 public class TogglzConfiguration implements TogglzConfig {
 
-    private static final String TOGGLZ_FILE_LOCATION = "/tmp/features.properties";
+    private String togglzFileLocation;
+    public TogglzConfiguration(){
+        this.togglzFileLocation = System.getProperty("features.properties","/tmp/features.properties");
+    }
 
     @Override
     public Class<? extends Feature> getFeatureClass() {
@@ -38,7 +41,7 @@ public class TogglzConfiguration implements TogglzConfig {
 
     @Override
     public StateRepository getStateRepository() {
-        return new FileBasedStateRepository(new File(TOGGLZ_FILE_LOCATION));
+        return new FileBasedStateRepository(new File(togglzFileLocation));
     }
 
     @Override
index cb8d392..1cd2ed2 100644 (file)
@@ -70,3 +70,11 @@ template "ExternalTestingConfiguration" do
       :EP2_CONFIG => node['EXTTEST']['ep2_config']
    })
 end
+
+template "FeaturesProperties" do
+   path "#{ENV['JETTY_BASE']}/config/onboarding-be/features.properties"
+   source "features.properties.erb"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
+   mode "0755"
+end
diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/features.properties.erb b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/features.properties.erb
new file mode 100644 (file)
index 0000000..1f87ee2
--- /dev/null
@@ -0,0 +1 @@
+EXTERNAL_LICENSE=true
\ No newline at end of file
index 7381d50..dc68d6f 100644 (file)
@@ -6,6 +6,7 @@ JAVA_OPTIONS="$JAVA_OPTIONS \
             -Dlog.home=$JETTY_BASE/logs \
             -Dlogback.configurationFile=$JETTY_BASE/config/onboarding-be/logback.xml \
             -Dconfiguration.yaml=$JETTY_BASE/config/onboarding-be/onboarding_configuration.yaml \
+            -Dfeatures.properties=$JETTY_BASE/config/onboarding-be/features.properties \
             -Dconfig.location=$JETTY_BASE/config/onboarding-be/."
 
 cd $JETTY_BASE
index 5dc0aab..fa136f2 100644 (file)
@@ -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,
index f5cd4c6..3e320c4 100644 (file)
@@ -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
+                                        }
                                     />
                                 </div>
                             </div>
@@ -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 (
+            <div
+                className="missing-license clickable"
+                onClick={event =>
+                    licenceChange(
+                        event,
+                        currentSoftwareProduct,
+                        onLicenseChange
+                    )
+                }>
+                <SVGIcon color="warning" name="exclamationTriangleFull" />
+                <div className="warning-text">{i18n('Missing')}</div>
+            </div>
+        );
+    }
+    return <div>{currentSoftwareProduct.licenseAgreementName}</div>;
+};
+
+const LicenseAgreement = ({
+    licenceChange,
+    currentSoftwareProduct,
+    onLicenseChange,
+    externalLicenceEnabled
+}) => {
+    if (externalLicenceEnabled) {
+        return (
+            <LicenseAgreementWithExternal
+                licenceChange={licenceChange}
+                currentSoftwareProduct={currentSoftwareProduct}
+                onLicenseChange={onLicenseChange}
+            />
+        );
+    } else {
+        return (
+            <LicenseAgreementWithoutExternal
+                licenceChange={licenceChange}
+                currentSoftwareProduct={currentSoftwareProduct}
+                onLicenseChange={onLicenseChange}
+            />
+        );
+    }
+};
+
 export default SoftwareProductLandingPageView;
index 3928a3d..ff36101 100644 (file)
@@ -95,7 +95,8 @@ describe('Software Product Landing Page: ', function () {
                const params = {
                        ...currentScreen.props,
                        currentSoftwareProduct,
-                       componentsList: VSPComponentsFactory.buildList(2)
+                       componentsList: VSPComponentsFactory.buildList(2),
+                       features: [{name:'EXTERNAL_LICENCE', active: true}]
                };
 
                const store = storeCreator();
@@ -111,7 +112,8 @@ describe('Software Product Landing Page: ', function () {
                const params = {
                        ...currentScreen.props,
                        currentSoftwareProduct,
-                       componentsList: VSPComponentsFactory.buildList(2)
+                       componentsList: VSPComponentsFactory.buildList(2),
+                       features: [{name:'EXTERNAL_LICENCE', active: true}]
                };
                const e = { target: {
                        value: 'INTERNAL'
@@ -140,7 +142,8 @@ describe('Software Product Landing Page: ', function () {
                const params = {
                        currentSoftwareProduct,
                        ...currentScreen.props,
-                       componentsList: VSPComponentsFactory.buildList(2)
+                       componentsList: VSPComponentsFactory.buildList(2),
+                       features: [{name:'EXTERNAL_LICENCE', active: true}]
                };
 
                const store = storeCreator();
@@ -167,7 +170,8 @@ describe('Software Product Landing Page: ', function () {
                        componentsList: VSPComponentsFactory.buildList(2),
                        onUploadConfirmation:  dummyFunc,
                        onUpload: dummyFunc,
-                       onInvalidFileSizeUpload: dummyFunc
+                       onInvalidFileSizeUpload: dummyFunc,
+                       features: [{name:'EXTERNAL_LICENCE', active: true}]
                };
 
                const files = [
@@ -210,7 +214,8 @@ describe('Software Product Landing Page: ', function () {
                        componentsList: VSPComponentsFactory.buildList(2),
                        onUploadConfirmation:  dummyFunc,
                        onUpload: dummyFunc,
-                       onInvalidFileSizeUpload: dummyFunc
+                       onInvalidFileSizeUpload: dummyFunc,
+                       features: [{name:'EXTERNAL_LICENCE', active: true}]
                };
 
                const store = storeCreator();