2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React, {Component, PropTypes} from 'react';
17 import Tabs from 'react-bootstrap/lib/Tabs.js';
18 import Tab from 'react-bootstrap/lib/Tab.js';
19 import {tabsMapping} from './SoftwareProductAttachmentsConstants.js';
20 import i18n from 'nfvo-utils/i18n/i18n.js';
21 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
22 import HeatValidation from './validation/HeatValidation.js';
23 import {onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
25 class HeatScreenView extends Component {
28 isValidationAvailable: PropTypes.bool,
29 goToOverview: PropTypes.bool,
30 setActiveTab: PropTypes.function
34 let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate,
35 heatSetup, HeatSetupComponent, onGoToOverview, version, onboardingOrigin, activeTab, setActiveTab, ...other} = this.props;
38 <div className='vsp-attachments-view'>
39 <div className='attachments-view-controllers'>
40 {(activeTab === tabsMapping.SETUP) &&
42 disabled={heatDataExist ? false : true}
44 className='icon-component'
45 label={i18n('Export Validation')}
48 onClick={heatDataExist ? () => onDownload({heatCandidate: heatSetup, isReadOnlyMode, version}) : undefined}
49 data-test-id='download-heat'/>}
50 {(activeTab === tabsMapping.VALIDATION && softwareProductId) &&
52 disabled={this.props.goToOverview !== true}
53 onClick={this.props.goToOverview ? () => onGoToOverview({version}) : undefined}
54 name='proceedToOverview'
55 className='icon-component'
56 label={i18n('Go to Overview')}
58 color={this.props.goToOverview ? 'primary' : 'secondary'}
59 data-test-id='go-to-overview'/>}
62 className='icon-component'
63 label={i18n('Upload New File')}
66 disabled={isReadOnlyMode}
67 onClick={evt => {this.refs.hiddenImportFileInput.click(evt);}}
68 data-test-id='upload-heat'/>
70 ref='hiddenImportFileInput'
74 onChange={evt => this.handleImport(evt)}/>
76 <Tabs id='attachments-tabs' activeKey={activeTab} onSelect={key => this.handleTabPress(key)}>
77 <Tab eventKey={tabsMapping.SETUP} title='Setup' disabled={onboardingOrigin === onboardingOriginTypes.CSAR}>
79 heatDataExist={heatDataExist}
80 changeAttachmentsTab={tab => setActiveTab({activeTab: tab})}
81 onProcessAndValidate={onProcessAndValidate}
82 softwareProductId={softwareProductId}
83 isReadOnlyMode={isReadOnlyMode}
86 <Tab eventKey={tabsMapping.VALIDATION} title='Validation' disabled={!isValidationAvailable}>
87 <HeatValidation {...other}/>
95 let {heatSetup, heatSetupCache, onProcessAndValidate, isReadOnlyMode, version, setActiveTab} = this.props;
97 case tabsMapping.VALIDATION:
98 onProcessAndValidate({heatData: heatSetup, heatDataCache: heatSetupCache, isReadOnlyMode, version}).then(
99 () => setActiveTab({activeTab: tabsMapping.VALIDATION})
102 case tabsMapping.SETUP:
103 setActiveTab({activeTab: tabsMapping.SETUP});
109 evt.preventDefault();
110 let {version} = this.props;
111 let formData = new FormData();
112 formData.append('upload', this.refs.hiddenImportFileInput.files[0]);
113 this.refs.hiddenImportFileInput.value = '';
114 this.props.onUpload(formData, version);
119 return this.props.onboardingOrigin === onboardingOriginTypes.ZIP ?
120 this.props.onSave(this.props.heatSetup, this.props.version) :
126 export default HeatScreenView;