From 61070c9c6b665fdea79b3ccdfeafc3a6b50d262e Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Wed, 26 Jul 2017 17:37:57 +0300 Subject: [SDC] Full OnBoard health-check and NFoD support Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv --- .../sdc-app/common/reducers/PlainDataReducer.js | 7 + .../sdc-app/onboarding/OnboardingActionHelper.js | 19 +- .../src/sdc-app/onboarding/OnboardingPunchOut.jsx | 16 +- .../licenseModel/LicenseModelConstants.js | 14 + .../onboarding/licenseModel/LicenseModelReducer.js | 2 + .../licenseModel/LicenseModelValidations.js | 41 +++ .../licenseModel/creation/LicenseModelCreation.js | 2 +- .../EntitlementPoolsActionHelper.js | 84 ++++- .../entitlementPools/EntitlementPoolsConstants.js | 17 +- .../entitlementPools/EntitlementPoolsEditor.js | 17 +- .../EntitlementPoolsEditorReducer.js | 36 +-- .../EntitlementPoolsEditorView.jsx | 346 +++++++++------------ .../entitlementPools/EntitlementPoolsLimits.js | 56 ++++ .../entitlementPools/EntitlementPoolsListEditor.js | 2 +- .../EntitlementPoolsListEditorView.jsx | 15 +- .../featureGroups/FeatureGroupEditor.js | 2 +- .../featureGroups/FeatureGroupEditorView.jsx | 36 ++- .../featureGroups/FeatureGroupListEditorView.jsx | 14 +- .../featureGroups/FeatureGroupsActionHelper.js | 2 + .../featureGroups/FeatureGroupsEditorReducer.js | 8 +- .../licenseAgreement/LicenseAgreementConstants.js | 2 +- .../licenseAgreement/LicenseAgreementEditor.js | 2 +- .../LicenseAgreementEditorReducer.js | 4 +- .../LicenseAgreementEditorView.jsx | 13 +- .../LicenseAgreementListEditorView.jsx | 2 +- .../LicenseKeyGroupsActionHelper.js | 88 +++++- .../licenseKeyGroups/LicenseKeyGroupsConstants.js | 10 +- .../licenseKeyGroups/LicenseKeyGroupsEditor.js | 16 +- .../LicenseKeyGroupsEditorReducer.js | 44 ++- .../LicenseKeyGroupsEditorView.jsx | 254 +++++++++++---- .../licenseKeyGroups/LicenseKeyGroupsLimits.js | 57 ++++ .../licenseKeyGroups/LicenseKeyGroupsListEditor.js | 2 +- .../LicenseKeyGroupsListEditorView.jsx | 14 +- .../onboarding/licenseModel/limits/LimitEditor.js | 25 ++ .../onboarding/licenseModel/limits/LimitEditor.jsx | 193 ++++++++++++ .../licenseModel/limits/LimitEditorActionHelper.js | 30 ++ .../licenseModel/limits/LimitEditorConstants.js | 52 ++++ .../licenseModel/limits/LimitEditorReducer.js | 70 +++++ .../onboarding/licenseModel/limits/Limits.jsx | 108 +++++++ .../onboarding/licenseModel/limits/LimitsServer.js | 46 +++ .../overview/LicenseModelOverviewConstants.js | 8 +- .../overview/LicenseModelOverviewView.jsx | 7 +- .../licenseModel/overview/VLMListView.jsx | 10 +- .../overview/listItems/EntitlementPool.jsx | 24 +- .../overview/listItems/FeatureGroup.jsx | 23 +- .../overview/listItems/LicenseAgreement.jsx | 15 +- .../overview/listItems/LicenseKeyGroup.jsx | 12 +- .../listItems/listItemsComponents/IconCol.jsx | 4 +- .../licenseModel/overview/summary/ListButtons.jsx | 29 +- .../overview/summary/VendorDataView.js | 35 ++- .../onboarding/onboard/CatalogItemDetails.jsx | 2 +- .../onboarding/softwareProduct/SoftwareProduct.js | 12 +- .../softwareProduct/SoftwareProductActionHelper.js | 3 +- .../softwareProduct/SoftwareProductReducer.js | 2 - .../attachments/setup/HeatSetupActionHelper.js | 12 +- .../SoftwareProductComponentsActionHelper.js | 31 +- .../images/SoftwareProductComponentsImageList.js | 3 +- .../SoftwareProductComponentsImageListView.jsx | 4 +- ...twareProductComponentsImageNavigationReducer.js | 32 -- .../SoftwareProductComponentsMonitoringView.jsx | 2 +- .../SoftwareProductComponentsNetworkListView.jsx | 2 +- .../storage/SoftwareProductComponentStorage.js | 7 +- .../SoftwareProductComponentStorageView.jsx | 9 +- .../creation/SoftwareProductCreation.js | 2 +- .../SoftwareProductDependenciesView.jsx | 5 +- .../editor/SoftwareProductDeploymentEditor.js | 2 +- .../details/SoftwareProductDetailsView.jsx | 2 +- 67 files changed, 1529 insertions(+), 538 deletions(-) create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageNavigationReducer.js (limited to 'openecomp-ui/src/sdc-app') diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js index 0bbb5e63be..2276984f7a 100644 --- a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js +++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js @@ -16,6 +16,7 @@ import {actionTypes} from './PlainDataReducerConstants.js'; import Validator from 'nfvo-utils/Validator.js'; import forOwn from 'lodash/forOwn.js'; +import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; function updateDataAndValidateReducer(state = {}, action) { let genericFieldInfoCopy; @@ -46,6 +47,12 @@ function updateDataAndValidateReducer(state = {}, action) { forOwn(state.genericFieldInfo,(value, key) => { let val = state.data && state.data[key] ? state.data[key] : ''; let result = Validator.validate(key, val, state.genericFieldInfo[key].validations, state, {}); + if(val.choice !== undefined) { + result = Validator.validate(key, val.choice, state.genericFieldInfo[key].validations, state, {}); + } + if(val.choice !== undefined && val.choice === optionInputOther.OTHER) { + result = Validator.validate(key, val.other, state.genericFieldInfo[key].validations, state, {}); + } genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText}; if (!result.isValid) { formReady = false; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js index 2b59361eef..dad930127b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js @@ -31,8 +31,7 @@ import OnboardActionHelper from './onboard/OnboardActionHelper.js'; import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; import {actionTypes, enums} from './OnboardingConstants.js'; import SoftwareProductComponentsImageActionHelper from './softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js'; -import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes, - onboardingMethod as onboardingMethodTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import ActivityLogActionHelper from 'sdc-app/common/activity-log/ActivityLogActionHelper.js'; import licenseModelOverviewActionHelper from 'sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js'; import store from 'sdc-app/AppStore.js'; @@ -164,18 +163,10 @@ export default { const newVersion = response[0].version ? response[0].version : version; SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); - let isFetchImageDetails = (response[0].onboardingMethod === onboardingMethodTypes.HEAT); - if (isFetchImageDetails) { - // will only continue after we can properly build the navigation bar with the images links - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion, isFetchImageDetails}).then(() => { - SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion}); - }); - } else { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion, isFetchImageDetails}); - SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion}); - } + + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion}); + SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion}); }); }, diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx index 1f0bef7a9f..aea5fc6406 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx @@ -415,9 +415,9 @@ export default class OnboardingPunchOut { handleStoreChange() { let {currentScreen, licenseModelList, softwareProductList, softwareProduct: {softwareProductEditor: {data = {onboardingMethod: ''}}, - softwareProductComponents: {componentsList, images: {imagesNavigationList}}, softwareProductAttachments: {heatSetup}}} = store.getState(); + softwareProductComponents: {componentsList}, softwareProductAttachments: {heatSetup}}} = store.getState(); let {onboardingMethod} = data; - let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup, imagesNavigationList}; + let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup}; if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { this.prevBreadcrumbsData = breadcrumbsData; this.breadcrumbsPrefixSelected = false; @@ -434,7 +434,7 @@ export default class OnboardingPunchOut { } } - buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, heatSetup, imagesNavigationList}) { + buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, heatSetup}) { let screenToBreadcrumb; switch (screen) { case enums.SCREEN.ONBOARDING_CATALOG: @@ -646,15 +646,7 @@ export default class OnboardingPunchOut { }, { key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, displayText: i18n('Monitoring') - }].filter(item => { - switch (item.key) { - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - return (onboardingMethod === onboardingMethodTypes.MANUAL || - (imagesNavigationList && imagesNavigationList[props.componentId] === true)); - default: - return true; - } - }) + }] }] ]; } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js index 4ba10c3a68..960090c2d8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import keyMirror from 'nfvo-utils/KeyMirror.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; export const actionTypes = keyMirror({ LICENSE_MODEL_LOADED: null, @@ -31,3 +32,16 @@ export const navigationItems = keyMirror({ LICENSE_KEY_GROUPS: 'license-key-groups', ACTIVITY_LOG: 'activity-log' }); + +export const thresholdUnitType = { + ABSOLUTE: 'Absolute', + PERCENTAGE: 'Percentage' +}; + +export const optionsInputValues = { + THRESHOLD_UNITS: [ + {enum: '', title: i18n('please select…')}, + {enum: thresholdUnitType.ABSOLUTE, title: 'Absolute'}, + {enum: thresholdUnitType.PERCENTAGE, title: '%'} + ] +}; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js index bd060a4c28..80beda22b5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js @@ -35,6 +35,7 @@ import licenseKeyGroupsListReducer from './licenseKeyGroups/LicenseKeyGroupsList import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; import {actionTypes as licenseModelOverviewConstants, selectedButton, VLM_DESCRIPTION_FORM} from './overview/LicenseModelOverviewConstants.js'; +import limitEditorReducer from './limits/LimitEditorReducer.js'; export default combineReducers({ licenseModelCreation: createPlainDataReducer(licenseModelCreationReducer), @@ -81,5 +82,6 @@ export default combineReducers({ } } )}), + limitEditor: createPlainDataReducer(limitEditorReducer), activityLog: activityLogReducer }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js new file mode 100644 index 0000000000..64bae3b6a0 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js @@ -0,0 +1,41 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {thresholdUnitType} from './LicenseModelConstants.js'; +import Validator from 'nfvo-utils/Validator.js'; + +export function validateStartDate(value, state) { + if (state.data.expiryDate) { + if (!value) { + return {isValid: false, errorText: i18n('Start date has to be specified if expiry date is specified')}; + } + } + return {isValid: true, errorText: ''}; +} + +export function thresholdValueValidation(value, state) { + let unit = state.data.thresholdUnits; + if (unit === thresholdUnitType.PERCENTAGE) { + return Validator.validate('thresholdValue', value, [ + {type: 'numeric', data: true}, + {type: 'maximum', data: 100}, + {type: 'minimum', data: 0}]); + } else { + return Validator.validate('thresholdValue', value, [ + {type: 'numeric', data: true}, + ]); + } +} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js index d85618c85f..39b3c15c6a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js @@ -26,7 +26,7 @@ export const mapStateToProps = ({licenseModelList, licenseModel: {licenseModelCr let VLMNames = {}; for (let i = 0; i < licenseModelList.length; i++) { - VLMNames[licenseModelList[i].vendorName] = licenseModelList[i].id; + VLMNames[licenseModelList[i].vendorName.toLowerCase()] = licenseModelList[i].id; } return {...licenseModelCreation, isFormValid: isFormValid, VLMNames}; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js index a7c95f608d..a371d5635e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js @@ -17,6 +17,8 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsConstants.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; +import getValue from 'nfvo-utils/getValue.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -28,18 +30,16 @@ function fetchEntitlementPoolsList(licenseModelId, version) { return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } -function postEntitlementPool(licenseModelId, entitlementPool, version) { +function postEntitlementPool(licenseModelId, entitlementPool, version) { return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: entitlementPool.name, description: entitlementPool.description, thresholdValue: entitlementPool.thresholdValue, - thresholdUnits: entitlementPool.thresholdUnits, + thresholdUnits: getValue(entitlementPool.thresholdUnits), entitlementMetric: entitlementPool.entitlementMetric, increments: entitlementPool.increments, - aggregationFunction: entitlementPool.aggregationFunction, - operationalScope: entitlementPool.operationalScope, + operationalScope: getValue(entitlementPool.operationalScope), time: entitlementPool.time, - manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber, startDate: entitlementPool.startDate, expiryDate: entitlementPool.expiryDate }); @@ -47,17 +47,16 @@ function postEntitlementPool(licenseModelId, entitlementPool, version) { function putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool, version) { + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${entitlementPool.id}`, { name: entitlementPool.name, description: entitlementPool.description, thresholdValue: entitlementPool.thresholdValue, - thresholdUnits: entitlementPool.thresholdUnits, + thresholdUnits: getValue(entitlementPool.thresholdUnits), entitlementMetric: entitlementPool.entitlementMetric, increments: entitlementPool.increments, - aggregationFunction: entitlementPool.aggregationFunction, - operationalScope: entitlementPool.operationalScope, + operationalScope: getValue(entitlementPool.operationalScope), time: entitlementPool.time, - manufacturerReferenceNumber: entitlementPool.manufacturerReferenceNumber, startDate: entitlementPool.startDate, expiryDate: entitlementPool.expiryDate }); @@ -67,8 +66,43 @@ function deleteEntitlementPool(licenseModelId, entitlementPoolId, version) { return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}`); } +function fetchLimitsList(licenseModelId, entitlementPoolId, version) { + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits`); +} + +function deleteLimit(licenseModelId, entitlementPoolId, version, limitId) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits/${limitId}`); +} + +function postLimit(licenseModelId, entitlementPoolId, version, limit) { + return RestAPIUtil.post(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits`, { + name: limit.name, + type: limit.type, + description: limit.description, + metric: limit.metric, + value: limit.value, + unit: limit.unit, + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + }); +} + +function putLimit(licenseModelId, entitlementPoolId, version, limit) { + + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits/${limit.id}`, { + name: limit.name, + type: limit.type, + description: limit.description, + metric: limit.metric, + value: limit.value, + unit: limit.unit, + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + }); +} export default { + fetchEntitlementPoolsList(dispatch, {licenseModelId, version}) { return fetchEntitlementPoolsList(licenseModelId, version).then(response => dispatch({ type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_LIST_LOADED, @@ -76,7 +110,10 @@ export default { })); }, - openEntitlementPoolsEditor(dispatch, {entitlementPool} = {}) { + openEntitlementPoolsEditor(dispatch, {entitlementPool, licenseModelId, version} = {}) { + if (licenseModelId && version) { + this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); + } dispatch({ type: entitlementPoolsActionTypes.entitlementPoolsEditor.OPEN, entitlementPool @@ -145,5 +182,32 @@ export default { LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { this.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); }); + }, + + + fetchLimits(dispatch, {licenseModelId, version, entitlementPool}) { + return fetchLimitsList(licenseModelId, entitlementPool.id, version). then (response => { + dispatch({ + type: entitlementPoolsActionTypes.entitlementPoolsEditor.LIMITS_LIST_LOADED, + response + }); + }); + }, + + submitLimit(dispatch, {licenseModelId, version, entitlementPool, limit}) { + const propmise = limit.id ? putLimit(licenseModelId,entitlementPool.id, version, limit) + : postLimit(licenseModelId,entitlementPool.id, version, limit); + return propmise.then(() => { + dispatch({ + type: limitEditorActions.CLOSE + }); + this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); + }); + }, + + deleteLimit(dispatch, {licenseModelId, version, entitlementPool, limit}) { + return deleteLimit(licenseModelId,entitlementPool.id, version, limit.id).then(() => { + this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); + }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js index 761614dfeb..de2a87ceaf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js @@ -15,7 +15,7 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ @@ -28,6 +28,7 @@ export const actionTypes = keyMirror({ OPEN: null, CLOSE: null, DATA_CHANGED: null, + LIMITS_LIST_LOADED: null } }); @@ -94,11 +95,6 @@ export const optionsInputValues = { {enum: 'Units_TB', title: 'Units-TB'}, {enum: 'Units_GB', title: 'Units-GB'}, {enum: 'Units_MB', title: 'Units-MB'} - ], - THRESHOLD_UNITS: [ - {enum: '', title: i18n('please select…')}, - {enum: thresholdUnitType.ABSOLUTE, title: 'Absolute'}, - {enum: thresholdUnitType.PERCENTAGE, title: '%'} ] }; @@ -112,6 +108,11 @@ export const extractUnits = (units) => { return units === 'Absolute' ? '' : '%'; }; -export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; +export const tabIds = { + GENERAL: 'GENERAL', + SP_LIMITS: 'SP_LIMITS', + VENDOR_LIMITS: 'VENDOR_LIMITS', + ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' +}; -export const EP_TIME_FORMAT = 'MM/DD/YYYY'; +export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js index f89cf8fbb5..23c260f793 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js @@ -18,10 +18,12 @@ import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; import EntitlementPoolsEditorView from './EntitlementPoolsEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import LimitEditorActionHelper from '../limits/LimitEditorActionHelper.js'; + const mapStateToProps = ({licenseModel: {entitlementPool}}) => { - let {data, genericFieldInfo, formReady} = entitlementPool.entitlementPoolEditor; + let {data, genericFieldInfo, formReady, limitsList} = entitlementPool.entitlementPoolEditor; let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); @@ -33,7 +35,7 @@ const mapStateToProps = ({licenseModel: {entitlementPool}}) => { const list = entitlementPool.entitlementPoolsList; for (let i = 0; i < list.length; i++) { - EPNames[list[i].name] = list[i].id; + EPNames[list[i].name.toLowerCase()] = list[i].id; } return { @@ -42,7 +44,8 @@ const mapStateToProps = ({licenseModel: {entitlementPool}}) => { previousData, isFormValid, formReady, - EPNames + EPNames, + limitsList }; }; @@ -50,11 +53,13 @@ const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch), - onSubmit: ({previousEntitlementPool, entitlementPool}) => { - EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch); + onSubmit: ({previousEntitlementPool, entitlementPool, keepOpen}) => { + if (!keepOpen) {EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch);} EntitlementPoolsActionHelper.saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool, version}); }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName), + onCloseLimitEditor: () => LimitEditorActionHelper.closeLimitsEditor(dispatch), + onOpenLimitEditor: (limit) => LimitEditorActionHelper.openLimitsEditor(dispatch, {limit}) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js index bc9549765f..be100f6802 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js @@ -41,12 +41,7 @@ export default (state = {}, action) => { 'description' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}] - }, - 'manufacturerReferenceNumber' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 100}] + validations: [{type: 'maxLength', data: 1000}] }, 'increments' : { isValid: true, @@ -56,33 +51,18 @@ export default (state = {}, action) => { 'operationalScope' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}] + validations: [] }, 'thresholdUnits' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}] + validations: [] }, 'thresholdValue' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}] - }, - 'entitlementMetric' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'aggregationFunction' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'time' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, + validations: [] + }, 'startDate': { isValid: true, errorText: '', @@ -106,6 +86,12 @@ export default (state = {}, action) => { }; case actionTypes.entitlementPoolsEditor.CLOSE: return {}; + + case actionTypes.entitlementPoolsEditor.LIMITS_LIST_LOADED: + return { + ...state, + limitsList: action.response.results + }; default: return state; } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx index e4b52fc439..aa1321c24a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx @@ -21,41 +21,39 @@ import Validator from 'nfvo-utils/Validator.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; import Form from 'nfvo-components/input/validation/Form.jsx'; +import Button from 'sdc-ui/lib/react/Button.js'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {optionsInputValues as EntitlementPoolsOptionsInputValues, thresholdUnitType, SP_ENTITLEMENT_POOL_FORM, EP_TIME_FORMAT} from './EntitlementPoolsConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import {optionsInputValues as EntitlementPoolsOptionsInputValues, SP_ENTITLEMENT_POOL_FORM, tabIds} from './EntitlementPoolsConstants.js'; +import {optionsInputValues as LicenseModelOptionsInputValues} from '../LicenseModelConstants.js'; +import {validateStartDate, thresholdValueValidation} from '../LicenseModelValidations.js'; +import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; +import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import Tabs from 'sdc-ui/lib/react/Tabs.js'; +import Tab from 'sdc-ui/lib/react/Tab.js'; +import EntitlementPoolsLimits from './EntitlementPoolsLimits.js'; +import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; const EntitlementPoolPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, - manufacturerReferenceNumber: React.PropTypes.string, operationalScope: React.PropTypes.shape({ choices: React.PropTypes.array, other: React.PropTypes.string }), - aggregationFunction: React.PropTypes.shape({ - choice: React.PropTypes.string, - other: React.PropTypes.string - }), + thresholdUnits: React.PropTypes.string, + thresholdValue: React.PropTypes.number, increments: React.PropTypes.string, - time: React.PropTypes.shape({ - choice: React.PropTypes.string, - other: React.PropTypes.string - }), - entitlementMetric: React.PropTypes.shape({ - choice: React.PropTypes.string, - other: React.PropTypes.string - }) + startDate: React.PropTypes.string, + expiryDate: React.PropTypes.string }); -const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, validateChoiceWithOther, validateTimeOtherValue, +const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, thresholdValueValidation, validateStartDate}) => { - let { - name, description, manufacturerReferenceNumber, operationalScope , aggregationFunction, thresholdUnits, thresholdValue, - increments, time, entitlementMetric, startDate, expiryDate} = data; + let {name, description, operationalScope, thresholdUnits, thresholdValue, + increments, startDate, expiryDate} = data; return ( @@ -73,12 +71,10 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val {}} isMultiSelect={true} - - isRequired={true} onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, - SP_ENTITLEMENT_POOL_FORM, {operationalScope: validateChoiceWithOther})} + SP_ENTITLEMENT_POOL_FORM)} onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], - other: operationalScope}}, SP_ENTITLEMENT_POOL_FORM, {operationalScope: validateChoiceWithOther})} + other: operationalScope}}, SP_ENTITLEMENT_POOL_FORM)} label={i18n('Operational Scope')} data-test-id='create-ep-operational-scope' type='select' @@ -95,21 +91,21 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val errorText={genericFieldInfo.description.errorText} label={i18n('Description')} value={description} - isRequired={true} data-test-id='create-ep-description' type='textarea'/>
{ // setting the unit to the correct value const selectedIndex = e.target.selectedIndex; const val = e.target.options[selectedIndex].value; onDataChanged({thresholdUnits: val}, SP_ENTITLEMENT_POOL_FORM); // TODO make sure that the value is valid too - onDataChanged({thresholdValue: thresholdValue}, SP_ENTITLEMENT_POOL_FORM,{thresholdValue : thresholdValueValidation});} + if(thresholdValue && thresholdValue !== '') { + onDataChanged({thresholdValue: thresholdValue}, SP_ENTITLEMENT_POOL_FORM,{thresholdValue : thresholdValueValidation}); + }} } value={thresholdUnits} @@ -120,7 +116,7 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val groupClassName='bootstrap-input-options' className='input-options-select' type='select' > - {EntitlementPoolsOptionsInputValues.THRESHOLD_UNITS.map(mtype => + {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map(mtype => )} @@ -133,116 +129,46 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val errorText={genericFieldInfo.thresholdValue.errorText} data-test-id='create-ep-threshold-value' value={thresholdValue} - isRequired={true} type='text'/>
- {}} - isMultiSelect={false} - isRequired={true} - onEnumChange={entitlementMetric => onDataChanged({entitlementMetric:{choice: entitlementMetric, other: ''}}, - SP_ENTITLEMENT_POOL_FORM, {entitlementMetric: validateChoiceWithOther})} - onOtherChange={entitlementMetric => onDataChanged({entitlementMetric:{choice: optionInputOther.OTHER, - other: entitlementMetric}}, SP_ENTITLEMENT_POOL_FORM, {entitlementMetric: validateChoiceWithOther})} - label={i18n('Entitlement Metric')} - data-test-id='create-ep-entitlement-metric' - type='select' - required={true} - selectedEnum={entitlementMetric && entitlementMetric.choice} - otherValue={entitlementMetric && entitlementMetric.other} - values={EntitlementPoolsOptionsInputValues.ENTITLEMENT_METRIC} - isValid={genericFieldInfo.entitlementMetric.isValid} - errorText={genericFieldInfo.entitlementMetric.errorText} /> - {}} - isMultiSelect={false} - isRequired={true} - onEnumChange={aggregationFunction => onDataChanged({aggregationFunction:{choice: aggregationFunction, other: ''}}, - SP_ENTITLEMENT_POOL_FORM, {aggregationFunction: validateChoiceWithOther})} - onOtherChange={aggregationFunction => onDataChanged({aggregationFunction:{choice: optionInputOther.OTHER, - other: aggregationFunction}}, SP_ENTITLEMENT_POOL_FORM, {aggregationFunction: validateChoiceWithOther})} - label={i18n('Aggregate Function')} - data-test-id='create-ep-aggregate-function' - type='select' - required={true} - selectedEnum={aggregationFunction && aggregationFunction.choice} - otherValue={aggregationFunction && aggregationFunction.other} - values={EntitlementPoolsOptionsInputValues.AGGREGATE_FUNCTION} - isValid={genericFieldInfo.aggregationFunction.isValid} - errorText={genericFieldInfo.aggregationFunction.errorText} /> -
- - onDataChanged({manufacturerReferenceNumber}, SP_ENTITLEMENT_POOL_FORM)} - label={i18n('Manufacturer Reference Number')} - value={manufacturerReferenceNumber} - isValid={genericFieldInfo.manufacturerReferenceNumber.isValid} - errorText={genericFieldInfo.manufacturerReferenceNumber.errorText} - isRequired={true} - data-test-id='create-ep-reference-number' - type='text'/> - - - {}} - isMultiSelect={false} - isRequired={true} - onEnumChange={time => onDataChanged({time:{choice: time, other: ''}}, - SP_ENTITLEMENT_POOL_FORM, {time: validateChoiceWithOther})} - onOtherChange={time => onDataChanged({time:{choice: optionInputOther.OTHER, - other: time}}, SP_ENTITLEMENT_POOL_FORM, {time: validateTimeOtherValue})} - label={i18n('Time')} - data-test-id='create-ep-time' - type='select' - required={true} - selectedEnum={time && time.choice} - otherValue={time && time.other} - values={EntitlementPoolsOptionsInputValues.TIME} - isValid={genericFieldInfo.time.isValid} - errorText={genericFieldInfo.time.errorText} /> - - onDataChanged({increments}, SP_ENTITLEMENT_POOL_FORM)} label={i18n('Increments')} value={increments} data-test-id='create-ep-increments' type='text'/> - - - - onDataChanged( - {startDate: startDate ? startDate.format(EP_TIME_FORMAT) : ''}, - SP_ENTITLEMENT_POOL_FORM, - {startDate: validateStartDate} - )} - isValid={genericFieldInfo.startDate.isValid} - errorText={genericFieldInfo.startDate.errorText} - selectsStart/> - - - { - onDataChanged({expiryDate: expiryDate ? expiryDate.format(EP_TIME_FORMAT) : ''}, SP_ENTITLEMENT_POOL_FORM); - onDataChanged({startDate}, SP_ENTITLEMENT_POOL_FORM, {startDate: validateStartDate}); - }} - isValid={genericFieldInfo.expiryDate.isValid} - errorText={genericFieldInfo.expiryDate.errorText} - selectsEnd/> - +
+ onDataChanged( + {startDate: startDate ? startDate.format(DATE_FORMAT) : ''}, + SP_ENTITLEMENT_POOL_FORM, + {startDate: validateStartDate} + )} + isValid={genericFieldInfo.startDate.isValid} + errorText={genericFieldInfo.startDate.errorText} + selectsStart/> + { + onDataChanged({expiryDate: expiryDate ? expiryDate.format(DATE_FORMAT) : ''}, SP_ENTITLEMENT_POOL_FORM); + onDataChanged({startDate}, SP_ENTITLEMENT_POOL_FORM, {startDate: validateStartDate}); + }} + isValid={genericFieldInfo.expiryDate.isValid} + errorText={genericFieldInfo.expiryDate.errorText} + selectsEnd/> +
+
); }; @@ -263,42 +189,102 @@ class EntitlementPoolsEditorView extends React.Component { data: {} }; - render() { - let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo} = this.props; + componentDidUpdate(prevProps) { + if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit + this.submit(); + } + } + + state = { + selectedTab: tabIds.GENERAL, + selectedLimit: '' + }; + render() { + let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo, onCloseLimitEditor, limitsList = []} = this.props; + const {selectedTab} = this.state; + const isTabsDisabled = !data.id || !this.props.isFormValid; return (
- { - genericFieldInfo &&
this.submit() } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM) } - className='entitlement-pools-form'> - this.validateName(value)} - validateTimeOtherValue ={(value)=> this.validateTimeOtherValue(value)} - validateChoiceWithOther={(value)=> this.validateChoiceWithOther(value)} - validateStartDate={(value, state)=> this.validateStartDate(value, state)} - thresholdValueValidation={(value, state)=> this.thresholdValueValidation(value, state)}/> - + { + if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { + this.onAddLimit(); + } else { + this.setState({selectedTab: tabIndex}); + this.setState({selectedLimit: ''}); + onCloseLimitEditor(); + } + + }} + invalidTabs={[]}> + + { + genericFieldInfo &&
this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM) } + className='license-model-form entitlement-pools-form'> + this.validateName(value)} + validateStartDate={(value, state) => validateStartDate(value, state)} + thresholdValueValidation={(value, state) => thresholdValueValidation(value, state)}/> + + } +
+ + {selectedTab === tabIds.SP_LIMITS && + item.type === limitType.SERVICE_PROVIDER)} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => this.onCloseLimitEditor()} + onSelectLimit={limit => this.onSelectLimit(limit)}/>} + + + {selectedTab === tabIds.VENDOR_LIMITS && + item.type === limitType.VENDOR)} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => this.onCloseLimitEditor()} + onSelectLimit={limit => this.onSelectLimit(limit)}/>} + + {selectedTab !== tabIds.GENERAL ? + : +
// Render empty div to not break tabs } +
+ + {!this.state.selectedLimit && } + +
); } submit() { - const {data: entitlementPool, previousData: previousEntitlementPool} = this.props; - this.props.onSubmit({entitlementPool, previousEntitlementPool}); + const {data: entitlementPool, previousData: previousEntitlementPool, formReady} = this.props; + + if (!formReady) { + this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM); + } else { + this.props.onSubmit({entitlementPool, previousEntitlementPool}); + } + + } validateName(value) { @@ -309,52 +295,26 @@ class EntitlementPoolsEditorView extends React.Component { {isValid: false, errorText: i18n('Entitlement pool by the name \'' + value + '\' already exists. Entitlement pool name must be unique')}; } - validateStartDate(value, state) { - if (state.data.expiryDate) { - if (!value) { - return {isValid: false, errorText: i18n('Start date has to be specified if expiry date is specified')}; - } + onSelectLimit(limit) { + if (limit.id === this.state.selectedLimit) { + this.setState({selectedLimit: ''}); + return; } - return {isValid: true, errorText: ''}; + this.setState({selectedLimit: limit.id}); + this.props.onOpenLimitEditor(limit); } - validateTimeOtherValue(value) { - return Validator.validate('time', value.other, [{type: 'required', data: true}, {type: 'numeric', data: true}]); + onCloseLimitEditor() { + this.setState({selectedLimit: ''}); + this.props.onCloseLimitEditor(); } - validateChoiceWithOther(value) { - let chosen = value.choice; - // if we have an empty multiple select we have a problem since it's required - if (value.choices) { - if (value.choices.length === 0) { - return Validator.validate('field', '', [{type: 'required', data: true}]); - } else { - // continuing validation with the first chosen value in case we have the 'Other' field - chosen = value.choices[0]; - } - } - if (chosen !== optionInputOther.OTHER) { - return Validator.validate('field', chosen, [{type: 'required', data: true}]); - } else { // when 'Other' was chosen, validate other value - return Validator.validate('field', value.other, [{type: 'required', data: true}]); - } + onAddLimit() { + this.setState({selectedLimit: NEW_LIMIT_TEMP_ID}); + this.props.onOpenLimitEditor(); } - thresholdValueValidation(value, state) { - let unit = state.data.thresholdUnits; - if (unit === thresholdUnitType.PERCENTAGE) { - return Validator.validate('thresholdValue', value, [ - {type: 'required', data: true}, - {type: 'numeric', data: true}, - {type: 'maximum', data: 100}, - {type: 'minimum', data: 0}]); - } else { - return Validator.validate('thresholdValue', value, [ - {type: 'numeric', data: true}, - {type: 'required', data: true}]); - } - } } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js new file mode 100644 index 0000000000..ae53a753c0 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js @@ -0,0 +1,56 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +import {connect} from 'react-redux'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; +import {actionTypes as globalModalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; + +const mapStateToProps = ({licenseModel: {entitlementPool: {entitlementPoolEditor: {data}}, limitEditor}, currentScreen}) => { + let {props: {licenseModelId, version}} = currentScreen; + return { + parent: data, + limitEditor, + licenseModelId, + version + }; +}; + +const mapActionsToProps = (dispatch) => { + return { + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), + onSubmit: (limit, entitlementPool, licenseModelId, version) => EntitlementPoolsActionHelper.submitLimit(dispatch, + { + limit, + entitlementPool, + licenseModelId, + version}), + onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n(`Are you sure you want to delete ${limit.name}?`), + confirmationButtonText: i18n('Delete'), + title: i18n('Warning'), + onConfirmed: ()=> EntitlementPoolsActionHelper.deleteLimit(dispatch, {limit, entitlementPool: parent, licenseModelId, version}).then(() => + selectedLimit === limit.id && onCloseLimitEditor() + ) + } + }) + }; +}; + +export default connect(mapStateToProps, mapActionsToProps)(Limits); \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js index 993ed48f2b..62c6663833 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js @@ -39,7 +39,7 @@ const mapStateToProps = ({licenseModel: {entitlementPool, licenseModelEditor}}) const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onAddEntitlementPoolClick: () => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch), - onEditEntitlementPoolClick: entitlementPool => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, {entitlementPool}), + onEditEntitlementPoolClick: entitlementPool => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, {entitlementPool, licenseModelId, version}), onDeleteEntitlementPool: entitlementPool => dispatch({ type: globalMoadlActions.GLOBAL_MODAL_WARNING, data:{ diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx index 55fd11b8bb..c730d669c7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx @@ -21,7 +21,7 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import EntitlementPoolsEditor from './EntitlementPoolsEditor.js'; -import {extractUnits, extractValue} from './EntitlementPoolsConstants'; +import {extractUnits} from './EntitlementPoolsConstants'; class EntitlementPoolsListEditorView extends React.Component { static propTypes = { @@ -60,7 +60,7 @@ class EntitlementPoolsListEditorView extends React.Component { isReadOnlyMode={isReadOnlyMode}> {this.filterList().map(entitlementPool => this.renderEntitlementPoolListItem(entitlementPool, isReadOnlyMode))} - + {`${isModalInEditMode ? i18n('Edit Entitlement Pool') : i18n('Create New Entitlement Pool')}`} @@ -91,8 +91,7 @@ class EntitlementPoolsListEditorView extends React.Component { } renderEntitlementPoolListItem(entitlementPool, isReadOnlyMode) { - let {id, name, description, thresholdValue, thresholdUnits, entitlementMetric, aggregationFunction, - manufacturerReferenceNumber, time} = entitlementPool; + let {id, name, description, thresholdValue, thresholdUnits} = entitlementPool; let {onEditEntitlementPoolClick, onDeleteEntitlementPool} = this.props; return (
{i18n('Entitlement')}
-
{`${extractValue(aggregationFunction)} ${extractValue(entitlementMetric)} per ${extractValue(time)}`}
-
{`${thresholdValue ? thresholdValue : ''} ${extractUnits(thresholdUnits)}`}
- - -
-
{i18n('Manufacturer Reference Number')}
-
{manufacturerReferenceNumber}
+
{thresholdValue && `${thresholdValue} ${extractUnits(thresholdUnits)}`}
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js index c6249c98ca..6edb1e1f0c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js @@ -34,7 +34,7 @@ export const mapStateToProps = ({licenseModel: {featureGroup, entitlementPool, l } for (let i = 0; i < list.length; i++) { - FGNames[list[i].name] = list[i].id; + FGNames[list[i].name.toLowerCase()] = list[i].id; } for (let field in genericFieldInfo) { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx index d69548442c..6a5ee4617c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx @@ -15,7 +15,7 @@ */ import React from 'react'; import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; -import Tab from 'react-bootstrap/lib/Tab.js'; +import Tab from 'sdc-ui/lib/react/Tab.js'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import {TabsForm as Form} from 'nfvo-components/input/validation/Form.jsx'; @@ -31,12 +31,13 @@ const FeatureGroupsPropType = React.PropTypes.shape({ name: React.PropTypes.string, description: React.PropTypes.string, partNumber: React.PropTypes.string, + manufacturerReferenceNumber: React.PropTypes.string, entitlementPoolsIds: React.PropTypes.arrayOf(React.PropTypes.string), licenseKeyGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string) }); const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) => { - let {name, description, partNumber} = data; + let {name, description, partNumber, manufacturerReferenceNumber} = data; return ( @@ -51,6 +52,8 @@ const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) isRequired={true} isValid={genericFieldInfo.name.isValid} errorText={genericFieldInfo.name.errorText} /> + + + + onDataChanged({partNumber}, FG_EDITOR_FORM)} @@ -74,6 +78,18 @@ const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) isValid={genericFieldInfo.partNumber.isValid} errorText={genericFieldInfo.partNumber.errorText} /> + + onDataChanged({manufacturerReferenceNumber}, FG_EDITOR_FORM)} + label={i18n('Manufacturer Reference Number')} + data-test-id='create-fg-reference-number' + value={manufacturerReferenceNumber} + isRequired={true} + type='text' + isValid={genericFieldInfo.manufacturerReferenceNumber.isValid} + errorText={genericFieldInfo.manufacturerReferenceNumber.errorText} /> + ); }; @@ -94,7 +110,7 @@ const EntitlementPoolsTab = ({entitlementPoolsList, data, onDataChanged, isReadO ); } else { return ( -

{i18n('There is no available entitlement pools')}

+

{i18n('There are no available entitlement pools')}

); } }; @@ -115,7 +131,7 @@ const LKGTab = ({licenseKeyGroupsList, data, onDataChanged, isReadOnlyMode}) => ); } else { return ( -

{i18n('There is no available licsense key groups')}

+

{i18n('There are no available license key groups')}

); } }; @@ -166,22 +182,22 @@ class FeatureGroupEditorView extends React.Component { labledButtons={true} isReadOnlyMode={isReadOnlyMode} name='feature-group-validation-form' - className='feature-group-form'> - - + className='license-model-form feature-group-form'> + +
this.validateName(value)}/>
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx index f883bd7a14..9844290a25 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx @@ -65,7 +65,7 @@ class FeatureGroupListEditorView extends React.Component { {this.filterList().map(listItem => this.renderFeatureGroupListItem(listItem, isReadOnlyMode, version))} {featureGroupsModal.show && + className='onborading-modal license-model-modal feature-group-modal'> {`${featureGroupsModal.editMode ? i18n('Edit Feature Group') : i18n('Create New Feature Group')}`} @@ -84,7 +84,7 @@ class FeatureGroupListEditorView extends React.Component { renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { - let {name, description, entitlementPoolsIds = [], licenseKeyGroupsIds = []} = listItem; + let {name, description, manufacturerReferenceNumber, entitlementPoolsIds = [], licenseKeyGroupsIds = []} = listItem; return (
+
+
+
{i18n('Manufacturer Reference')}
+
{i18n('Number')}
+
{manufacturerReferenceNumber}
+
+
+
{i18n('Description')}
{description}
+ +
); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js index a2015787a6..b8c03750fb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js @@ -39,6 +39,7 @@ function addFeatureGroup(licenseModelId, featureGroup, version) { name: featureGroup.name, description: featureGroup.description, partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, addedLicenseKeyGroupsIds: featureGroup.licenseKeyGroupsIds, addedEntitlementPoolsIds: featureGroup.entitlementPoolsIds }); @@ -54,6 +55,7 @@ function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, name: featureGroup.name, description: featureGroup.description, partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, addedLicenseKeyGroupsIds: licenseKeyGroupsIds.filter(licenseKeyGroupId => prevLicenseKeyGroupsIds.indexOf(licenseKeyGroupId) === -1), removedLicenseKeyGroupsIds: prevLicenseKeyGroupsIds.filter(prevLicenseKeyGroupId => licenseKeyGroupsIds.indexOf(prevLicenseKeyGroupId) === -1), addedEntitlementPoolsIds: entitlementPoolsIds.filter(entitlementPoolId => prevEntitlementPoolsIds.indexOf(entitlementPoolId) === -1), diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js index 001bd20d44..5688fc0f16 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js @@ -30,7 +30,7 @@ export default (state = {}, action) => { 'description': { isValid: true, errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}], + validations: [{type: 'maxLength', data: 1000}], tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL }, 'partNumber': { @@ -39,6 +39,12 @@ export default (state = {}, action) => { validations: [{type: 'required', data: true}], tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL }, + 'manufacturerReferenceNumber': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {type: 'maxLength', data: 100}], + tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL + }, 'name': { isValid: true, errorText: '', diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js index 998d5f0e8d..40bef2c181 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js @@ -15,7 +15,7 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ LICENSE_AGREEMENT_LIST_LOADED: null, diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js index aada8ddca1..7d70da6ea5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js @@ -32,7 +32,7 @@ export const mapStateToProps = ({licenseModel: {licenseAgreement, featureGroup}} } for (let i = 0; i < list.length; i++) { - LANames[list[i].name] = list[i].id; + LANames[list[i].name.toLowerCase()] = list[i].id; } const {featureGroupsList = []} = featureGroup; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js index e02935c579..5be140550a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js @@ -26,7 +26,7 @@ export default (state = {}, action) => { 'description' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}], + validations: [{type: 'maxLength', data: 1000}], tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL }, 'requirementsAndConstrains' : { @@ -38,7 +38,7 @@ export default (state = {}, action) => { 'licenseTerm' : { isValid: true, errorText: '', - validations: [], + validations: [{type: 'required', data: true}], tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL }, 'name' : { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx index 42a33fd509..a15e5daa4e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx @@ -19,7 +19,7 @@ import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import {TabsForm as Form} from 'nfvo-components/input/validation/Form.jsx'; import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; -import Tab from 'react-bootstrap/lib/Tab.js'; +import Tab from 'sdc-ui/lib/react/Tab.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -96,7 +96,6 @@ const GeneralTabContent = ({data, genericFieldInfo, onDataChanged, validateName, overlayPos='bottom' data-test-id='create-la-description' name='license-agreement-description' - isRequired={true} type='textarea'/> @@ -145,10 +144,10 @@ class LicenseAgreementEditorView extends React.Component { isValid={this.props.isFormValid} formReady={this.props.formReady} onValidateForm={() => this.props.onValidateForm(LA_EDITOR_FORM) } - className='license-agreement-form'> - + className='license-model-form license-agreement-form'> +
@@ -157,7 +156,7 @@ class LicenseAgreementEditorView extends React.Component {
@@ -168,7 +167,7 @@ class LicenseAgreementEditorView extends React.Component { selectedValuesList={data.featureGroupsIds} availableList={featureGroupsList} onChange={ selectedValuesList => onDataChanged( { featureGroupsIds: selectedValuesList }, LA_EDITOR_FORM )}/> : -

{i18n('There is no available feature groups')}

} +

{i18n('There are no available feature groups')}

}
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx index 192d2ded99..6247723d72 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx @@ -59,7 +59,7 @@ class LicenseAgreementListEditorView extends React.Component { isReadOnlyMode={isReadOnlyMode}> {this.filterList().map(licenseAgreement => this.renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode, version))} - + {`${isModalInEditMode ? i18n('Edit License Agreement') : i18n('Create New License Agreement')}`} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js index dd2a5c6003..f5017f6d7a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js @@ -17,6 +17,8 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as licenseKeyGroupsConstants} from './LicenseKeyGroupsConstants.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; +import getValue from 'nfvo-utils/getValue.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -36,8 +38,13 @@ function postLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: licenseKeyGroup.name, description: licenseKeyGroup.description, - operationalScope: licenseKeyGroup.operationalScope, - type: licenseKeyGroup.type + operationalScope: getValue(licenseKeyGroup.operationalScope), + type: licenseKeyGroup.type, + increments: licenseKeyGroup.increments, + thresholdValue: licenseKeyGroup.thresholdValue, + thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), + startDate: licenseKeyGroup.startDate, + expiryDate: licenseKeyGroup.expiryDate }); } @@ -45,11 +52,50 @@ function putLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseKeyGroup.id}`, { name: licenseKeyGroup.name, description: licenseKeyGroup.description, - operationalScope: licenseKeyGroup.operationalScope, - type: licenseKeyGroup.type + operationalScope: getValue(licenseKeyGroup.operationalScope), + type: licenseKeyGroup.type, + increments: licenseKeyGroup.increments, + thresholdValue: licenseKeyGroup.thresholdValue, + thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), + startDate: licenseKeyGroup.startDate, + expiryDate: licenseKeyGroup.expiryDate }); } +function fetchLimitsList(licenseModelId, licenseKeyGroupId, version) { + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits`); +} + +function deleteLimit(licenseModelId, licenseKeyGroupId, version, limitId) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits/${limitId}`); +} + +function postLimit(licenseModelId, licenseKeyGroupId, version, limit) { + return RestAPIUtil.post(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits`, { + name: limit.name, + type: limit.type, + description: limit.description, + metric: limit.metric, + value: limit.value, + unit: limit.unit, + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + }); +} + +function putLimit(licenseModelId, licenseKeyGroupId, version, limit) { + + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits/${limit.id}`, { + name: limit.name, + type: limit.type, + description: limit.description, + metric: limit.metric, + value: limit.value, + unit: limit.unit, + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + }); +} export default { fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) { @@ -59,7 +105,10 @@ export default { })); }, - openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup} = {}) { + openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup, licenseModelId, version} = {}) { + if (licenseModelId && version) { + this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); + } dispatch({ type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.OPEN, licenseKeyGroup @@ -124,5 +173,34 @@ export default { LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { this.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); }); + }, + + + fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}) { + return fetchLimitsList(licenseModelId, licenseKeyGroup.id, version).then(response => { + dispatch({ + type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.LIMITS_LIST_LOADED, + response + }); + }); + }, + + submitLimit(dispatch, {licenseModelId, version, licenseKeyGroup, limit}) { + const promise = limit.id ? putLimit(licenseModelId,licenseKeyGroup.id, version, limit) : + postLimit(licenseModelId,licenseKeyGroup.id, version, limit); + return promise.then(() => { + dispatch({ + type: limitEditorActions.CLOSE + }); + this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); + }); + }, + + deleteLimit(dispatch, {licenseModelId, version, licenseKeyGroup, limit}) { + return deleteLimit(licenseModelId,licenseKeyGroup.id, version, limit.id).then(() => { + this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); + }); } + + }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js index 50d1fe8625..c376cb3fbc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js @@ -15,7 +15,7 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ @@ -28,6 +28,7 @@ export const actionTypes = keyMirror({ OPEN: null, CLOSE: null, DATA_CHANGED: null, + LIMITS_LIST_LOADED: null } }); @@ -77,3 +78,10 @@ export const getOperationalScopes = (operationalScope) => { return allOpScopes; } }; + +export const tabIds = { + GENERAL: 'GENERAL', + SP_LIMITS: 'SP_LIMITS', + VENDOR_LIMITS: 'VENDOR_LIMITS', + ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js index aef1532dc1..028fa9d3e4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js @@ -16,12 +16,13 @@ import {connect} from 'react-redux'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; import LicenseKeyGroupsEditorView from './LicenseKeyGroupsEditorView.jsx'; +import LimitEditorActionHelper from '../limits/LimitEditorActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const mapStateToProps = ({licenseModel: {licenseKeyGroup}}) => { - let {data, genericFieldInfo, formReady} = licenseKeyGroup.licenseKeyGroupsEditor; + let {data, genericFieldInfo, formReady, limitsList} = licenseKeyGroup.licenseKeyGroupsEditor; let previousData, LKGNames = {}; const licenseKeyGroupId = data ? data.id : null; @@ -33,7 +34,7 @@ const mapStateToProps = ({licenseModel: {licenseKeyGroup}}) => { const list = licenseKeyGroup.licenseKeyGroupsList; for (let i = 0; i < list.length; i++) { - LKGNames[list[i].name] = list[i].id; + LKGNames[list[i].name.toLowerCase()] = list[i].id; } return { @@ -42,7 +43,8 @@ const mapStateToProps = ({licenseModel: {licenseKeyGroup}}) => { genericFieldInfo, isFormValid, formReady, - LKGNames + LKGNames, + limitsList }; }; @@ -50,11 +52,13 @@ const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch), - onSubmit: ({previousLicenseKeyGroup, licenseKeyGroup}) => { - LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch); + onSubmit: ({previousLicenseKeyGroup, licenseKeyGroup, keepOpen}) => { + if (!keepOpen) {LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch);} LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version}); }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName), + onCloseLimitEditor: () => LimitEditorActionHelper.closeLimitsEditor(dispatch), + onOpenLimitEditor: (limit) => LimitEditorActionHelper.openLimitsEditor(dispatch, {limit}) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js index 090c971c65..b1a22f3d9a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js @@ -14,20 +14,30 @@ * permissions and limitations under the License. */ import {actionTypes, defaultState, LKG_FORM_NAME} from './LicenseKeyGroupsConstants.js'; +import moment from 'moment'; +import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; export default (state = {}, action) => { switch (action.type) { case actionTypes.licenseKeyGroupsEditor.OPEN: + let licenseKeyGroupData = {...action.licenseKeyGroup}; + let {startDate, expiryDate} = licenseKeyGroupData; + if (startDate) { + licenseKeyGroupData.startDate = moment(startDate, DATE_FORMAT).format(DATE_FORMAT); + } + if (expiryDate) { + licenseKeyGroupData.expiryDate = moment(expiryDate, DATE_FORMAT).format(DATE_FORMAT); + } return { ...state, - data: action.licenseKeyGroup ? {...action.licenseKeyGroup} : defaultState.licenseKeyGroupsEditor, + data: action.licenseKeyGroup ? licenseKeyGroupData : defaultState.licenseKeyGroupsEditor, formReady: null, formName: LKG_FORM_NAME, genericFieldInfo: { 'description' : { isValid: true, errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}] + validations: [{type: 'maxLength', data: 1000}] }, 'name' : { isValid: true, @@ -43,9 +53,39 @@ export default (state = {}, action) => { isValid: true, errorText: '', validations: [] + }, + 'thresholdUnits' : { + isValid: true, + errorText: '', + validations: [] + }, + 'thresholdValue' : { + isValid: true, + errorText: '', + validations: [] + }, + 'increments' : { + isValid: true, + errorText: '', + validations: [{type: 'maxLength', data: 120}] + }, + 'startDate': { + isValid: true, + errorText: '', + validations: [] + }, + 'expiryDate': { + isValid: true, + errorText: '', + validations: [] } } }; + case actionTypes.licenseKeyGroupsEditor.LIMITS_LIST_LOADED: + return { + ...state, + limitsList: action.response.results + }; case actionTypes.licenseKeyGroupsEditor.CLOSE: return {}; default: diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx index b95efd0f9c..647e205cb5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx @@ -17,27 +17,43 @@ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; +import Tabs from 'sdc-ui/lib/react/Tabs.js'; +import Tab from 'sdc-ui/lib/react/Tab.js'; + +import Button from 'sdc-ui/lib/react/Button.js'; import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {optionsInputValues as licenseKeyGroupOptionsInputValues, LKG_FORM_NAME} from './LicenseKeyGroupsConstants.js'; +import {optionsInputValues as licenseKeyGroupOptionsInputValues, LKG_FORM_NAME, tabIds} from './LicenseKeyGroupsConstants.js'; +import {optionsInputValues as LicenseModelOptionsInputValues} from '../LicenseModelConstants.js'; +import {validateStartDate, thresholdValueValidation} from '../LicenseModelValidations.js'; import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; -const LicenseKeyGroupPropType = React.PropTypes.shape({ +import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; + +import LicenseKeyGroupsLimits from './LicenseKeyGroupsLimits.js'; +import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; + + const LicenseKeyGroupPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, + increments: React.PropTypes.string, operationalScope: React.PropTypes.shape({ choices: React.PropTypes.array, other: React.PropTypes.string }), - type: React.PropTypes.string + type: React.PropTypes.string, + thresholdUnits: React.PropTypes.string, + thresholdValue: React.PropTypes.number, + startDate: React.PropTypes.string, + expiryDate: React.PropTypes.string }); -const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, validateName, validateOperationalScope}) => { - let {name, description, operationalScope, type} = data; +const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, validateName, validateStartDate, thresholdValueValidation}) => { + let {name, description, increments, operationalScope, type, thresholdUnits, thresholdValue, startDate, expiryDate} = data; return ( @@ -55,11 +71,10 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali {}} isMultiSelect={true} - isRequired={true} onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, - LKG_FORM_NAME, {operationalScope: validateOperationalScope})} + LKG_FORM_NAME)} onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], - other: operationalScope}}, LKG_FORM_NAME, {operationalScope: validateOperationalScope})} + other: operationalScope}}, LKG_FORM_NAME)} label={i18n('Operational Scope')} data-test-id='create-lkg-operational-scope' type='select' @@ -77,7 +92,6 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali value={description} isValid={genericFieldInfo.description.isValid} errorText={genericFieldInfo.description.errorText} - isRequired={true} type='textarea' overlayPos='bottom' /> @@ -101,6 +115,82 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali } + + { + // setting the unit to the correct value + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({thresholdUnits: val}, LKG_FORM_NAME); + // TODO make sure that the value is valid too + onDataChanged({thresholdValue: thresholdValue}, LKG_FORM_NAME,{thresholdValue : thresholdValueValidation});} + + } + value={thresholdUnits} + label={i18n('Threshold Units')} + data-test-id='create-ep-threshold-units' + isValid={genericFieldInfo.thresholdUnits.isValid} + errorText={genericFieldInfo.thresholdUnits.errorText} + groupClassName='bootstrap-input-options' + className='input-options-select' + type='select' > + {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map(mtype => + )} + + + + onDataChanged({thresholdValue}, LKG_FORM_NAME, + {thresholdValue : thresholdValueValidation})} + label={i18n('Threshold Value')} + isValid={genericFieldInfo.thresholdValue.isValid} + errorText={genericFieldInfo.thresholdValue.errorText} + data-test-id='create-ep-threshold-value' + value={thresholdValue} + type='text'/> + + + onDataChanged( + {startDate: startDate ? startDate.format(DATE_FORMAT) : ''}, + LKG_FORM_NAME, + {startDate: validateStartDate} + )} + isValid={genericFieldInfo.startDate.isValid} + errorText={genericFieldInfo.startDate.errorText} + selectsStart/> + + + { + onDataChanged({expiryDate: expiryDate ? expiryDate.format(DATE_FORMAT) : ''}, LKG_FORM_NAME); + onDataChanged({startDate}, LKG_FORM_NAME, {startDate: validateStartDate}); + }} + isValid={genericFieldInfo.expiryDate.isValid} + errorText={genericFieldInfo.expiryDate.errorText} + selectsEnd/> + + + onDataChanged({increments}, LKG_FORM_NAME)} + label={i18n('Increments')} + value={increments} + data-test-id='create-ep-increments' + type='text'/> + ); }; @@ -120,36 +210,100 @@ class LicenseKeyGroupsEditorView extends React.Component { data: {} }; + componentDidUpdate(prevProps) { + if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit + this.submit(); + } + } + + state = { + localFeatureGroupsListFilter: '', + selectedTab: tabIds.GENERAL, + selectedLimit: '' + }; + render() { - let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo} = this.props; + let {data = {}, onDataChanged, isReadOnlyMode, onCloseLimitEditor, genericFieldInfo, limitsList = []} = this.props; + let {selectedTab} = this.state; + const isTabsDisabled = !data.id || !this.props.isFormValid; return ( -
- { genericFieldInfo && -
this.submit() } - onReset={ () => this.props.onCancel() } - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(LKG_FORM_NAME) } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - className='license-key-groups-form'> - this.validateName(value)} - validateOperationalScope={this.validateOperationalScope}/> - } +
+ { + if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { + this.onAddLimit(); + } else { + this.setState({selectedTab: tabIndex}); + onCloseLimitEditor(); + this.setState({selectedLimit: ''}); + } + }} + invalidTabs={[]}> + + { genericFieldInfo && +
this.props.onValidateForm(LKG_FORM_NAME) } + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + className='license-model-form license-key-groups-form'> + this.validateName(value)} + validateStartDate={(value, state)=> validateStartDate(value, state)} + thresholdValueValidation={(value, state) => thresholdValueValidation(value, state)}/> + } + +
+ + {selectedTab === tabIds.SP_LIMITS && + item.type === limitType.SERVICE_PROVIDER)} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => this.onCloseLimitEditor()} + onSelectLimit={limit => this.onSelectLimit(limit)}/>} + + + {selectedTab === tabIds.VENDOR_LIMITS && + item.type === limitType.VENDOR)} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => this.onCloseLimitEditor()} + onSelectLimit={limit => this.onSelectLimit(limit)}/>} + + {selectedTab !== tabIds.GENERAL ? + : +
// Render empty div to not break tabs + } +
+ + + {!this.state.selectedLimit && } + +
+ ); } submit() { - const {data: licenseKeyGroup, previousData: previousLicenseKeyGroup} = this.props; - this.props.onSubmit({licenseKeyGroup, previousLicenseKeyGroup}); + const {data: licenseKeyGroup, previousData: previousLicenseKeyGroup, formReady, onValidateForm, onSubmit} = this.props; + if (!formReady) { + onValidateForm(LKG_FORM_NAME); + } else { + onSubmit({licenseKeyGroup, previousLicenseKeyGroup}); + } } validateName(value) { @@ -160,27 +314,23 @@ class LicenseKeyGroupsEditorView extends React.Component { {isValid: false, errorText: i18n('License key group by the name \'' + value + '\' already exists. License key group name must be unique')}; } - validateOperationalScope(value) { - if (value && value.choices && value.choices.length > 0) { - if (value.choices[0] !== optionInputOther.OTHER) - { - return { - isValid: true, - errorText: '' - }; - } else { - if ( value.other ) { - return { - isValid: true, - errorText: '' - }; - } - } + onSelectLimit(limit) { + if (limit.id === this.state.selectedLimit) { + this.setState({selectedLimit: ''}); + return; } - return { - isValid: false, - errorText: 'Field is required' - }; + this.setState({selectedLimit: limit.id}); + this.props.onOpenLimitEditor(limit); + } + + onCloseLimitEditor() { + this.setState({selectedLimit: ''}); + this.props.onCloseLimitEditor(); + } + + onAddLimit() { + this.setState({selectedLimit: NEW_LIMIT_TEMP_ID}); + this.props.onOpenLimitEditor(); } } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js new file mode 100644 index 0000000000..7745a12fec --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js @@ -0,0 +1,57 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +import {connect} from 'react-redux'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {actionTypes as globalModalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; + +import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; + +const mapStateToProps = ({licenseModel: {licenseKeyGroup: {licenseKeyGroupsEditor: {data}}, limitEditor}, currentScreen}) => { + let {props: {licenseModelId, version}} = currentScreen; + return { + parent: data, + limitEditor, + licenseModelId, + version + }; +}; + +const mapActionsToProps = (dispatch) => { + return { + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), + onSubmit: (limit, licenseKeyGroup, licenseModelId, version) => LicenseKeyGroupsActionHelper.submitLimit(dispatch, + { + limit, + licenseKeyGroup, + licenseModelId, + version}), + onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n(`Are you sure you want to delete ${limit.name}?`), + confirmationButtonText: i18n('Delete'), + title: i18n('Warning'), + onConfirmed: ()=> LicenseKeyGroupsActionHelper.deleteLimit(dispatch, {limit, licenseKeyGroup: parent, licenseModelId, version}).then(() => + selectedLimit === limit.id && onCloseLimitEditor() + ) + } + }) + }; +}; + +export default connect(mapStateToProps, mapActionsToProps)(Limits); \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js index e2c6c30e21..a8cf1eb0a1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js @@ -38,7 +38,7 @@ const mapStateToProps = ({licenseModel: {licenseKeyGroup, licenseModelEditor}}) const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onAddLicenseKeyGroupClick: () => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch), - onEditLicenseKeyGroupClick: licenseKeyGroup => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup}), + onEditLicenseKeyGroupClick: licenseKeyGroup => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup, licenseModelId, version}), onDeleteLicenseKeyGroupClick: licenseKeyGroup => dispatch({ type: globalMoadlActions.GLOBAL_MODAL_WARNING, data:{ diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx index b8ccd68bce..1a7f2b0b5b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx @@ -21,7 +21,7 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import LicenseKeyGroupsEditor from './LicenseKeyGroupsEditor.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; import {optionsInputValues} from './LicenseKeyGroupsConstants'; class LicenseKeyGroupsListEditorView extends React.Component { @@ -61,7 +61,7 @@ class LicenseKeyGroupsListEditorView extends React.Component { isReadOnlyMode={isReadOnlyMode}> {this.filterList().map(licenseKeyGroup => (this.renderLicenseKeyGroupListItem(licenseKeyGroup, isReadOnlyMode)))} - + {`${isModalInEditMode ? i18n('Edit License Key Group') : i18n('Create New License Key Group')}`} @@ -122,16 +122,20 @@ class LicenseKeyGroupsListEditorView extends React.Component { } getOperationalScopes(operationalScope) { - if(operationalScope.choices.toString() === i18n(optionInputOther.OTHER) && operationalScope.other !== '') { + + if(operationalScope.choices && operationalScope.choices.toString() === i18n(optionInputOther.OTHER)) { return operationalScope.other; } - else { + else if (operationalScope.choices) { let allOpScopes = ''; for (let opScope of operationalScope.choices) { allOpScopes += allOpScopes === '' ? InputOptions.getTitleByName(optionsInputValues, opScope) : `, ${InputOptions.getTitleByName(optionsInputValues, opScope)}`; } return allOpScopes; - } + } + else { + return ''; + } } extractValue(item) { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js new file mode 100644 index 0000000000..d483383472 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js @@ -0,0 +1,25 @@ +import {connect} from 'react-redux'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import LimitEditor from './LimitEditor.jsx'; + +const mapStateToProps = ({licenseModel: {limitEditor}}) => { + + let {data, genericFieldInfo, formReady} = limitEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + + return { + data, + genericFieldInfo, + isFormValid, + formReady + }; +}; + +const mapActionsToProps = (dispatch) => { + return { + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) + }; +}; + +export default connect(mapStateToProps, mapActionsToProps)(LimitEditor); \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx new file mode 100644 index 0000000000..f70f917725 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx @@ -0,0 +1,193 @@ +import React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; +import {LIMITS_FORM_NAME, selectValues} from './LimitEditorConstants.js'; +import Button from 'sdc-ui/lib/react/Button.js'; +import Validator from 'nfvo-utils/Validator.js'; + +const LimitPropType = React.PropTypes.shape({ + id: React.PropTypes.string, + name: React.PropTypes.string, + description: React.PropTypes.string, + metric: React.PropTypes.string, + value: React.PropTypes.number, + aggregationFunction: React.PropTypes.string, + time: React.PropTypes.string, + unit: React.PropTypes.number +}); + +class LimitEditor extends React.Component { + static propTypes = { + data: LimitPropType, + limitsNames: React.PropTypes.object, + isReadOnlyMode: React.PropTypes.bool, + isFormValid: React.PropTypes.bool, + formReady: React.PropTypes.bool, + genericFieldInfo: React.PropTypes.object.isRequired, + onDataChanged: React.PropTypes.func.isRequired, + onSubmit: React.PropTypes.func.isRequired, + onValidateForm: React.PropTypes.func.isRequired, + onCancel: React.PropTypes.func.isRequired + }; + + componentDidUpdate(prevProps) { + if (this.props.formReady && this.props.formReady !== prevProps.formReady) { + this.submit(); + } + } + + render() { + let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo, onCancel, isFormValid, formReady, onValidateForm} = this.props; + let {name, description, metric, value, aggregationFunction, time, unit} = data; + return ( +
+ {!data.id && +
+ {data.name ? data.name : i18n('NEW LIMIT')} +
} + { + genericFieldInfo && +
onValidateForm(LIMITS_FORM_NAME) } + labledButtons={false} + isReadOnlyMode={isReadOnlyMode} + className='limit-editor-form'> + + + onDataChanged({name}, LIMITS_FORM_NAME, {name: () => this.validateName(name)})} + label={i18n('Name')} + data-test-id='limit-editor-name' + value={name} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + isRequired={true} + type='text'/> + + + onDataChanged({description}, LIMITS_FORM_NAME)} + label={i18n('Description')} + data-test-id='limit-editor-description' + value={description} + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + isRequired={false} + type='text'/> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({metric: val}, LIMITS_FORM_NAME);} + } + isRequired={true} + value={metric} + label={i18n('Metric')} + data-test-id='limit-editor-metric' + isValid={genericFieldInfo.metric.isValid} + errorText={genericFieldInfo.metric.errorText} + groupClassName='bootstrap-input-options' + className='input-options-select' + type='select' > + {selectValues.METRIC.map(mtype => + )} + + + + onDataChanged({value}, LIMITS_FORM_NAME)} + label={i18n('Metric value')} + data-test-id='limit-editor-metric-value' + value={value} + isValid={genericFieldInfo.value.isValid} + errorText={genericFieldInfo.value.errorText} + isRequired={true} + type='number'/> + + + onDataChanged({unit}, LIMITS_FORM_NAME)} + label={i18n('Units')} + data-test-id='limit-editor-units' + value={unit} + isValid={genericFieldInfo.unit.isValid} + errorText={genericFieldInfo.unit.errorText} + isRequired={false} + type='number'/> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({aggregationFunction: val}, LIMITS_FORM_NAME);} + } + value={aggregationFunction} + label={i18n('Aggregation Function')} + data-test-id='limit-editor-aggregation-function' + isValid={genericFieldInfo.aggregationFunction.isValid} + errorText={genericFieldInfo.aggregationFunction.errorText} + groupClassName='bootstrap-input-options' + className='input-options-select' + type='select' > + {selectValues.AGGREGATION_FUNCTION.map(mtype => + )} + + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({time: val}, LIMITS_FORM_NAME);} + } + value={time} + label={i18n('Time')} + data-test-id='limit-editor-time' + isValid={genericFieldInfo.time.isValid} + errorText={genericFieldInfo.time.errorText} + groupClassName='bootstrap-input-options' + className='input-options-select' + type='select' > + {selectValues.TIME.map(mtype => + )} + + + + + + + +
+ } +
+ ); + } + + validateName(value) { + const {data: {id}, limitsNames} = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: limitsNames}); + + return !isExists ? {isValid: true, errorText: ''} : + {isValid: false, errorText: i18n('Limit by the name \'' + value + '\' already exists. Limit name must be unique')}; + } + + submit() { + if (!this.props.formReady) { + this.props.onValidateForm(LIMITS_FORM_NAME); + } else { + this.props.onSubmit(); + } + } +} + +export default LimitEditor; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js new file mode 100644 index 0000000000..09c64ada62 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js @@ -0,0 +1,30 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import {actionTypes} from './LimitEditorConstants.js'; + + +const LimitEditorActionHelper = { + openLimitsEditor(dispatch, {limit}) { + dispatch({type: actionTypes.OPEN, limitItem: limit}); + }, + + closeLimitsEditor(dispatch) { + dispatch({type: actionTypes.CLOSE}); + } +}; + +export default LimitEditorActionHelper; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js new file mode 100644 index 0000000000..1bef286442 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js @@ -0,0 +1,52 @@ +import keyMirror from 'nfvo-utils/KeyMirror.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +// import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; + +export const actionTypes = keyMirror({ + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, +}); + +export const LIMITS_FORM_NAME = 'LIMITSFORM'; + +export const selectValues = { + METRIC: [ + {enum: '', title: i18n('please select…')}, + {enum: 'Software_Instances_Count', title: 'Software Instances'}, + {enum: 'Core', title: 'Core'}, + {enum: 'CPU', title: 'CPU'}, + {enum: 'Trunks', title: 'Trunks'}, + {enum: 'User', title: 'User'}, + {enum: 'Subscribers', title: 'Subscribers'}, + {enum: 'Tenants', title: 'Tenants'}, + {enum: 'Tokens', title: 'Tokens'}, + {enum: 'Seats', title: 'Seats'}, + {enum: 'Units_TB', title: 'Units-TB'}, + {enum: 'Units_GB', title: 'Units-GB'}, + {enum: 'Units_MB', title: 'Units-MB'} + ], + AGGREGATION_FUNCTION: [ + {enum: '', title: i18n('please select…')}, + {enum: 'Peak', title: 'Peak'}, + {enum: 'Average', title: 'Average'} + ], + TIME: [ + {enum: '', title: i18n('please select…')}, + {enum: 'Hour', title: 'Hour'}, + {enum: 'Day', title: 'Day'}, + {enum: 'Month', title: 'Month'} + ] + +}; + +export const limitType = { + SERVICE_PROVIDER: 'ServiceProvider', + VENDOR: 'Vendor' +}; + +export const defaultState = { + LIMITS_EDITOR_DATA: {} +}; + +export const NEW_LIMIT_TEMP_ID = 'NEW_LIMIT_TEMP_ID'; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js new file mode 100644 index 0000000000..2499093af2 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js @@ -0,0 +1,70 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import {actionTypes, LIMITS_FORM_NAME, defaultState} from './LimitEditorConstants.js'; + +export default (state = {}, action) => { + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + data: action.limitItem ? {...action.limitItem} : defaultState.LIMITS_EDITOR_DATA, + formReady: null, + formName: LIMITS_FORM_NAME, + genericFieldInfo: { + 'description' : { + isValid: true, + errorText: '', + validations: [{type: 'maxLength', data: 1000}] + }, + 'name' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] + }, + 'metric' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'value' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {type: 'numeric', data: true}, {type: 'minimum', data: 0}] + }, + 'unit' : { + isValid: true, + errorText: '', + validations: [{type: 'numeric', data: true}] + }, + 'aggregationFunction' : { + isValid: true, + errorText: '', + validations: [] + }, + 'time' : { + isValid: true, + errorText: '', + validations: [] + } + } + }; + case actionTypes.CLOSE: + return {}; + default: + return state; + } +}; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx new file mode 100644 index 0000000000..ec5a1dff72 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx @@ -0,0 +1,108 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +import React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; +import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; +import LimitEditor from './LimitEditor.js'; +import {NEW_LIMIT_TEMP_ID, selectValues} from './LimitEditorConstants.js'; + +const LimitItem = ({isReadOnlyMode, limit, onDelete, onSelect}) => { + const {name, description, metric, value, aggregationFunction = '', time = ''} = limit; + const timeLabel = time ? `per ${time}` : ''; + return ( + +
+
{name}
+
+ +
+
{description}
+
+ +
+
{`${selectValues.METRIC.find(item => item.enum === metric).title} ${value} ${aggregationFunction} ${timeLabel}`}
+
+
+ ); +}; + +class Limits extends React.Component { + + + state = { + localFilter: '' + }; + + render() { + const {isReadOnlyMode = false, limitEditor, limitsList = [], onCloseLimitEditor, selectedLimit} = this.props; + let limitsNames = {}; + for (let i = 0; i < limitsList.length; i++) { + limitsNames[limitsList[i].name.toLowerCase()] = limitsList[i].id; + } + return ( +
+ + {this.props.selectedLimit === NEW_LIMIT_TEMP_ID && limitEditor.data && + this.submit()}/> + } + {limitsList.length === 0 && !limitEditor.data &&
{i18n('There are no limits')}
} + {limitsList.map(limit => +
+ this.delete(limit)} + onSelect={selectedLimit ? undefined : () => this.props.onSelectLimit(limit)} + clickable={!selectedLimit} + isReadOnlyMode={isReadOnlyMode} + limit={limit}/> + {limit.id === selectedLimit && limitEditor.data && this.submit()}/>} +
)} +
+ +
+ ); + } + + submit() { + let {onSubmit, onCloseLimitEditor, parent, limitEditor, licenseModelId, version, limitType} = this.props; + onSubmit({type: limitType, ...limitEditor.data}, parent, licenseModelId, version).then(() => onCloseLimitEditor()); + } + + delete(limit) { + let {onDelete, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit} = this.props; + onDelete({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}); + } + + filterList() { + let {limitsList = []} = this.props; + let {localFilter} = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return limitsList.filter(({name = '', description = ''}) => { + return escape(name).match(filter) || escape(description).match(filter); + }); + } + else { + return limitsList; + } + } +} + +export default Limits; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js new file mode 100644 index 0000000000..1b8ecb9d94 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js @@ -0,0 +1,46 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +// items/{itemId}/users + +let list = [ + +]; + +export default { + fetch() { + return Promise.resolve({ + listCount: list.length, + results: list + }); + }, + + put(url, payload) { + // let {removedUsers, addedUsers} = payload; + // users = users.filter(user => !removedUsers.map(user => user.userId).includes(user.userId)).concat(addedUsers); + payload.id = Math.random() * (1000 - 1) + 1; + list.push(payload); + return Promise.resolve(); + }, + + destroy(url) { + const parts = url.split('/'); + const id = parts[parts.length - 1]; + let newList = list.filter(item => item.id !== id); + list = newList; + return Promise.resolve(); + } +}; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js index b5a27ed018..56b23384a7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js @@ -34,9 +34,9 @@ export const actionTypes = keyMirror({ LM_DATA_CHANGED: null }); -export const selectedButton = keyMirror({ - VLM_LIST_VIEW: null, - NOT_IN_USE: null -}); +export const selectedButton = { + VLM_LIST_VIEW: 'VLM_LIST_VIEW', + NOT_IN_USE: 'NOT_IN_USE' +}; export const VLM_DESCRIPTION_FORM = 'VLMDEWSCRIPTIONFORM'; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx index d6c79ddb52..15f6c2d1bb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx @@ -52,7 +52,7 @@ class LicenseModelOverviewView extends React.Component { licenseModelId: React.PropTypes.string, licensingDataList: React.PropTypes.array, modalHeader: React.PropTypes.string, - selectedTab: React.PropTypes.symbol, + selectedTab: React.PropTypes.string, onTabSelect: React.PropTypes.func, onCallVCAction: React.PropTypes.func, onClose: React.PropTypes.func @@ -67,14 +67,13 @@ class LicenseModelOverviewView extends React.Component {
-
{selectedInUse ? i18n('VLM List View') : i18n('Entities not in Use')}
- +
{ isDisplayModal && - + {`${i18n('Create New ')}${i18n(modalHeader)}`} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx index 119008a849..ec05e37681 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx @@ -66,7 +66,8 @@ class VLMListView extends Component { this.updateCollapsable(event, licenseAgreement.id) }/> + onClick={event => this.updateCollapsable(event, licenseAgreement.id) } + isOrphan={!this.props.showInUse}/>
    {licenseAgreement.children && licenseAgreement.children.map(item => this.renderLicensingItem(item))} @@ -83,7 +84,8 @@ class VLMListView extends Component { this.updateCollapsable(event, featureGroup.id) }/> + onClick={event=> this.updateCollapsable(event, featureGroup.id) } + isOrphan={!this.props.showInUse}/> { showInUse &&
      @@ -99,7 +101,7 @@ class VLMListView extends Component { renderEntitlementPoolItem(entitlementPool) { return (
    • - +
    • ); } @@ -107,7 +109,7 @@ class VLMListView extends Component { renderLicenseKeyGroupItem(licenseKeyGroup) { return (
    • - +
    • ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx index 94977b40d1..34d2ee6db5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx @@ -15,7 +15,7 @@ */ import React, {Component} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {extractValue, extractUnits} from '../../entitlementPools/EntitlementPoolsConstants.js'; +import {extractUnits} from '../../entitlementPools/EntitlementPoolsConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; @@ -23,31 +23,23 @@ import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/Ad class EntitlementPool extends Component { render() { - let {epData: {name, description, manufacturerReferenceNumber}} = this.props; + let {epData: {name, description, thresholdValue, thresholdUnits}, isOrphan} = this.props; return ( -
      - - +
      + {!isOrphan && } + - - + value={`${thresholdValue} ${extractUnits(thresholdUnits)}`}/> + }
      ); } - getEntitlement() { - let {epData: {entitlementMetric, aggregationFunction, time, thresholdValue, thresholdUnits}} = this.props; - return `${extractValue(aggregationFunction)} ${extractValue(entitlementMetric)} per ${extractValue(time)} ${thresholdValue} ${extractUnits(thresholdUnits)}`; - } - } export default EntitlementPool; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx index 8dbd46a29e..6d97dea358 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx @@ -18,30 +18,41 @@ import {overviewEditorHeaders} from '../LicenseModelOverviewConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/AdditionalDataCol.jsx'; class FeatureGroup extends Component { render() { - let {fgData: {name, description, children = []}, isCollapsed, onClick} = this.props; + let {fgData: {name, manufacturerReferenceNumber, description, children = []}, isCollapsed, onClick, isOrphan} = this.props; return ( -
      onClick(e)} className='vlm-list-item vlm-list-item-fg' data-test-id='vlm-list-item-fg'> - - +
      onClick(e)} + className={`vlm-list-item vlm-list-item-fg ${isOrphan ? 'orphan-list-item' : ''} ${children.length && !isOrphan ? 'clickable' : ''}`} data-test-id='vlm-list-item-fg'> + {!isOrphan && } +
      - Entitlement Pools: + {i18n('Entitlement Pools: ')} {`${children.filter(child => child.itemType === overviewEditorHeaders.ENTITLEMENT_POOL).length}`} + | - License Key Groups: + {i18n('License Key Groups: ')} {`${children.filter(child => child.itemType === overviewEditorHeaders.LICENSE_KEY_GROUP).length}`}
      + + +
      ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx index dd4686d330..dfbbe20d69 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx @@ -15,7 +15,7 @@ */ import React, {Component} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; import {optionsInputValues} from '../../licenseAgreement/LicenseAgreementConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; @@ -24,14 +24,17 @@ import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/Ad class LicenseAgreement extends Component { render() { - let {laData: {name, description, licenseTerm, children = []}, isCollapsed, onClick} = this.props; + let {laData: {name, description, licenseTerm, children = []}, isCollapsed, onClick, isOrphan} = this.props; return ( -
      onClick(e)} className='vlm-list-item vlm-list-item-la' data-test-id='vlm-list-la-item'> - - +
      onClick(e)} + className={`vlm-list-item vlm-list-item-la ${isOrphan ? 'orphan-list-item' : ''} ${children.length && !isOrphan ? 'clickable' : ''} `} + data-test-id='vlm-list-la-item'> + {!isOrphan && } +
      - Feature Groups: {`${children.length}`} + {i18n('Feature Groups: ')}{`${children.length}`}
      diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx index 9722b83336..b1036aae23 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx @@ -23,17 +23,17 @@ import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/Ad class LicenseKeyGroup extends Component { render() { - let {lkgData: {name, description, operationalScope, type}} = this.props; + let {lkgData: {name, description, operationalScope, type}, isOrphan} = this.props; return ( -
      - - +
      + {!isOrphan && } + - + value={getOperationalScopes(operationalScope)}/>} -
      +
      {text}
      ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx index 730ccb33f1..3d81aa5d5c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx @@ -15,19 +15,26 @@ */ import React from 'react'; import {selectedButton} from '../LicenseModelOverviewConstants.js'; +import Tabs from 'sdc-ui/lib/react/Tabs.js'; +import Tab from 'sdc-ui/lib/react/Tab.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; -function ListButtons ({onTabSelect, selectedInUse}) { +function ListButtons ({onTabSelect, selectedTab}) { return ( -
      -
      onTabSelect(selectedButton.VLM_LIST_VIEW)} - className={selectedInUse ? 'button-vlm-list-view vlm-list-icon selected' : 'button-vlm-list-view vlm-list-icon' } - data-test-id='vlm-overview-vlmlist-tab'>
      -
      onTabSelect(selectedButton.NOT_IN_USE)} - className={selectedInUse ? 'button-vlm-list-view entities-list-icon' : 'button-vlm-list-view entities-list-icon selected' } - data-test-id='vlm-overview-orphans-tab' > -
      - -
      + onTabSelect(tabId)} + activeTab={selectedTab} + className='overview-buttons-section' + type='header' > + + + ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js index 1d65ab9869..87559901b3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js @@ -13,9 +13,11 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React from 'react'; +import React, {Component} from 'react'; import {connect} from 'react-redux'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import licenseModelOverviewActionHelper from '../licenseModelOverviewActionHelper.js'; import LicenseModelActionHelper from '../../LicenseModelActionHelper.js'; @@ -46,9 +48,7 @@ const mapActionsToProps = (dispatch) => { }; }; - - -export class VendorDataView extends React.Component { +export class VendorDataView extends Component { render() { let {data: {vendorName}, description, isReadOnlyMode} = this.props; return ( @@ -62,13 +62,16 @@ export class VendorDataView extends React.Component { ); } + renderDescription() { let {data: {description}, onVendorDescriptionEdit, isReadOnlyMode} = this.props; return ( -
      {if (!isReadOnlyMode) {onVendorDescriptionEdit(description);}}} className={!isReadOnlyMode ? 'vendor-description' : 'vendor-description-readonly'}> -
      - {description} -
      +
      {if (!isReadOnlyMode) {onVendorDescriptionEdit(description);}}} className={!isReadOnlyMode ? 'vendor-description' : 'vendor-description-readonly'}> + {this.renderOverlay( +
      + {description} +
      + )}
      ); } @@ -80,7 +83,21 @@ export class VendorDataView extends React.Component { ); } + renderOverlay(children) { + let {data: {description}, isReadOnlyMode} = this.props; + if (isReadOnlyMode) { + return ( + {description}} + delayShow={400}> + {children} + + ); + } + return children; + } + } export default connect(mapStateToProps, mapActionsToProps)(VendorDataView); - diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx index 3b3e2fcf40..5939499ec5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx @@ -49,7 +49,7 @@ const CatalogTileVendorName = ({vendorName, catalogItemTypeClass}) => { }; const CatalogTileItemName = ({name}) => ( - +
      {name}
      ); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index 07d6c740e0..c9c95f359e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -36,7 +36,7 @@ function getActiveNavigationId(screen, componentId) { return activeItemId; } -const buildComponentNavigationBarGroups = ({componentId, meta, hasImages}) => { +const buildComponentNavigationBarGroups = ({componentId, meta}) => { const groups = ([ { id: navigationItems.GENERAL + '|' + componentId, @@ -67,7 +67,6 @@ const buildComponentNavigationBarGroups = ({componentId, meta, hasImages}) => { id: navigationItems.IMAGES + '|' + componentId, name: i18n('Images'), disabled: false, - hidden: (!hasImages), meta }, { id: navigationItems.PROCESS_DETAILS + '|' + componentId, @@ -85,7 +84,7 @@ const buildComponentNavigationBarGroups = ({componentId, meta, hasImages}) => { return groups; }; -const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds, imagesNavigationList}) => { +const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}) => { const {softwareProductEditor: {data: currentSoftwareProduct = {}}} = softwareProduct; const {id, name, onboardingMethod} = currentSoftwareProduct; const groups = [{ @@ -148,8 +147,7 @@ const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, co name: displayName, meta, expanded: mapOfExpandedIds[navigationItems.COMPONENTS + '|' + id] === true && screen !== enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, - items: buildComponentNavigationBarGroups({componentId: id, meta, - hasImages : (onboardingMethod === onboardingMethodTypes.MANUAL || imagesNavigationList[id] === true)}) + items: buildComponentNavigationBarGroups({componentId: id, meta}) })) ] } @@ -193,12 +191,12 @@ function buildMeta({softwareProduct, componentId, softwareProductDependencies}) const mapStateToProps = ({softwareProduct}, {currentScreen: {screen, props: {componentId}}}) => { const {softwareProductEditor, softwareProductComponents, softwareProductDependencies} = softwareProduct; const {mapOfExpandedIds = []} = softwareProductEditor; - const {componentsList = [], images: {imagesNavigationList}} = softwareProductComponents; + const {componentsList = []} = softwareProductComponents; const meta = buildMeta({softwareProduct, componentId, softwareProductDependencies}); return { versionControllerProps: buildVersionControllerProps(softwareProduct), - navigationBarProps: buildNavigationBarProps({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds, imagesNavigationList}), + navigationBarProps: buildNavigationBarProps({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}), meta }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index d6ba86ad6e..90a2bb8f2e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -251,8 +251,7 @@ const SoftwareProductActionHelper = { processAndValidateHeatCandidate(dispatch, {softwareProductId, version}){ return validateHeatCandidate(softwareProductId, version).then(response => { if (response.status === 'Success') { - let isFetchImageDetails = true; - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version, isFetchImageDetails}); + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index 5248c4e8fd..977a76ac69 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -35,7 +35,6 @@ import SoftwareProductComponentsNICListReducer from './components/network/Softwa import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js'; import SoftwareProductComponentsImageListReducer from './components/images/SoftwareProductComponentsImageListReducer.js'; import SoftwareProductComponentsImageEditorReducer from './components/images/SoftwareProductComponentsImageEditorReducer.js'; -import SoftwareProductComponentsImageNavigationReducer from './components/images/SoftwareProductComponentsImageNavigationReducer.js'; import SoftwareProductComponentsNICCreationReducer from './components/network/NICCreation/NICCreationReducer.js'; import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.js'; import SoftwareProductComponentsComputeFlavorListReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js'; @@ -83,7 +82,6 @@ export default combineReducers({ }), images: combineReducers({ imagesList: SoftwareProductComponentsImageListReducer, - imagesNavigationList: SoftwareProductComponentsImageNavigationReducer, imageEditor: createPlainDataReducer(createComposedJSONSchemaReducer(IMAGE_QUESTIONNAIRE, SoftwareProductComponentsImageEditorReducer)) }), computeFlavor: combineReducers({ diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js index 53143647a3..87953bb8aa 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js @@ -17,8 +17,8 @@ import {actionTypes} from './HeatSetupConstants.js'; import isEqual from 'lodash/isEqual.js'; import cloneDeep from 'lodash/cloneDeep.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +// import i18n from 'nfvo-utils/i18n/i18n.js'; +// import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; export default { @@ -56,7 +56,11 @@ export default { dispatch({type: actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS}); }, - heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) { + heatSetupLeaveConfirmation() { + return Promise.resolve(); + } + + /*heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) { return new Promise((resolve, reject) => { if (isEqual({...heatSetup, softwareProductId}, heatSetupCache)) { resolve(); @@ -73,5 +77,5 @@ export default { }); } }); - } + }*/ }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js index 71dc8325ad..8085c875f4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js @@ -18,7 +18,6 @@ import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes, COMPONENTS_QUESTIONNAIRE} from './SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import SoftwareProductComponentsImageActionHelper from './images/SoftwareProductComponentsImageActionHelper.js'; import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; function baseUrl(softwareProductId, version) { @@ -69,32 +68,12 @@ function postSoftwareProductComponent(softwareProductId, vspComponent, version) const SoftwareProductComponentsActionHelper = { - fetchSoftwareProductComponents(dispatch, {softwareProductId, version, isFetchImageDetails = false}) { + fetchSoftwareProductComponents(dispatch, {softwareProductId, version}) { return fetchSoftwareProductComponents(softwareProductId, version).then(response => { - let componentImagesCalls = []; - if (isFetchImageDetails && response.listCount) { - response.results.map(component => { - let componentId = component.id; - componentImagesCalls[componentImagesCalls.length] = - SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, { - softwareProductId, - componentId, - version - }); - - }); - return Promise.all(componentImagesCalls).then(() => { - dispatch({ - type: actionTypes.COMPONENTS_LIST_UPDATE, - componentsList: response.results - }); - }); - } else { - dispatch({ - type: actionTypes.COMPONENTS_LIST_UPDATE, - componentsList: response.results - }); - } + dispatch({ + type: actionTypes.COMPONENTS_LIST_UPDATE, + componentsList: response.results + }); }); }, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js index 86c4e072d4..fb3bd35eb2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js @@ -77,9 +77,10 @@ const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { image, isReadOnlyMode, softwareProductId, componentId, version, modalClassName: 'image-modal-edit'} ); }, - onSubmit: ({qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, + onSubmit: (version, qdata) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId: componentId, + version, qdata}); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx index ccf5b9d6b1..54def08fc1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx @@ -125,8 +125,8 @@ class SoftwareProductComponentsImageListView extends React.Component { } save() { - let {onSubmit, qdata} = this.props; - return onSubmit({qdata}); + let {onSubmit, qdata, version} = this.props; + return onSubmit(version, qdata); } } export default SoftwareProductComponentsImageListView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageNavigationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageNavigationReducer.js deleted file mode 100644 index 20d1f5dd18..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageNavigationReducer.js +++ /dev/null @@ -1,32 +0,0 @@ -/*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -import {actionTypes} from './SoftwareProductComponentsImageConstants.js'; - -export default (state = {}, action) => { - switch (action.type) { - - case actionTypes.IMAGES_LIST_UPDATE: - if (action.componentId) { - return { - ...state, - [action.componentId] : (action.response && action.response.length > 0) - }; - } - return state; - default: - return state; - } -}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx index 2ad48ec84b..36c1728ef3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx @@ -96,7 +96,7 @@ class SoftwareProductComponentsMonitoringView extends Component { - + ); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx index 5a159b4a87..4d460c722d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx @@ -122,7 +122,7 @@ class SoftwareProductComponentsNetworkView extends React.Component {
      {i18n('Purpose of NIC')}
      -
      {description ? description : i18n('N/A')}
      + {description &&
      {description}
      }
      {!isManual &&
      {i18n('Network')}
      diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js index 18a3b1e8ff..7149adbbfb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js @@ -33,14 +33,15 @@ const mapStateToProps = ({softwareProduct}) => { qdata, isReadOnlyMode, qGenericFieldInfo, - dataMap + dataMap, + version: currentVSP.version }; }; -const mapActionToProps = (dispatch, {softwareProductId, version, componentId}) => { +const mapActionToProps = (dispatch, {softwareProductId, componentId}) => { return { onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), - onSubmit: ({componentData, qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, + onSubmit: ({componentData, qdata, version}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId: componentId, componentData, qdata}); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx index 28bdf8e5e5..00df21bb59 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx @@ -162,7 +162,7 @@ class SoftwareProductComponentStorageView extends React.Component { }; render() { - let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata} = this.props; + let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata, version} = this.props; return(
      @@ -170,7 +170,7 @@ class SoftwareProductComponentStorageView extends React.Component { ref={form => this.form = form } isValid={true} formReady={null} - onSubmit={() => onSubmit({qdata})} + onSubmit={() => onSubmit({qdata, version})} className='component-questionnaire-validation-form' isReadOnlyMode={isReadOnlyMode} hasButtons={false}> @@ -182,8 +182,9 @@ class SoftwareProductComponentStorageView extends React.Component { ); } - save(){ - return this.form.handleFormSubmit(new Event('dummy')); + save(){ + const {componentData, qdata, onSubmit, version} = this.props; + return onSubmit({componentData, qdata, version}); } } 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 19e2d5b0db..3b973c65cd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js @@ -27,7 +27,7 @@ export const mapStateToProps = ({finalizedLicenseModelList, softwareProductList, let VSPNames = {}; for (let i = 0; i < softwareProductList.length; i++) { - VSPNames[softwareProductList[i].name] = softwareProductList[i].id; + VSPNames[softwareProductList[i].name.toLowerCase()] = softwareProductList[i].id; } return { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx index 2e0cd340de..a427470a4f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx @@ -63,14 +63,15 @@ export default class SoftwareProductDependenciesView extends React.Component { numOfIcons={2} isReadOnlyMode={isReadOnlyMode} onAdd={canAdd ? onAddDependency : undefined} - onAddItem={i18n('Add Rule')}> + onAddItem={i18n('Add Rule')}> {softwareProductDependencies.map(dependency => ( onDataChanged(softwareProductDependencies.filter(currentDependency => currentDependency.id !== dependency.id))} overlayMsg={i18n('There is a loop between selections')} hasError={dependency.hasCycle} - hasErrorIndication> + hasErrorIndication + showDelete={dependency.id !== 'fake' || dependency.hasCycle !== undefined}> { - DFNames[deployment.model] = deployment.id; + DFNames[deployment.model.toLowerCase()] = deployment.id; }); return { 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 98dd7730bd..e4caf92c21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -19,7 +19,7 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; -import InputOptions from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; -- cgit 1.2.3-korg