From 804ec686128a49628e9f656397e4a4512e4c5714 Mon Sep 17 00:00:00 2001 From: Vodafone Date: Mon, 18 Mar 2019 15:46:53 +0530 Subject: List of Input Parameters for VSP: FE Change-Id: I17697b5646c1a201678dbab11fef28a7483fbf8c Issue-ID: SDC-2049 Co-authored-by: rahul.ghugikar@vodafone.com, soumyarup.paul@vodafone.com Signed-off-by: Vodafone --- .../sdc-app/onboarding/OnboardingActionHelper.js | 56 +++ .../src/sdc-app/onboarding/OnboardingConstants.js | 6 + .../src/sdc-app/onboarding/OnboardingPunchOut.jsx | 57 ++- .../src/sdc-app/onboarding/OnboardingView.jsx | 19 + .../onboarding/softwareProduct/SoftwareProduct.js | 17 + .../softwareProduct/SoftwareProductReducer.js | 4 + .../validation/SoftwareProductValidation.js | 89 +++++ .../SoftwareProductValidationActionHelper.js | 160 +++++++++ .../SoftwareProductValidationConstants.js | 36 ++ .../validation/SoftwareProductValidationReducer.js | 66 ++++ .../validation/SoftwareProductValidationView.jsx | 387 +++++++++++++++++++++ .../validation/inputs/VspValidationInputs.js | 28 ++ .../validation/inputs/VspValidationInputsView.jsx | 297 ++++++++++++++++ .../validation/setup/VspValidationSetup.js | 32 ++ .../validation/setup/VspValidationSetupView.jsx | 320 +++++++++++++++++ .../SoftwareProductValidationResults.js | 28 ++ .../SoftwareProductValidationResultsView.jsx | 207 +++++++++++ 17 files changed, 1805 insertions(+), 4 deletions(-) create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetup.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx (limited to 'openecomp-ui/src/sdc-app/onboarding') diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js index c3cf8b292f..8385da750f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js @@ -48,6 +48,8 @@ import { actionTypes as filterActionTypes } from './onboard/filter/FilterConstan import FeaturesActionHelper from 'sdc-app/features/FeaturesActionHelper.js'; import { notificationActions } from 'nfvo-components/notification/NotificationsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import SoftwareProductValidationActionHelper from './softwareProduct/validation/SoftwareProductValidationActionHelper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; function setCurrentScreen(dispatch, screen, props = {}) { dispatch({ @@ -88,6 +90,13 @@ const OnboardingActionHelper = { }); }, + saveIsValidationDisabled(dispatch, { isValidationDisabled }) { + SoftwareProductValidationActionHelper.setIsVspValidationDisabled( + dispatch, + { isValidationDisabled } + ); + }, + autoSaveBeforeNavigate( dispatch, { softwareProductId, version, vspComponentId, dataToSave } @@ -381,6 +390,53 @@ const OnboardingActionHelper = { }); }, + navigateToSoftwareProductValidation( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductValidationActionHelper.fetchVspChecks(dispatch) + .then(() => { + SoftwareProductValidationActionHelper.setCertificationChecked( + dispatch, + [] + ); + SoftwareProductValidationActionHelper.setComplianceChecked( + dispatch, + [] + ); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION, + { + softwareProductId, + version, + status + } + ); + }) + .catch(error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: 'ERROR', + msg: error.responseJSON.message, + cancelButtonText: i18n('OK') + } + }); + }); + }, + + navigateToSoftwareProductValidationResults( + dispatch, + { softwareProductId, version, status } + ) { + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, + { softwareProductId, version, status } + ); + }, + navigateToSoftwareProductDependencies( dispatch, { softwareProductId, version, status } diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js index 97e82ef9b0..cf8ff12387 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js @@ -53,6 +53,8 @@ const breadcrumbsEnum = { SOFTWARE_PRODUCT_PROCESSES: 'SOFTWARE_PRODUCT_PROCESSES', SOFTWARE_PRODUCT_DEPLOYMENT: 'SOFTWARE_PRODUCT_DEPLOYMENT', SOFTWARE_PRODUCT_NETWORKS: 'SOFTWARE_PRODUCT_NETWORKS', + SOFTWARE_PRODUCT_VALIDATION: 'SOFTWARE_PRODUCT_VALIDATION', + SOFTWARE_PRODUCT_VALIDATION_RESULTS: 'SOFTWARE_PRODUCT_VALIDATION_RESULTS', SOFTWARE_PRODUCT_DEPENDENCIES: 'SOFTWARE_PRODUCT_DEPENDENCIES', SOFTWARE_PRODUCT_ACTIVITY_LOG: 'SOFTWARE_PRODUCT_ACTIVITY_LOG', SOFTWARE_PRODUCT_COMPONENTS: 'SOFTWARE_PRODUCT_COMPONENTS', @@ -97,6 +99,10 @@ export const enums = keyMirror({ SOFTWARE_PRODUCT_DEPLOYMENT: breadcrumbsEnum.SOFTWARE_PRODUCT_DEPLOYMENT, SOFTWARE_PRODUCT_NETWORKS: breadcrumbsEnum.SOFTWARE_PRODUCT_NETWORKS, + SOFTWARE_PRODUCT_VALIDATION: + breadcrumbsEnum.SOFTWARE_PRODUCT_VALIDATION, + SOFTWARE_PRODUCT_VALIDATION_RESULTS: + breadcrumbsEnum.SOFTWARE_PRODUCT_VALIDATION_RESULTS, SOFTWARE_PRODUCT_DEPENDENCIES: breadcrumbsEnum.SOFTWARE_PRODUCT_DEPENDENCIES, SOFTWARE_PRODUCT_ACTIVITY_LOG: diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx index a73501468c..d50fcccf09 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx @@ -26,7 +26,7 @@ import Application from 'sdc-app/Application.jsx'; import store from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; - +import ConfigHelper from 'sdc-app/common/helpers/ConfigHelper.js'; import { onboardingMethod as onboardingMethodTypes, onboardingOriginTypes @@ -38,9 +38,32 @@ import { AppContainer } from 'react-hot-loader'; import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; import { actionTypes, enums, screenTypes } from './OnboardingConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import OnboardingActionHelper from './OnboardingActionHelper.js'; import Onboarding from './Onboarding.js'; +ConfigHelper.fetchVspConfig() + .then(response => { + let dispatch = action => store.dispatch(action); + OnboardingActionHelper.saveIsValidationDisabled(dispatch, { + isValidationDisabled: + response.enabled === undefined || response.enabled === '' + ? true + : !response.enabled + }); + }) + .catch(error => { + let dispatch = action => store.dispatch(action); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('ERROR'), + msg: error.message || error.responseJSON.message, + cancelButtonText: i18n('OK') + } + }); + }); + export default class OnboardingPunchOut { render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) { if (!this.unsubscribeFromStore) { @@ -360,7 +383,8 @@ export default class OnboardingPunchOut { softwareProductEditor: { data: currentSoftwareProduct = { onboardingMethod: '' } }, - softwareProductComponents: { componentsList } + softwareProductComponents: { componentsList }, + softwareProductValidation: { isValidationDisabled } }, licenseModel: { licenseModelEditor: { data: currentLicenseModel = {} } @@ -373,7 +397,8 @@ export default class OnboardingPunchOut { currentScreen, currentSoftwareProduct, currentLicenseModel, - componentsList + componentsList, + isValidationDisabled }; if ( @@ -402,7 +427,8 @@ export default class OnboardingPunchOut { itemId, currentSoftwareProduct, currentLicenseModel, - componentsList + componentsList, + isValidationDisabled }) { let { onboardingMethod, @@ -553,6 +579,8 @@ export default class OnboardingPunchOut { case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS: case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: @@ -578,6 +606,10 @@ export default class OnboardingPunchOut { enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, + [enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_VALIDATION, + [enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_VALIDATION_RESULTS, [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: @@ -673,6 +705,18 @@ export default class OnboardingPunchOut { .SOFTWARE_PRODUCT_NETWORKS, displayText: i18n('Networks') }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_VALIDATION, + displayText: i18n('Validation') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_VALIDATION_RESULTS, + displayText: i18n('Validation Results') + }, { key: enums.BREADCRUMS @@ -719,6 +763,11 @@ export default class OnboardingPunchOut { case enums.BREADCRUMS .SOFTWARE_PRODUCT_DEPENDENCIES: return componentsList.length > 1; + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_VALIDATION: + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_VALIDATION_RESULTS: + return !isValidationDisabled; default: return true; } diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx index 7156e2e253..d4358909d5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx @@ -31,6 +31,8 @@ import SoftwareProductAttachments from './softwareProduct/attachments/SoftwarePr import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js'; import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js'; +import SoftwareProductValidation from './softwareProduct/validation/SoftwareProductValidation.js'; +import SoftwareProductValidationResults from './softwareProduct/validationResults/SoftwareProductValidationResults.js'; import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js'; import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js'; @@ -145,6 +147,8 @@ export default class OnboardingView extends React.Component { case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS: case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: @@ -204,6 +208,21 @@ export default class OnboardingView extends React.Component { {...props} /> ); + case enums.SCREEN + .SOFTWARE_PRODUCT_VALIDATION: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_VALIDATION_RESULTS: + return ( + + ); case enums.SCREEN .SOFTWARE_PRODUCT_DEPENDENCIES: return ( diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index d3d7b96a5d..1362165d1f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -140,6 +140,7 @@ const buildNavigationBarProps = ({ candidateOnboardingOrigin, onboardingOrigin } = currentSoftwareProduct; + let { isValidationDisabled } = softwareProduct.softwareProductValidation; const groups = [ { id: id, @@ -176,6 +177,20 @@ const buildNavigationBarProps = ({ disabled: false, meta }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION, + name: i18n('Validation'), + disabled: false, + hidden: isValidationDisabled, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, + name: i18n('Validation Results'), + disabled: false, + hidden: isValidationDisabled, + meta + }, { id: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, name: i18n('Attachments'), @@ -586,6 +601,8 @@ const mapActionsToProps = ( case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION: + case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS: case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index fd4f02cde1..7b8c426964 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -25,6 +25,7 @@ import { actionTypes as heatSetupActionTypes } from './attachments/setup/HeatSet import SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js'; import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js'; import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js'; +import SoftwareProductValidationReducer from './validation/SoftwareProductValidationReducer.js'; import SoftwareProductProcessesEditorReducer from './processes/SoftwareProductProcessesEditorReducer.js'; import SoftwareProductDeploymentListReducer from './deployment/SoftwareProductDeploymentListReducer.js'; import SoftwareProductDeploymentEditorReducer from './deployment/editor/SoftwareProductDeploymentEditorReducer.js'; @@ -74,6 +75,9 @@ export default combineReducers({ softwareProductEditor: createPlainDataReducer( SoftwareProductDetailsReducer ), + softwareProductValidation: createPlainDataReducer( + SoftwareProductValidationReducer + ), softwareProductProcesses: combineReducers({ processesList: SoftwareProductProcessesListReducer, processesEditor: createPlainDataReducer( diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js new file mode 100644 index 0000000000..a6237e878a --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 SoftwareProductValidationView from './SoftwareProductValidationView.jsx'; +import SoftwareProductValidationActionHelper from './SoftwareProductValidationActionHelper.js'; + +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductValidation } = softwareProduct; + return { + softwareProductValidation + }; +}; + +export const mapActionsToProps = dispatch => { + return { + onErrorThrown: msg => { + SoftwareProductValidationActionHelper.onErrorThrown(dispatch, msg); + }, + + onTestSubmit: (softwareProductId, version, status, tests) => { + SoftwareProductValidationActionHelper.navigateToSoftwareProductValidationResults( + dispatch, + { + softwareProductId, + version, + status, + tests + } + ); + }, + + setVspTestsMap: map => { + SoftwareProductValidationActionHelper.setVspTestsMap(dispatch, map); + }, + + setActiveTab: activeTab => { + SoftwareProductValidationActionHelper.setActiveTab( + dispatch, + activeTab + ); + }, + + setComplianceChecked: ({ checked }) => { + SoftwareProductValidationActionHelper.setComplianceChecked( + dispatch, + checked + ); + }, + + setCertificationChecked: ({ checked }) => { + SoftwareProductValidationActionHelper.setCertificationChecked( + dispatch, + checked + ); + }, + + setTestsRequest: (request, info) => { + SoftwareProductValidationActionHelper.setTestsRequest( + dispatch, + request, + info + ); + }, + + setGeneralInfo: info => { + SoftwareProductValidationActionHelper.setGeneralInfo( + dispatch, + info + ); + } + }; +}; + +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductValidationView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js new file mode 100644 index 0000000000..d19416a2aa --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js @@ -0,0 +1,160 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; +import Configuration from 'sdc-app/config/Configuration.js'; +import getValue from 'nfvo-utils/getValue.js'; +import { actionTypes } from './SoftwareProductValidationConstants.js'; +import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; + +function postVSPCertificationChecks(tests) { + const restPrefix = Configuration.get('restPrefix'); + return RestAPIUtil.post( + `${restPrefix}/v1.0/externaltesting/executions`, + getValue(tests) + ); +} + +function fetchVspChecks() { + const restPrefix = Configuration.get('restPrefix'); + return RestAPIUtil.get(`${restPrefix}/v1.0/externaltesting/testcasetree`); +} + +const SoftwareProductValidationActionHelper = { + navigateToSoftwareProductValidationResults( + dispatch, + { softwareProductId, version, status, tests } + ) { + postVSPCertificationChecks(tests) + .then(response => { + dispatch({ + type: actionTypes.POST_VSP_TESTS, + vspTestResults: response + }); + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version, + status + } + }); + }) + .catch(error => { + let errMessage = error.message || error.responseJSON.message; + let title = error.responseJSON + ? error.responseJSON.status + : i18n('Error'); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: title, + msg: errMessage, + cancelButtonText: i18n('OK') + } + }); + }); + }, + + fetchVspChecks(dispatch) { + return new Promise((resolve, reject) => { + fetchVspChecks() + .then(response => { + dispatch({ + type: actionTypes.FETCH_VSP_CHECKS, + vspChecks: response + }); + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, + + setActiveTab(dispatch, { activeTab }) { + dispatch({ + type: actionTypes.SET_ACTIVE_TAB, + activeTab + }); + }, + + onErrorThrown(dispatch, msg) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Error'), + modalComponentName: i18n('Error'), + modalComponentProps: { + onClose: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }) + }, + msg: msg, + cancelButtonText: i18n('OK') + } + }); + }, + + setVspTestsMap(dispatch, map) { + dispatch({ + type: actionTypes.SET_VSP_TESTS_MAP, + vspTestsMap: map + }); + }, + + setComplianceChecked(dispatch, checked) { + dispatch({ + type: actionTypes.SET_COMPLIANCE_CHECKED, + complianceChecked: checked + }); + }, + + setCertificationChecked(dispatch, checked) { + dispatch({ + type: actionTypes.SET_CERTIFICATION_CHECKED, + certificationChecked: checked + }); + }, + + setTestsRequest(dispatch, request, info) { + dispatch({ + type: actionTypes.SET_TESTS_REQUEST, + testsRequest: request, + generalInfo: info + }); + }, + + setGeneralInfo(dispatch, info) { + dispatch({ + type: actionTypes.SET_GENERAL_INFO, + generalInfo: info + }); + }, + + setIsVspValidationDisabled(dispatch, { isValidationDisabled }) { + dispatch({ + type: actionTypes.SET_VSP_VALIDATION_DISABLED, + isValidationDisabled: isValidationDisabled + }); + } +}; + +export default SoftwareProductValidationActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js new file mode 100644 index 0000000000..2dc5a1cc43 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const tabsMapping = { + SETUP: 1, + INPUTS: 2 +}; + +export const actionTypes = keyMirror( + { + POST_VSP_TESTS: null, + FETCH_VSP_CHECKS: null, + SET_ACTIVE_TAB: null, + SET_VSP_TESTS_MAP: null, + SET_COMPLIANCE_CHECKED: null, + SET_CERTIFICATION_CHECKED: null, + SET_TESTS_REQUEST: null, + SET_GENERAL_INFO: null, + SET_VSP_VALIDATION_DISABLED: null + }, + 'SoftwareProductValidation' +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js new file mode 100644 index 0000000000..4513e23205 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 './SoftwareProductValidationConstants.js'; + +export default (state = {}, action) => { + switch (action.type) { + case actionTypes.POST_VSP_TESTS: + return { + ...state, + vspTestResults: action.vspTestResults + }; + case actionTypes.FETCH_VSP_CHECKS: + return { + ...state, + vspChecks: action.vspChecks + }; + case actionTypes.SET_ACTIVE_TAB: + return { ...state, activeTab: action.activeTab }; + case actionTypes.SET_VSP_TESTS_MAP: + return { + ...state, + vspTestsMap: action.vspTestsMap + }; + case actionTypes.SET_COMPLIANCE_CHECKED: + return { + ...state, + complianceChecked: action.complianceChecked + }; + case actionTypes.SET_CERTIFICATION_CHECKED: + return { + ...state, + certificationChecked: action.certificationChecked + }; + case actionTypes.SET_TESTS_REQUEST: + return { + ...state, + testsRequest: action.testsRequest, + generalInfo: action.generalInfo + }; + case actionTypes.SET_GENERAL_INFO: + return { + ...state, + generalInfo: action.generalInfo + }; + case actionTypes.SET_VSP_VALIDATION_DISABLED: + return { + ...state, + isValidationDisabled: action.isValidationDisabled + }; + default: + return state; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx new file mode 100644 index 0000000000..8611c41937 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx @@ -0,0 +1,387 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import i18n from 'nfvo-utils/i18n/i18n.js'; +import Button from 'sdc-ui/lib/react/Button.js'; +import { Tab, Tabs } from 'sdc-ui/lib/react'; +import { tabsMapping } from './SoftwareProductValidationConstants.js'; +import VspValidationInputs from './inputs/VspValidationInputs.js'; +import VspValidationSetup from './setup/VspValidationSetup.js'; + +class SoftwareProductValidation extends Component { + static propTypes = { + onErrorThrown: PropTypes.func, + softwareProductValidation: PropTypes.object, + onTestSubmit: PropTypes.func, + setVspTestsMap: PropTypes.func, + setActiveTab: PropTypes.func, + setComplianceChecked: PropTypes.func, + setCertificationChecked: PropTypes.func + }; + + constructor(props) { + super(props); + this.state = { + complianceCheckList: null, + certificationCheckList: null, + flatTestsMap: {}, + generalInfo: {}, + activeTab: tabsMapping.SETUP, + goToValidationInput: false + }; + } + + setMapAndGeneralData(element, testScenario) { + let flatTestMap = this.state.flatTestsMap; + let generalInputData = this.state.generalInfo; + flatTestMap[element.testCaseName] = { + title: element.description, + parameters: element.inputs, + endpoint: element.endpoint, + testCaseName: element.testCaseName, + testSuiteName: element.testSuiteName, + scenario: testScenario + }; + generalInputData[element.testCaseName] = {}; + element.inputs.forEach(key => { + generalInputData[element.testCaseName][key.name] = { + isValid: true, + errorText: '' + }; + }); + + this.setState({ + flatTestsMap: flatTestMap, + generalInfo: generalInputData + }); + } + + buildChildElements(setItem, testScenario) { + let parentElement = {}; + parentElement.value = setItem.name; + parentElement.label = setItem.description; + parentElement.children = []; + if (setItem.children !== undefined) { + setItem.children.forEach(element => { + let childElement = this.buildChildElements( + element, + testScenario + ); + if (childElement.children.length !== 0) { + parentElement.children.push(childElement); + } + }); + } + if (setItem.tests !== undefined) { + setItem.tests.forEach(element => { + parentElement.children.push({ + value: element.testCaseName, + label: element.description + }); + this.setMapAndGeneralData(element, testScenario); + }); + } + return parentElement; + } + + buildCheckboxParentNode(parentNode, data) { + parentNode.value = data.description; + parentNode.label = 'All'; + parentNode.children = []; + let scenario = data.name; + data.children.forEach(element => { + let childElement = this.buildChildElements(element, scenario); + if (childElement.children.length !== 0) { + parentNode.children.push(childElement); + } + }); + if (data.tests !== undefined) { + data.tests.forEach(element => { + parentNode.children.push({ + value: element.testCaseName, + label: element.description + }); + this.setMapAndGeneralData(element, scenario); + }); + } + return parentNode; + } + + prepareDataForCheckboxes(res) { + let complianceData = {}; + let certificationData = {}; + let complianceList = []; + let certificationList = []; + let { setVspTestsMap } = this.props; + if (Object.keys(res).length !== 0 && res.children) { + res.children.forEach(element => { + if (element.name === 'certification') { + certificationData = element; + } else if (element.name === 'compliance') { + complianceData = element; + } + }); + + let complianceParentNode = {}; + if ( + Object.keys(complianceData).length !== 0 && + complianceData.children !== undefined + ) { + complianceParentNode = this.buildCheckboxParentNode( + complianceParentNode, + complianceData + ); + if (complianceParentNode.children.length !== 0) { + complianceList.push(complianceParentNode); + } + } + + let certificationParentNode = {}; + if ( + Object.keys(certificationData).length !== 0 && + certificationData.children !== undefined + ) { + certificationParentNode = this.buildCheckboxParentNode( + certificationParentNode, + certificationData + ); + if (certificationParentNode.children.length !== 0) { + certificationList.push(certificationParentNode); + } + } + } + this.setState({ + certificationCheckList: certificationList, + complianceCheckList: complianceList + }); + setVspTestsMap(this.state.flatTestsMap); + } + + resetState() { + this.setState({ + complianceCheckList: [], + certificationCheckList: [], + flatTestsMap: {}, + activeTab: tabsMapping.SETUP, + goToValidationInput: false + }); + } + + componentWillMount() {} + + shouldComponentUpdate() { + return true; + } + + componentDidMount() { + let { softwareProductValidation } = this.props; + if (softwareProductValidation.vspChecks !== undefined) { + this.prepareDataForCheckboxes(softwareProductValidation.vspChecks); + } + } + + componentWillUnmount() { + this.resetState(); + } + + componentWillReceiveProps(nextProps) { + if ( + nextProps.softwareProductValidation.vspChecks !== + this.props.softwareProductValidation.vspChecks + ) { + let { softwareProductValidation, setActiveTab } = nextProps; + if (softwareProductValidation.vspChecks !== undefined) { + this.prepareDataForCheckboxes( + softwareProductValidation.vspChecks + ); + } + this.setState({ activeTab: tabsMapping.SETUP }); + setActiveTab({ activeTab: tabsMapping.SETUP }); + } + } + + prepareDataForValidationInputsSection() { + let { + softwareProductId, + version, + onTestSubmit, + onErrorThrown, + setTestsRequest, + setGeneralInfo + } = this.props; + return { + softwareProductId, + version, + onTestSubmit, + onErrorThrown, + setTestsRequest, + setGeneralInfo + }; + } + + prepareDataForCheckboxTreeSection() { + let { + softwareProductValidation, + setComplianceChecked, + setCertificationChecked + } = this.props; + let complianceCheckList = this.state.complianceCheckList; + let certificationCheckList = this.state.certificationCheckList; + return { + softwareProductValidation, + setComplianceChecked, + setCertificationChecked, + complianceCheckList, + certificationCheckList + }; + } + + handleTabPress(key) { + let { setActiveTab } = this.props; + switch (key) { + case tabsMapping.SETUP: + this.setState({ activeTab: tabsMapping.SETUP }); + setActiveTab({ activeTab: tabsMapping.SETUP }); + return; + case tabsMapping.INPUTS: + default: + setActiveTab({ activeTab: tabsMapping.INPUTS }); + this.setState({ + goToValidationInput: true, + activeTab: tabsMapping.INPUTS + }); + return; + } + } + + formTestsRequest(item, testsRequest) { + let { vspTestsMap } = this.props.softwareProductValidation; + testsRequest[item] = { + parameters: {}, + scenario: vspTestsMap[item]['scenario'], + testCaseName: vspTestsMap[item]['testCaseName'], + testSuiteName: vspTestsMap[item]['testSuiteName'], + endpoint: vspTestsMap[item]['endpoint'] + }; + vspTestsMap[item].parameters.forEach(parameter => { + testsRequest[item].parameters[parameter.name] = + parameter.defaultValue || ''; + }); + return testsRequest; + } + + onGoToInputs() { + let { + setActiveTab, + softwareProductValidation, + setTestsRequest + } = this.props; + setActiveTab({ activeTab: tabsMapping.INPUTS }); + let testsRequest = {}; + if (softwareProductValidation.complianceChecked) { + softwareProductValidation.complianceChecked.forEach(item => { + testsRequest = this.formTestsRequest(item, testsRequest); + }); + } + if (softwareProductValidation.certificationChecked) { + softwareProductValidation.certificationChecked.forEach(item => { + testsRequest = this.formTestsRequest(item, testsRequest); + }); + } + setTestsRequest(testsRequest, this.state.generalInfo); + this.setState({ + goToValidationInput: true, + activeTab: tabsMapping.INPUTS + }); + } + + onGoToSetup() { + let { setActiveTab } = this.props; + setActiveTab({ activeTab: tabsMapping.SETUP }); + this.setState({ + goToValidationInput: false, + activeTab: tabsMapping.SETUP + }); + } + + render() { + let { softwareProductValidation } = this.props; + let isNextDisabled = + (softwareProductValidation.certificationChecked === undefined || + softwareProductValidation.certificationChecked.length === 0) && + (softwareProductValidation.complianceChecked === undefined || + softwareProductValidation.complianceChecked.length === 0); + + return ( +
+
+ {this.state.activeTab === tabsMapping.SETUP && ( + + )} + {this.state.activeTab === tabsMapping.INPUTS && ( + + )} +
+ this.handleTabPress(key)}> + +
+ {this.state.complianceCheckList && + this.state.certificationCheckList && ( + + )} +
+
+ +
+ +
+
+
+
+ ); + } +} + +export default SoftwareProductValidation; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js new file mode 100644 index 0000000000..375cd456b6 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 VspValidationInputs from './VspValidationInputsView.jsx'; + +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductValidation } = softwareProduct; + return { + softwareProductValidation + }; +}; + +export default connect(mapStateToProps, null, null, { + withRef: true +})(VspValidationInputs); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx new file mode 100644 index 0000000000..c2990a2058 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx @@ -0,0 +1,297 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import i18n from 'nfvo-utils/i18n/i18n.js'; +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 Input from 'nfvo-components/input/validation/Input.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; + +class VspInputs extends React.Component { + constructor(props) { + super(props); + this.state = {}; + } + + shouldComponentUpdate() { + return true; + } + + changeInputs(e, check, parameterName) { + let { testsRequest, generalInfo, setTestsRequest } = this.props; + testsRequest[check].parameters[parameterName] = e; + generalInfo[check][parameterName] = { isValid: true, errorText: '' }; + setTestsRequest(testsRequest, generalInfo); + } + + renderInputs(check) { + let { vspTestsMap, testsRequest, generalInfo } = this.props; + return ( +
+ + {vspTestsMap[check].parameters.map((parameter, index) => { + if ( + parameter.type === 'text' && + !parameter.metadata.hidden + ) { + return ( + + { + this.changeInputs( + e.target ? e.target.value : e, + check, + parameter.name + ); + }} + disabled={ + parameter.metadata.disabled || false + }> + {parameter.metadata.choices && ( + + )} + {parameter.metadata.choices && + parameter.metadata.choices.map( + selectOption => ( + + ) + )} + + + ); + } + })} + +
+ ); + } + + render() { + let { + complianceChecked, + vspTestsMap, + certificationChecked + } = this.props; + return ( +
+ {complianceChecked.map(complianceCheck => { + if (vspTestsMap[complianceCheck].parameters.length === 0) { + return
; + } else { + return this.renderInputs(complianceCheck); + } + })} + {certificationChecked.map(certificateCheck => { + if (vspTestsMap[certificateCheck].parameters.length === 0) { + return
; + } else { + return this.renderInputs(certificateCheck); + } + })} +
+ ); + } +} + +class VspValidationInputs extends Component { + static propTypes = { + softwareProductValidation: PropTypes.object + }; + + constructor(props) { + super(props); + this.state = {}; + } + + shouldComponentUpdate() { + return true; + } + + validateInputs() { + let areInputsValid = true; + let { softwareProductValidation, setGeneralInfo } = this.props; + let generalInfo = softwareProductValidation.generalInfo; + Object.keys(softwareProductValidation.testsRequest).forEach( + testCaseName => { + let requestParameters = + softwareProductValidation.testsRequest[testCaseName] + .parameters; + let validationParameters = + softwareProductValidation.vspTestsMap[testCaseName] + .parameters; + Object.keys(requestParameters).forEach(parameterName => { + let parameter = validationParameters.find( + o => o.name === parameterName + ); + let isParameterValid = true; + let errorText = ''; + if ( + parameter.type === 'text' && + parameter.metadata.choices + ) { + if ( + !parameter.isOptional && + !requestParameters[parameterName] + ) { + isParameterValid = false; + errorText = i18n('Field is required'); + } + } else if (parameter.type === 'text') { + if ( + !parameter.isOptional && + !requestParameters[parameterName] + ) { + isParameterValid = false; + errorText = i18n('Field is required'); + } else if ( + (!parameter.isOptional && + !requestParameters[parameterName]) || + (parameter.metadata.maxLength && + requestParameters[parameterName].length > + parseInt(parameter.metadata.maxLength)) || + (parameter.metadata.minLength && + requestParameters[parameterName].length < + parseInt(parameter.metadata.minLength) && + requestParameters[parameterName].length > 0) + ) { + isParameterValid = false; + errorText = i18n( + 'Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters', + { + minLength: parameter.metadata.minLength, + maxLength: parameter.metadata.maxLength + } + ); + } + } + generalInfo[testCaseName][ + parameterName + ].isValid = isParameterValid; + generalInfo[testCaseName][ + parameterName + ].errorText = errorText; + areInputsValid = areInputsValid && isParameterValid; + }); + } + ); + if (!areInputsValid) { + setGeneralInfo(generalInfo); + } + return areInputsValid; + } + + performVSPTests() { + let tests = []; + let { + version, + onTestSubmit, + status, + softwareProductId, + softwareProductValidation + } = this.props; + + Object.keys(softwareProductValidation.testsRequest).forEach(key => { + tests.push(softwareProductValidation.testsRequest[key]); + }); + if (this.validateInputs()) { + onTestSubmit(softwareProductId, version, status, tests); + } + } + + prepareDataForVspInputs() { + let { setTestsRequest } = this.props; + let { + complianceChecked, + certificationChecked, + vspTestsMap, + testsRequest, + generalInfo + } = this.props.softwareProductValidation; + return { + setTestsRequest, + complianceChecked, + certificationChecked, + vspTestsMap, + testsRequest, + generalInfo + }; + } + + render() { + return ( +
+
this.performVSPTests()} + isReadOnlyMode={false}> + + + +
+ ); + } +} + +export default VspValidationInputs; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetup.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetup.js new file mode 100644 index 0000000000..875639e86a --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetup.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 VspValidationSetupView from './VspValidationSetupView.jsx'; + +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductValidation } = softwareProduct; + return { + softwareProductValidation + }; +}; + +export const mapActionsToProps = () => { + return {}; +}; + +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(VspValidationSetupView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx new file mode 100644 index 0000000000..012d50ac93 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx @@ -0,0 +1,320 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import i18n from 'nfvo-utils/i18n/i18n.js'; +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; +import CheckboxTree from 'react-checkbox-tree'; + +const icons = { + check: , + uncheck: , + halfCheck: , + expandClose: , + expandOpen: , + expandAll: , + collapseAll: , + parentClose: , + parentOpen: , + leaf: +}; + +class CertificationQuery extends React.Component { + constructor(props) { + super(props); + let { certificationChecked, certificationNodes } = this.props; + this.state = { + checked: + certificationChecked === undefined ? [] : certificationChecked, + expanded: certificationNodes[0] ? [certificationNodes[0].value] : [] + }; + } + + expandFirstNode() { + let { certificationNodes } = this.props; + this.setState({ + expanded: certificationNodes[0] ? [certificationNodes[0].value] : [] + }); + } + + componentDidMount() { + this.expandFirstNode(); + } + + shouldComponentUpdate() { + return true; + } + + componentWillReceiveProps(nextProps) { + if ( + nextProps.certificationChecked !== this.props.certificationChecked + ) { + let expand = this.state.expanded; + this.setState({ + checked: nextProps.certificationChecked || [], + expanded: expand + }); + } + } + + populateOptions(checkedCertificationQuery) { + let { flatTestsMap } = this.props; + return ( + + ); + } + + render() { + let { certificationNodes, setCertificationChecked } = this.props; + return ( +
+ + +
+ {certificationNodes[0] + ? certificationNodes[0].value + : ''} +
+
+ {certificationNodes.length > 0 && ( + { + this.setState( + { checked }, + setCertificationChecked({ + checked + }) + ); + }} + onExpand={expanded => + this.setState({ expanded }) + } + icons={icons} + className="field-section" + /> + )} + {certificationNodes.length === 0 && ( +
+ {i18n( + 'No Certifications Query are Available' + )} +
+ )} +
+
+ + {certificationNodes.length > 0 && ( +
+
+ {i18n('Selected Certifications Query')} +
+
+ +
+
+ )} +
+
+
+ ); + } +} + +class ComplianceTests extends React.Component { + constructor(props) { + super(props); + let { complianceChecked, complianceNodes } = this.props; + this.state = { + checked: complianceChecked === undefined ? [] : complianceChecked, + expanded: complianceNodes[0] ? [complianceNodes[0].value] : [] + }; + } + + shouldComponentUpdate() { + return true; + } + + expandFirstNode() { + let { complianceNodes } = this.props; + this.setState({ + expanded: complianceNodes[0] ? [complianceNodes[0].value] : [] + }); + } + + componentDidMount() { + this.expandFirstNode(); + } + + componentWillUnmount() {} + + componentWillReceiveProps(nextProps) { + let expand = this.state.expanded; + + if (nextProps.complianceChecked !== this.props.complianceChecked) { + this.setState({ + checked: nextProps.complianceChecked || [], + expanded: expand + }); + } + } + + populateOptions(checkedComplianceTests) { + let { flatTestsMap } = this.props; + return ( + + ); + } + render() { + let { complianceNodes, setComplianceChecked } = this.props; + return ( +
+ + +
+ {complianceNodes[0] ? complianceNodes[0].value : ''} +
+
+ {complianceNodes.length > 0 && ( + { + this.setState( + { checked }, + setComplianceChecked({ + checked + }) + ); + }} + onExpand={expanded => + this.setState({ expanded }) + } + icons={icons} + className="field-section" + /> + )} + {complianceNodes.length === 0 && ( +
+ {i18n('No Compliance Checks are Available')} +
+ )} +
+
+ + {complianceNodes.length > 0 && ( +
+
+ {i18n('Selected Compliance Tests')} +
+
+ +
+
+ )} +
+
+
+ ); + } +} + +class VspValidationSetup extends Component { + static propTypes = { + softwareProductValidation: PropTypes.object, + setComplianceChecked: PropTypes.func, + setCertificationChecked: PropTypes.func + }; + + constructor(props) { + super(props); + this.state = { + complianceCheckList: [], + certificationCheckList: [] + }; + } + + shouldComponentUpdate() { + return true; + } + + render() { + let { + softwareProductValidation, + setComplianceChecked, + setCertificationChecked, + complianceCheckList, + certificationCheckList + } = this.props; + return ( +
+ + +
+ ); + } +} + +export default VspValidationSetup; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js new file mode 100644 index 0000000000..dffade7c9a --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 SoftwareProductValidationResultsView from './SoftwareProductValidationResultsView.jsx'; + +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductValidation } = softwareProduct; + return { + softwareProductValidation + }; +}; + +export default connect(mapStateToProps, null, null, { + withRef: true +})(SoftwareProductValidationResultsView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx new file mode 100644 index 0000000000..b6cc1d5bdc --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx @@ -0,0 +1,207 @@ +/** + * Copyright (c) 2019 Vodafone Group + * + * 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 PropTypes from 'prop-types'; +import Accordion from 'sdc-ui/lib/react/Accordion.js'; +import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import unCamelCasedString from 'nfvo-utils/unCamelCaseString.js'; + +const TestResultComponent = ({ tests }) => { + return ( +
+ {tests.map((test, index) => { + let name = 'errorCircle'; + let color = 'warning'; + if ( + test.testResult && + test.testResult.toLowerCase() === 'pass' + ) { + color = 'positive'; + name = 'checkCircle'; + } else if ( + test.testResult && + test.testResult.toLowerCase() === 'fail' + ) { + name = 'exclamationTriangleFull'; + } + return ( +
  • + + + {test.testName + + ' | ' + + test.testResult + + ' | ' + + test.notes} + +
  • + ); + })} +
    + ); +}; + +class SoftwareProductValidationResultsView extends React.Component { + static propTypes = { + softwareProductValidation: PropTypes.object + }; + + constructor(props) { + super(props); + this.state = { + vspId: this.props.softwareProductId, + versionNumber: this.props.version.name + }; + } + + buildSubAccordions(result) { + if (result.status && result.status.toLowerCase() === 'completed') { + if (!result.results.testResults) { + return ( +
    + + + {i18n('{title} results are not available', { + title: result.scenario + })} + +
    + ); + } + return ( + + {Object.keys(result.results.testResults).map( + (key, index) => { + let title = unCamelCasedString(key); + if (result.results.testResults[key].length > 0) { + return ( + + + + ); + } else { + return ( +
    + {i18n( + '{title} results are not available', + { + title: title + } + )} +
    + ); + } + } + )} +
    + ); + } else if ( + result.status && + result.status.toLowerCase() === 'failed' && + result.results.errors + ) { + return ( + + {result.results.errors.map((element, index) => { + return ( +
  • + + + {element.reason + ' | ' + element.advice} + +
  • + ); + })} +
    + ); + } else if (result.message || result.httpStatus) { + return ( +
    + + + {result.message + ' | ' + result.httpStatus} + +
    + ); + } + } + + render() { + let results = this.props.softwareProductValidation.vspTestResults || []; + if (results.length > 0) { + return ( + + + + {results.map(row => this.buildSubAccordions(row))} + + + + ); + } else { + return ( + +

    {i18n('No Validation Checks Performed')}

    +
    + ); + } + } +} + +export default SoftwareProductValidationResultsView; -- cgit 1.2.3-korg