From c8a540b3c234449163f6fb1899807bba951113b4 Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Mon, 11 Sep 2017 15:45:37 +0300 Subject: Create new VSP, onboard from TOSCA file - UI Change-Id: I018c6d07a4b9ec7e6b1507ab37e2550865423cfe Issue-ID: SDC-230 Signed-off-by: shrek2000 --- .../attachments/SoftwareProductAttachments.js | 12 ++++--- .../SoftwareProductAttachmentsActionHelper.js | 26 ++++++++++++++ .../SoftwareProductAttachmentsConstants.js | 6 ++++ .../SoftwareProductAttachmentsReducer.js | 25 +++++++++++++ .../attachments/SoftwareProductAttachmentsView.jsx | 42 +++++++++++----------- .../validation/HeatValidationReducer.js | 11 +++--- .../attachments/validation/HeatValidationView.jsx | 6 ++-- 7 files changed, 96 insertions(+), 32 deletions(-) create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments') 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 945de4fc36..f14c988866 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js @@ -23,6 +23,7 @@ import {errorLevels} from 'sdc-app/onboarding/softwareProduct/attachments/valida import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; import HeatSetup from './setup/HeatSetup.js'; import {doesHeatDataExist} from './SoftwareProductAttachmentsUtils.js'; +import SoftwareProductAttachmentsActionHelper from './SoftwareProductAttachmentsActionHelper.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; @@ -30,7 +31,7 @@ export const mapStateToProps = (state) => { let { softwareProduct: { softwareProductEditor:{data: currentSoftwareProduct = {}}, - softwareProductAttachments: {heatSetup, heatSetupCache, heatValidation : {errorList}} + softwareProductAttachments: {attachmentsDetails: {activeTab}, heatSetup, heatSetupCache, heatValidation : {errorList}} } } = state; @@ -47,7 +48,7 @@ export const mapStateToProps = (state) => { let isReadOnlyMode = currentSoftwareProduct && currentSoftwareProduct.version ? VersionControllerUtils.isReadOnly(currentSoftwareProduct) : false; - let {version} = currentSoftwareProduct; + let {version, onboardingOrigin} = currentSoftwareProduct; return { isValidationAvailable: unassigned.length === 0 && modules.length > 0, heatSetup, @@ -56,7 +57,9 @@ export const mapStateToProps = (state) => { goToOverview, HeatSetupComponent: HeatSetup, isReadOnlyMode, - version + version, + onboardingOrigin, + activeTab }; }; @@ -83,7 +86,8 @@ export const mapActionsToProps = (dispatch, {softwareProductId}) => { onProcessAndValidate: ({heatData, heatDataCache, isReadOnlyMode, version}) => { return HeatSetupActionHelper.processAndValidateHeat(dispatch, {softwareProductId, heatData, heatDataCache, isReadOnlyMode, version}); - } + }, + setActiveTab: ({activeTab}) => SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab}) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js new file mode 100644 index 0000000000..ae4a615a40 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js @@ -0,0 +1,26 @@ +/*! + * 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 './SoftwareProductAttachmentsConstants'; + +export default { + setActiveTab(dispatch, {activeTab}) { + dispatch({ + type: actionTypes.SET_ACTIVE_TAB, + activeTab + }); + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js index b0410d1566..67265909d7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js @@ -13,7 +13,13 @@ * 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, VALIDATION: 2 }; + +export const actionTypes = keyMirror({ + SET_ACTIVE_TAB: null +}); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js new file mode 100644 index 0000000000..5f6538ab7e --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js @@ -0,0 +1,25 @@ +/*! + * 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 './SoftwareProductAttachmentsConstants.js'; + +export default (state = [], action) => { + switch (action.type) { + case actionTypes.SET_ACTIVE_TAB: + return {activeTab: action.activeTab}; + default: + return state; + } +}; 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 3da26cc20f..8c59b2b1cc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx @@ -20,34 +20,34 @@ import {tabsMapping} from './SoftwareProductAttachmentsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import HeatValidation from './validation/HeatValidation.js'; +import {onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; class HeatScreenView extends Component { static propTypes = { isValidationAvailable: PropTypes.bool, - goToOverview: PropTypes.bool - }; - - state = { - activeTab: tabsMapping.SETUP + goToOverview: PropTypes.bool, + setActiveTab: PropTypes.function }; render() { - let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, heatSetup, HeatSetupComponent, onGoToOverview, version, ...other} = this.props; + let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, + heatSetup, HeatSetupComponent, onGoToOverview, version, onboardingOrigin, activeTab, setActiveTab, ...other} = this.props; + return (
- {(this.state.activeTab === tabsMapping.SETUP) && + {(activeTab === tabsMapping.SETUP) && onDownload({heatCandidate: heatSetup, isReadOnlyMode, version}) : undefined} data-test-id='download-heat'/>} - {(this.state.activeTab === tabsMapping.VALIDATION && softwareProductId) && + {(activeTab === tabsMapping.VALIDATION && softwareProductId) && onGoToOverview({version}) : undefined} @@ -60,7 +60,7 @@ class HeatScreenView extends Component { this.handleImport(evt)}/>
- this.handleTabPress(key)}> - + this.handleTabPress(key)}> + this.setState({activeTab: tab})} + changeAttachmentsTab={tab => setActiveTab({activeTab: tab})} onProcessAndValidate={onProcessAndValidate} softwareProductId={softwareProductId} isReadOnlyMode={isReadOnlyMode} version={version}/> - + @@ -92,15 +92,15 @@ class HeatScreenView extends Component { } handleTabPress(key) { - let {heatSetup, heatSetupCache, onProcessAndValidate, isReadOnlyMode, version} = this.props; + let {heatSetup, heatSetupCache, onProcessAndValidate, isReadOnlyMode, version, setActiveTab} = this.props; switch (key) { case tabsMapping.VALIDATION: onProcessAndValidate({heatData: heatSetup, heatDataCache: heatSetupCache, isReadOnlyMode, version}).then( - () => this.setState({activeTab: tabsMapping.VALIDATION}) + () => setActiveTab({activeTab: tabsMapping.VALIDATION}) ); return; case tabsMapping.SETUP: - this.setState({activeTab: tabsMapping.SETUP}); + setActiveTab({activeTab: tabsMapping.SETUP}); return; } } @@ -112,11 +112,13 @@ class HeatScreenView extends Component { formData.append('upload', this.refs.hiddenImportFileInput.files[0]); this.refs.hiddenImportFileInput.value = ''; this.props.onUpload(formData, version); - this.setState({activeTab: tabsMapping.SETUP}); } save() { - return this.props.onSave(this.props.heatSetup, this.props.version); + + return this.props.onboardingOrigin === onboardingOriginTypes.ZIP ? + this.props.onSave(this.props.heatSetup, this.props.version) : + Promise.resolve(); } } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js index f0c10ed457..1d11bdd6b7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js @@ -89,16 +89,16 @@ function createErrorList(node, parent, deep = 0, errorList = []) { return errorList; } -const mapValidationDataToTree = validationData => { - let {heat, volume, network, artifacts, other} = validationData.importStructure || {}; +const mapValidationDataToTree = (validationData, packageName) => { + let {heat, nested, volume, network, artifacts, other} = validationData.importStructure || {}; return { children: [ { - name: 'HEAT', + name: packageName, expanded: true, type: 'heat', header: true, - children: (heat ? heat.map(mapHeatData) : []) + children: (heat ? heat.map(mapHeatData) : nested ? nested.map(mapHeatData) : []) }, ...(artifacts ? [{ name: 'artifacts', @@ -165,7 +165,8 @@ export default (state = {attachmentsTree: {}}, action) => { switch (action.type) { case softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED: let currentSoftwareProduct = action.response; - let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData) : {}; + const packageName = currentSoftwareProduct.networkPackageName; + let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData, packageName) : {}; let errorList = createErrorList(attachmentsTree); return { ...state, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx index 2a2f4ac291..80d74b2964 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx @@ -93,9 +93,9 @@ function HeatFileTreeHeader(props) {
props.selectNode(nodeFilters.ALL)} className={classNames({'attachments-tree-header': true, 'header-selected' : props.selectedNode === nodeFilters.ALL})} data-test-id='validation-tree-header'>
- + {/**/} {i18n(`HEAT${hasErrors ? ' (Draft)' : ''}`)} + 'tree-header-title-selected' : props.selectedNode === nodeFilters.ALL})}>{i18n(`${props.headerTitle} ${hasErrors ? '(Draft)' : ''}`)}
); @@ -134,7 +134,7 @@ class HeatFileTree extends React.Component {
{ node.header ? - this.selectNode(nodeName)} /> : + this.selectNode(nodeName)} /> : this.selectNode(node.name)} /> } { -- cgit 1.2.3-korg