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 from 'react';
17 import PropTypes from 'prop-types';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import Input from 'nfvo-components/input/validation/Input.jsx';
20 import Form from 'nfvo-components/input/validation/Form.jsx';
21 import GridSection from 'nfvo-components/grid/GridSection.jsx';
22 import GridItem from 'nfvo-components/grid/GridItem.jsx';
23 import classnames from 'classnames';
25 const BackupSection = ({isReadOnlyMode,dataMap, onQDataChanged, qgenericFieldInfo}) => (
26 <GridSection title={i18n('Backup')}>
28 <div className='vertical-flex'>
29 <label key='label' className={classnames('control-label',{'disabled': isReadOnlyMode})}>{i18n('Backup Type')}</label>
30 <div className='radio-options-content-row'>
31 {qgenericFieldInfo['storage/backup/backupType'].enum.map(onSite => (
33 data-test-id='backupType'
36 name={'compute/guestOS/bitSize'}
37 className='radio-field'
40 onChange={(site) => onQDataChanged({'storage/backup/backupType' : site})}
41 isValid={qgenericFieldInfo['storage/backup/backupType'].isValid}
42 errorText={qgenericFieldInfo['storage/backup/backupType'].errorText}
43 checked={dataMap['storage/backup/backupType'] === onSite.enum} /> )) }
49 className='section-field'
50 data-test-id='backupSolution'
51 onChange={(backupSolution) => onQDataChanged({'storage/backup/backupSolution' : backupSolution})}
52 label={i18n('Backup Solution')}
54 isValid={qgenericFieldInfo['storage/backup/backupSolution'].isValid}
55 errorText={qgenericFieldInfo['storage/backup/backupSolution'].errorText}
56 value={dataMap['storage/backup/backupSolution']}/>
60 className='section-field'
61 data-test-id='backupStorageSize'
62 onChange={(backupStorageSize) => onQDataChanged({'storage/backup/backupStorageSize' : backupStorageSize})}
63 label={i18n('Backup Storage Size (GB)')}
65 isValid={qgenericFieldInfo['storage/backup/backupStorageSize'].isValid}
66 errorText={qgenericFieldInfo['storage/backup/backupStorageSize'].errorText}
67 value={dataMap['storage/backup/backupStorageSize']}/>
71 data-test-id='backupNIC'
72 label={i18n('Backup NIC')}
74 className='input-options-select section-field'
75 groupClassName='bootstrap-input-options'
76 isValid={qgenericFieldInfo['storage/backup/backupNIC'].isValid}
77 errorText={qgenericFieldInfo['storage/backup/backupNIC'].errorText}
78 value={dataMap['storage/backup/backupNIC']}
80 const selectedIndex = e.target.selectedIndex;
81 const val = e.target.options[selectedIndex].value;
82 onQDataChanged({'storage/backup/backupNIC' : val});}
84 <option key='placeholder' value=''>{i18n('Select...')}</option>
85 {qgenericFieldInfo['storage/backup/backupNIC'].enum.map(hv => <option value={hv.enum} key={hv.enum}>{hv.title}</option>)}
91 const SnapshotBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => (
92 <GridSection title={i18n('Snapshot Backup')}>
95 className='section-field'
96 data-test-id='snapshotFrequency'
97 onChange={(snapshotFrequency) => onQDataChanged({'storage/snapshotBackup/snapshotFrequency' : snapshotFrequency})}
98 label={i18n('Backup Storage Size (GB)')}
100 isValid={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].isValid}
101 errorText={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].errorText}
102 value={dataMap['storage/snapshotBackup/snapshotFrequency']}/>
107 const LogBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => (
108 <GridSection title={i18n('Log Backup')}>
111 className='section-field'
112 data-test-id='sizeOfLogFiles'
113 onChange={(sizeOfLogFiles) => onQDataChanged({'storage/logBackup/sizeOfLogFiles' : sizeOfLogFiles})}
114 label={i18n('Backup Storage Size (GB)')}
116 isValid={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].isValid}
117 errorText={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].errorText}
118 value={dataMap['storage/logBackup/sizeOfLogFiles']}/>
122 className='section-field'
123 label={i18n('Log Retention Period (days)')}
124 data-test-id='logRetentionPeriod'
125 onChange={(logRetentionPeriod) => onQDataChanged({'storage/logBackup/logRetentionPeriod' : logRetentionPeriod})}
127 isValid={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].isValid}
128 errorText={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].errorText}
129 value={dataMap['storage/logBackup/logRetentionPeriod']}/>
133 className='section-field'
134 label={i18n('Log Backup Frequency (days)')}
135 data-test-id='logBackupFrequency'
136 onChange={(logBackupFrequency) => onQDataChanged({'storage/logBackup/logBackupFrequency' : logBackupFrequency})}
138 isValid={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].isValid}
139 errorText={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].errorText}
140 value={dataMap['storage/logBackup/logBackupFrequency']}/>
144 className='section-field'
145 label={i18n('Log File Location')}
146 data-test-id='logFileLocation'
147 onChange={(logFileLocation) => onQDataChanged({'storage/logBackup/logFileLocation' : logFileLocation})}
149 isValid={qgenericFieldInfo['storage/logBackup/logFileLocation'].isValid}
150 errorText={qgenericFieldInfo['storage/logBackup/logFileLocation'].errorText}
151 value={dataMap['storage/logBackup/logFileLocation']}/>
156 class SoftwareProductComponentStorageView extends React.Component {
159 componentId: PropTypes.string,
160 onQDataChanged: PropTypes.func,
161 onSubmit: PropTypes.func,
162 isReadOnlyMode: PropTypes.bool
166 let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata} = this.props;
169 <div className='vsp-component-questionnaire-view'>
170 {qGenericFieldInfo && <Form
171 ref={form => this.form = form }
174 onSubmit={() => onSubmit({qdata})}
175 className='component-questionnaire-validation-form'
176 isReadOnlyMode={isReadOnlyMode}
178 <BackupSection isReadOnlyMode={isReadOnlyMode} onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
179 <SnapshotBackupSection onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
180 <LogBackupSection onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
187 const {qdata, onSubmit} = this.props;
188 return onSubmit({qdata});
192 export default SoftwareProductComponentStorageView;