From f6784900012e11850d8e98bbf198f04bd0e411c7 Mon Sep 17 00:00:00 2001 From: svishnev Date: Mon, 12 Feb 2018 09:10:35 +0200 Subject: heat validation flow Issue-ID: SDC-1024 Change-Id: I4248fef46c7f8f5132644628f320231eeafe8070 Signed-off-by: svishnev --- .../onboarding/softwareProduct/SoftwareProduct.js | 15 ++-- .../softwareProduct/SoftwareProductActionHelper.js | 26 +++++-- .../softwareProduct/SoftwareProductConstants.js | 3 +- .../attachments/SoftwareProductAttachments.js | 16 ++++- .../attachments/SoftwareProductAttachmentsView.jsx | 79 +++++++++++++--------- .../details/SoftwareProductDetailsReducer.js | 7 +- .../landingPage/SoftwareProductLandingPage.js | 13 ++-- .../landingPage/SoftwareProductLandingPageView.jsx | 23 ++++--- 8 files changed, 120 insertions(+), 62 deletions(-) (limited to 'openecomp-ui/src/sdc-app') diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index cdaf189fc0..683dd4f682 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ const buildComponentNavigationBarGroups = ({componentId, meta}) => { const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}) => { const {softwareProductEditor: {data: currentSoftwareProduct = {}}} = softwareProduct; - const {id, name, onboardingMethod, candidateOnboardingOrigin} = currentSoftwareProduct; + const {id, name, onboardingMethod, candidateOnboardingOrigin, onboardingOrigin} = currentSoftwareProduct; const groups = [{ id: id, name: name, @@ -126,7 +126,7 @@ const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, co id: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, name: i18n('Attachments'), disabled: false, - hidden: candidateOnboardingOrigin === onboardingOriginTypes.NONE, + hidden: !candidateOnboardingOrigin && !onboardingOrigin, meta }, { id: enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, @@ -159,14 +159,14 @@ const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, co }]; let activeItemId = getActiveNavigationId(screen, componentId); return { - activeItemId, groups + activeItemId, groups, disabled: !!candidateOnboardingOrigin }; }; const buildVersionControllerProps = ({softwareProduct, versions, currentVersion, permissions, userInfo, usersList, itemPermission, isReadOnlyMode}) => { const {softwareProductEditor = {data: {}}} = softwareProduct; - const {isValidityData = true, data: {name, onboardingMethod}} = softwareProductEditor; - + const {isValidityData = true, data: {name, onboardingMethod, candidateOnboardingOrigin}} = softwareProductEditor; + return { version: currentVersion, viewableVersions: versions, @@ -177,7 +177,8 @@ const buildVersionControllerProps = ({softwareProduct, versions, currentVersion, isReadOnlyMode, userInfo, usersList, - isManual: onboardingMethod === onboardingMethodType.MANUAL + isManual: onboardingMethod === onboardingMethodType.MANUAL, + candidateInProcess: !!candidateOnboardingOrigin }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index ebd660f71c..9ed6005397 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -1,17 +1,17 @@ -/* - * Copyright © 2016-2017 European Support Limited +/*! + * Copyright © 2016-2018 European Support Limited * * 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 + * 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. + * 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 showFileSaveDialog from 'nfvo-utils/ShowFileSaveDialog.js'; @@ -116,6 +116,10 @@ function fetchOrchestrationTemplateCandidate(softwareProductId, version, ) { return RestAPIUtil.fetch(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate`, {dataType: 'binary'}); } +function abortValidationProcess(softwareProductId, version) { + return RestAPIUtil.destroy(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate`); +} + function objToString(obj) { let str = ''; if (obj instanceof Array) { @@ -242,6 +246,8 @@ const SoftwareProductActionHelper = { if (response.status === 'Success') { SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); + } else { + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); } }); }, @@ -267,6 +273,10 @@ const SoftwareProductActionHelper = { screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, screenType: screenTypes.SOFTWARE_PRODUCT, props: {softwareProductId, version} }); + dispatch({ + type: actionTypes.CANDIDATE_IN_PROCESS, + inProcess: true + }); break; case onboardingOriginTypes.CSAR: ScreensHelper.loadScreen(dispatch, { @@ -540,6 +550,10 @@ const SoftwareProductActionHelper = { screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, props: {softwareProductId, version: {id: newVer, label: newVer}} })); + }, + + abortCandidateValidation(dispatch, {softwareProductId, version}) { + return abortValidationProcess(softwareProductId, version); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js index 7df46589c3..c82483740f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ export const actionTypes = keyMirror({ SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE: null, LOAD_LICENSING_VERSIONS_LIST: null, TOGGLE_NAVIGATION_ITEM: null, + CANDIDATE_IN_PROCESS: null, softwareProductEditor: { OPEN: null, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js index 234953ec3b..d942172973 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,8 @@ export const mapStateToProps = (state) => { HeatSetupComponent: HeatSetup, version, onboardingOrigin, - activeTab + activeTab, + candidateInProcess: !!currentSoftwareProduct.candidateOnboardingOrigin }; }; @@ -67,6 +68,8 @@ export const mapActionsToProps = (dispatch, {softwareProductId, version}) => { data:{ msg: i18n('Upload will erase existing data. Do you want to continue?'), confirmationButtonText: i18n('Continue'), + title: i18n('WARNING'), + onConfirmed: ()=>SoftwareProductActionHelper.uploadFile(dispatch, { softwareProductId, formData, @@ -75,6 +78,15 @@ export const mapActionsToProps = (dispatch, {softwareProductId, version}) => { }) } }), + onUploadAbort: () => { + SoftwareProductActionHelper.abortCandidateValidation(dispatch, {softwareProductId, version}) + .then(()=>{ + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, + props: {softwareProductId, version} + }); + }); + }, onInvalidFileUpload: () => dispatch({ type: modalActionTypes.GLOBAL_MODAL_ERROR, data: { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx index a23015732b..90dd7692bf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import {tabsMapping} from './SoftwareProductAttachmentsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import HeatValidation from './validation/HeatValidation.js'; import {onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import Button from 'sdc-ui/lib/react/Button.js'; class HeatScreenView extends Component { @@ -30,40 +31,56 @@ class HeatScreenView extends Component { setActiveTab: PropTypes.func }; + componentDidMount() { + if (!this.props.goToOverview && this.props.candidateInProcess) { + this.props.setActiveTab({activeTab: tabsMapping.VALIDATION}); + } + } + render() { - let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, - heatSetup, HeatSetupComponent, onGoToOverview, version, onboardingOrigin, activeTab, setActiveTab, ...other} = this.props; + let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, onUploadAbort, + candidateInProcess, heatSetup, HeatSetupComponent, onGoToOverview, version, onboardingOrigin, activeTab, setActiveTab, ...other} = this.props; return (
- {(activeTab === tabsMapping.SETUP) && - onDownload({heatCandidate: heatSetup, isReadOnlyMode, version}) : undefined} - data-test-id='download-heat'/>} + {(activeTab === tabsMapping.SETUP) && + + } + {candidateInProcess && + } + {(activeTab === tabsMapping.VALIDATION && softwareProductId) && - onGoToOverview({version}) : undefined} - name='proceedToOverview' - className='icon-component' - label={i18n('Go to Overview')} - labelPosition='right' - color={this.props.goToOverview ? 'primary' : 'secondary'} - data-test-id='go-to-overview'/>} + className='go-to-overview-btn' + onClick={this.props.goToOverview ? () => onGoToOverview({version}) : undefined}>{i18n('GO TO OVERVIEW')}} +
+ onDownload({heatCandidate: heatSetup, isReadOnlyMode, version}) : undefined} + data-test-id='download-heat'/> + this.refs.hiddenImportFileInput.click(evt)} data-test-id='upload-heat'/> this.handleImport(evt)}/>
- this.handleTabPress(key)}> + this.handleTabPress(key)}> { ...state, licensingVersionsList: action.licensingVersionsList }; + case actionTypes.CANDIDATE_IN_PROCESS: + return { + ...state, + data: {...state.data, candidateOnboardingOrigin: true} + }; default: return state; } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js index 90ea182dfa..64e0d562ce 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ export const mapStateToProps = ({ softwareProduct, licenseModel: {licenseAgreement}, }) => { - let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents, softwareProductCategories = []} = softwareProduct; + let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents, softwareProductCategories = [], } = softwareProduct; let {licensingData = {}} = currentSoftwareProduct; let {licenseAgreementList} = licenseAgreement; let {componentsList} = softwareProductComponents; @@ -53,8 +53,8 @@ export const mapStateToProps = ({ currentSoftwareProduct: { ...currentSoftwareProduct, licenseAgreementName, - fullCategoryDisplayName - }, + fullCategoryDisplayName + }, componentsList, isManual: currentSoftwareProduct.onboardingMethod === onboardingMethod.MANUAL }; @@ -67,7 +67,10 @@ const mapActionsToProps = (dispatch, {version}) => { screen: enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, screenType: screenTypes.SOFTWARE_PRODUCT, props: {softwareProductId, version} }), - + onCandidateInProcess: (softwareProductId) => ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, screenType: screenTypes.SOFTWARE_PRODUCT, + props: {softwareProductId, version} + }), onUpload: (softwareProductId, formData) => SoftwareProductActionHelper.uploadFile(dispatch, { softwareProductId, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx index 76228b0731..70c04f01a3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx @@ -1,17 +1,17 @@ -/* - * Copyright © 2016-2017 European Support Limited +/*! + * Copyright © 2016-2018 European Support Limited * * 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 - * + * + * 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. + * 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'; @@ -65,7 +65,12 @@ class SoftwareProductLandingPageView extends React.Component { onComponentSelect: PropTypes.func, onAddComponent: PropTypes.func }; - + componentDidMount() { + const {onCandidateInProcess, currentSoftwareProduct} = this.props; + if (currentSoftwareProduct.candidateOnboardingOrigin) { + onCandidateInProcess(currentSoftwareProduct.id); + } + } render() { let {currentSoftwareProduct, isReadOnlyMode, isManual, onDetailsSelect} = this.props; return ( -- cgit 1.2.3-korg