From 36fa9cdd9fb26aa3fbd3a1f35b2d8344d1301c11 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Thu, 22 Jul 2021 11:54:07 +0100 Subject: Specify a model while creating a VSP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6ed0a3c979e14c62ecd6488dfd70589df40636e9 Issue-ID: SDC-3656 Signed-off-by: André Schmid --- .../softwareProduct/SoftwareProductActionHelper.js | 20 ++++ .../softwareProduct/SoftwareProductConstants.js | 7 ++ .../softwareProduct/SoftwareProductReducer.js | 7 ++ .../creation/SoftwareProductCreation.js | 13 ++- .../creation/SoftwareProductCreationReducer.js | 13 +++ .../creation/SoftwareProductCreationView.jsx | 126 ++++++++++++++++++--- .../details/SoftwareProductDetailsView.jsx | 22 +++- .../landingPage/SoftwareProductLandingPageView.jsx | 21 +++- 8 files changed, 207 insertions(+), 22 deletions(-) (limited to 'openecomp-ui/src/sdc-app/onboarding') diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index 38600a60b8..29e278f928 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -1,6 +1,7 @@ /*! * Copyright © 2016-2018 European Support Limited * Modifications copyright (c) 2021 Nokia + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,11 +101,17 @@ function baseUrl() { const restPrefix = Configuration.get('restPrefix'); return `${restPrefix}/v1.0/vendor-software-products/`; } + function softwareProductCategoriesUrl() { const restCatalogPrefix = Configuration.get('restCatalogPrefix'); return `${restCatalogPrefix}/v1/categories/resources/`; } +function getModelUrl() { + const restCatalogPrefix = Configuration.get('restCatalogPrefix'); + return `${restCatalogPrefix}/v1/catalog/model/`; +} + function uploadFile(vspId, formData, version) { return RestAPIUtil.post( `${baseUrl()}${vspId}/versions/${ @@ -135,6 +142,7 @@ function putSoftwareProduct({ softwareProduct, version }) { : undefined, icon: softwareProduct.icon, licenseType: softwareProduct.licenseType, + selectedModelList: softwareProduct.selectedModelList, licensingData: getLicensingData(softwareProduct.licensingData) } ); @@ -264,6 +272,17 @@ function fetchSoftwareProductCategories(dispatch) { .catch(() => handleResponse(null)); } +function fetchModelList(dispatch) { + let handleResponse = response => + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_MODELS_LOADED, + modelList: response + }); + RestAPIUtil.fetch(getModelUrl()) + .then(handleResponse) + .catch(() => handleResponse(null)); +} + function loadLicensingData(dispatch, { licenseModelId, licensingVersion }) { return ItemsHelper.fetchVersion({ itemId: licenseModelId, @@ -329,6 +348,7 @@ const SoftwareProductActionHelper = { loadSoftwareProductAssociatedData(dispatch) { fetchSoftwareProductCategories(dispatch); + fetchModelList(dispatch); LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); }, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js index e13225010f..22a11eab5e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js @@ -1,5 +1,6 @@ /*! * Copyright © 2016-2018 European Support Limited + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,7 @@ export const actionTypes = keyMirror( FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED: null, SOFTWARE_PRODUCT_LIST_EDIT: null, SOFTWARE_PRODUCT_CATEGORIES_LOADED: null, + SOFTWARE_PRODUCT_MODELS_LOADED: null, SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE: null, LOAD_LICENSING_VERSIONS_LIST: null, TOGGLE_NAVIGATION_ITEM: null, @@ -43,6 +45,11 @@ export const onboardingMethod = { NETWORK_PACKAGE: 'NetworkPackage' }; +export const ModelOption = { + DEFAULT: 'default', + SELECTED: 'selected' +}; + export const onboardingOriginTypes = { NONE: 'none', ZIP: 'zip', diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index dcec5c683f..06e974c78f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -1,5 +1,6 @@ /*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,6 +161,12 @@ export default combineReducers({ } return state; }, + modelList: (state = [], action) => { + if (action.type === actionTypes.SOFTWARE_PRODUCT_MODELS_LOADED) { + return action.modelList; + } + return state; + }, softwareProductQuestionnaire: createJSONSchemaReducer( PRODUCT_QUESTIONNAIRE ), diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js index 539bc12ca7..cccde7883e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js @@ -1,5 +1,6 @@ /*! * Copyright © 2016-2018 European Support Limited + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +34,11 @@ export const mapStateToProps = ({ archivedSoftwareProductList, softwareProductList, finalizedSoftwareProductList, - softwareProduct: { softwareProductCreation, softwareProductCategories } + softwareProduct: { + softwareProductCreation, + softwareProductCategories, + modelList + } }) => { let { genericFieldInfo, vendorList = [] } = softwareProductCreation; let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); @@ -55,6 +60,7 @@ export const mapStateToProps = ({ softwareProductCategories, finalizedLicenseModelList, vendorList, + modelList: modelList, isFormValid, formReady: softwareProductCreation.formReady, genericFieldInfo, @@ -65,12 +71,13 @@ export const mapStateToProps = ({ export const mapActionsToProps = dispatch => { return { - onDataChanged: (deltaData, formName, customValidations) => + onDataChanged: (deltaData, formName, customValidations) => { ValidationHelper.dataChanged(dispatch, { deltaData, formName, customValidations - }), + }); + }, onCancel: () => SoftwareProductCreationActionHelper.resetData(dispatch), onSubmit: (softwareProduct, usersList) => { SoftwareProductCreationActionHelper.resetData(dispatch); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js index 886037406f..496a251105 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js @@ -1,5 +1,6 @@ /*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,6 +71,18 @@ export default (state = {}, action) => { validations: [ { type: 'requiredChooseOption', data: true } ] + }, + modelOption: { + isValid: true, + errorText: '', + validations: [ + { type: 'requiredChooseOption', data: true } + ] + }, + selectedModelList: { + isValid: true, + errorText: '', + validations: [] } }, showModal: true diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx index e4a9893f61..51e883427a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx @@ -1,5 +1,6 @@ /*! * Copyright © 2016-2018 European Support Limited + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +15,7 @@ * permissions and limitations under the License. */ import React from 'react'; -import PropTypes from 'prop-types'; +import PropTypes, { string } from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; @@ -26,7 +27,11 @@ import { SP_CREATION_FORM_NAME } from './SoftwareProductCreationConstants.js'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; -import { onboardingMethod as onboardingMethodConst } from '../SoftwareProductConstants.js'; +import { + ModelOption, + onboardingMethod as onboardingMethodConst +} from '../SoftwareProductConstants.js'; +import SelectInput from 'nfvo-components/input/SelectInput.jsx'; const SoftwareProductPropType = PropTypes.shape({ id: PropTypes.string, @@ -34,7 +39,8 @@ const SoftwareProductPropType = PropTypes.shape({ description: PropTypes.string, category: PropTypes.string, subCategory: PropTypes.string, - vendorId: PropTypes.string + vendorId: PropTypes.string, + selectedModelList: PropTypes.arrayOf(string) }); class SoftwareProductCreationView extends React.Component { @@ -44,6 +50,7 @@ class SoftwareProductCreationView extends React.Component { softwareProductCategories: PropTypes.array, VSPNames: PropTypes.object, usersList: PropTypes.array, + modelList: PropTypes.array, onDataChanged: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired @@ -56,14 +63,17 @@ class SoftwareProductCreationView extends React.Component { onDataChanged, onCancel, genericFieldInfo, - disableVendor + disableVendor, + modelList } = this.props; let { name, description, vendorId, subCategory, - onboardingMethod + onboardingMethod, + modelOption, + selectedModelList } = data; const vendorList = this.getVendorList(); @@ -193,11 +203,24 @@ class SoftwareProductCreationView extends React.Component { /> - + + + + + + + + )} @@ -235,14 +258,12 @@ class SoftwareProductCreationView extends React.Component { } submit() { - let { - data: softwareProduct, - finalizedLicenseModelList, - usersList - } = this.props; + let { finalizedLicenseModelList, usersList } = this.props; + const softwareProduct = { ...this.props.data }; softwareProduct.vendorName = finalizedLicenseModelList.find( vendor => vendor.id === softwareProduct.vendorId ).name; + delete softwareProduct.modelOption; this.props.onSubmit(softwareProduct, usersList); } @@ -284,7 +305,7 @@ const OnboardingProcedure = ({ genericFieldInfo }) => { return ( - + { + function onSelectChanged(selectedValueList) { + let modelList1 = []; + if (selectedValueList) { + modelList1 = selectedValueList.map(item => item.value); + } + onDataChanged({ selectedModelList: modelList1 }, SP_CREATION_FORM_NAME); + } + + function selectDefaultModel() { + return () => { + onDataChanged( + { modelOption: ModelOption.DEFAULT }, + SP_CREATION_FORM_NAME + ); + onDataChanged({ selectedModelList: [] }, SP_CREATION_FORM_NAME); + }; + } + + return ( + + + + + onDataChanged( + { modelOption: ModelOption.SELECTED }, + SP_CREATION_FORM_NAME + ) + } + type="radio" + data-test-id="model-option-selected" + groupClassName="no-bottom-margin" + /> + + + {modelOption === ModelOption.SELECTED &&
} + {modelOption === ModelOption.SELECTED && ( + ({ + label: model.name, + value: model.name + }))} + onMultiSelectChanged={onSelectChanged} + value={selectedModelList} + clearable={true} + placeholder={i18n('vsp.model.select.label')} + multi + /> + )} + {modelOption === ModelOption.SELECTED &&
} +
+
+ ); +}; + export default SoftwareProductCreationView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx index 7df610a3ec..d24916f663 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -1,5 +1,6 @@ /*! * Copyright © 2016-2018 European Support Limited + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +52,7 @@ class GeneralSection extends React.Component { name: PropTypes.string, description: PropTypes.string, subCategory: PropTypes.string, + selectedModelList: PropTypes.arrayOf(PropTypes.string), softwareProductCategories: PropTypes.array, finalizedLicenseModelList: PropTypes.array, onDataChanged: PropTypes.func.isRequired, @@ -164,6 +166,22 @@ class GeneralSection extends React.Component { ) )} +
+ +
+ {this.props.selectedModelList.length > 0 ? ( +
    + {this.props.selectedModelList.map( + value =>
  • {value}
  • + )} +
+ ) : ( + i18n('model.sdc.label') + )} +
+
this.onSelectSubCategory(args), genericFieldInfo, vendorName, + selectedModelList, isVendorArchived, onArchivedVendorRemove }; 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 0f18a44708..5f208345f7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx @@ -1,5 +1,6 @@ /* * Copyright © 2016-2018 European Support Limited + * Modifications Copyright (C) 2021 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,8 @@ const SoftwareProductPropType = PropTypes.shape({ licenseType: PropTypes.string, status: PropTypes.string, licensingData: PropTypes.object, - validationData: PropTypes.object + validationData: PropTypes.object, + selectedModelList: PropTypes.arrayOf(PropTypes.string) }); const ComponentPropType = PropTypes.shape({ @@ -259,7 +261,8 @@ const ProductSummary = ({ name = '', description = '', vendorName = '', - fullCategoryDisplayName = '' + fullCategoryDisplayName = '', + selectedModelList = [] } = currentSoftwareProduct; return (
@@ -285,6 +288,20 @@ const ProductSummary = ({ {fullCategoryDisplayName}
+
+
{i18n('Model')}
+
+ {selectedModelList.length > 0 ? ( +
    + {selectedModelList.map(value => ( +
  • {value}
  • + ))} +
+ ) : ( + i18n('model.sdc.label') + )} +
+
{i18n('License Agreement')} -- cgit 1.2.3-korg