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 i18n from 'nfvo-utils/i18n/i18n.js';
18 import Input from 'nfvo-components/input/validation/Input.jsx';
19 import Form from 'nfvo-components/input/validation/Form.jsx';
20 import GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
22 import classnames from 'classnames';
24 const BackupSection = ({isReadOnlyMode,dataMap, onQDataChanged, qgenericFieldInfo}) => (
25 <GridSection title={i18n('Backup')}>
27 <div className='vertical-flex'>
28 <label key='label' className={classnames('control-label',{'disabled': isReadOnlyMode})}>{i18n('Backup Type')}</label>
29 <div className='radio-options-content-row'>
30 {qgenericFieldInfo['storage/backup/backupType'].enum.map(onSite => (
32 data-test-id='backupType'
35 name={'compute/guestOS/bitSize'}
36 className='radio-field'
39 onChange={(site) => onQDataChanged({'storage/backup/backupType' : site})}
40 isValid={qgenericFieldInfo['storage/backup/backupType'].isValid}
41 errorText={qgenericFieldInfo['storage/backup/backupType'].errorText}
42 checked={dataMap['storage/backup/backupType'] === onSite.enum} /> )) }
48 className='section-field'
49 data-test-id='backupSolution'
50 onChange={(backupSolution) => onQDataChanged({'storage/backup/backupSolution' : backupSolution})}
51 label={i18n('Backup Solution')}
53 isValid={qgenericFieldInfo['storage/backup/backupSolution'].isValid}
54 errorText={qgenericFieldInfo['storage/backup/backupSolution'].errorText}
55 value={dataMap['storage/backup/backupSolution']}/>
59 className='section-field'
60 data-test-id='backupStorageSize'
61 onChange={(backupStorageSize) => onQDataChanged({'storage/backup/backupStorageSize' : backupStorageSize})}
62 label={i18n('Backup Storage Size (GB)')}
64 isValid={qgenericFieldInfo['storage/backup/backupStorageSize'].isValid}
65 errorText={qgenericFieldInfo['storage/backup/backupStorageSize'].errorText}
66 value={dataMap['storage/backup/backupStorageSize']}/>
70 data-test-id='backupNIC'
71 label={i18n('Backup NIC')}
73 className='input-options-select section-field'
74 groupClassName='bootstrap-input-options'
75 isValid={qgenericFieldInfo['storage/backup/backupNIC'].isValid}
76 errorText={qgenericFieldInfo['storage/backup/backupNIC'].errorText}
77 value={dataMap['storage/backup/backupNIC']}
79 const selectedIndex = e.target.selectedIndex;
80 const val = e.target.options[selectedIndex].value;
81 onQDataChanged({'storage/backup/backupNIC' : val});}
83 <option key='placeholder' value=''>{i18n('Select...')}</option>
84 {qgenericFieldInfo['storage/backup/backupNIC'].enum.map(hv => <option value={hv.enum} key={hv.enum}>{hv.title}</option>)}
90 const SnapshotBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => (
91 <GridSection title={i18n('Snapshot Backup')}>
94 className='section-field'
95 data-test-id='snapshotFrequency'
96 onChange={(snapshotFrequency) => onQDataChanged({'storage/snapshotBackup/snapshotFrequency' : snapshotFrequency})}
97 label={i18n('Backup Storage Size (GB)')}
99 isValid={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].isValid}
100 errorText={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].errorText}
101 value={dataMap['storage/snapshotBackup/snapshotFrequency']}/>
106 const LogBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => (
107 <GridSection title={i18n('Log Backup')}>
110 className='section-field'
111 data-test-id='sizeOfLogFiles'
112 onChange={(sizeOfLogFiles) => onQDataChanged({'storage/logBackup/sizeOfLogFiles' : sizeOfLogFiles})}
113 label={i18n('Backup Storage Size (GB)')}
115 isValid={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].isValid}
116 errorText={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].errorText}
117 value={dataMap['storage/logBackup/sizeOfLogFiles']}/>
121 className='section-field'
122 label={i18n('Log Retention Period (days)')}
123 data-test-id='logRetentionPeriod'
124 onChange={(logRetentionPeriod) => onQDataChanged({'storage/logBackup/logRetentionPeriod' : logRetentionPeriod})}
126 isValid={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].isValid}
127 errorText={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].errorText}
128 value={dataMap['storage/logBackup/logRetentionPeriod']}/>
132 className='section-field'
133 label={i18n('Log Backup Frequency (days)')}
134 data-test-id='logBackupFrequency'
135 onChange={(logBackupFrequency) => onQDataChanged({'storage/logBackup/logBackupFrequency' : logBackupFrequency})}
137 isValid={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].isValid}
138 errorText={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].errorText}
139 value={dataMap['storage/logBackup/logBackupFrequency']}/>
143 className='section-field'
144 label={i18n('Log File Location')}
145 data-test-id='logFileLocation'
146 onChange={(logFileLocation) => onQDataChanged({'storage/logBackup/logFileLocation' : logFileLocation})}
148 isValid={qgenericFieldInfo['storage/logBackup/logFileLocation'].isValid}
149 errorText={qgenericFieldInfo['storage/logBackup/logFileLocation'].errorText}
150 value={dataMap['storage/logBackup/logFileLocation']}/>
155 class SoftwareProductComponentStorageView extends React.Component {
158 componentId: React.PropTypes.string,
159 onQDataChanged: React.PropTypes.func,
160 onSubmit: React.PropTypes.func,
161 isReadOnlyMode: React.PropTypes.bool
165 let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata} = this.props;
168 <div className='vsp-component-questionnaire-view'>
169 {qGenericFieldInfo && <Form
170 ref={form => this.form = form }
173 onSubmit={() => onSubmit({qdata})}
174 className='component-questionnaire-validation-form'
175 isReadOnlyMode={isReadOnlyMode}
177 <BackupSection isReadOnlyMode={isReadOnlyMode} onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
178 <SnapshotBackupSection onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
179 <LogBackupSection onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qGenericFieldInfo}/>
186 return this.form.handleFormSubmit(new Event('dummy'));
190 export default SoftwareProductComponentStorageView;