Add collaboration feature
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / components / creation / SoftwareProductComponentCreationView.jsx
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 import React from 'react';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19
20 import Form from 'nfvo-components/input/validation/Form.jsx';
21 import Input from 'nfvo-components/input/validation/Input.jsx';
22 import GridSection from 'nfvo-components/grid/GridSection.jsx';
23 import GridItem from 'nfvo-components/grid/GridItem.jsx';
24 import {forms} from '../SoftwareProductComponentsConstants.js';
25
26 class ComponentCreationView extends React.Component {
27         render() {
28                 let {data = {}, onDataChanged, onCancel, genericFieldInfo} = this.props;
29                 let {displayName, description} = data;
30                 return(
31                         <div>
32                                 {
33                                         genericFieldInfo && <Form
34                                                 ref='validationForm'
35                                                 hasButtons={true}
36                                                 onSubmit={ () => this.submit() }
37                                                 onReset={ () => onCancel() }
38                                                 submitButtonText={i18n('Create')}
39                                                 labledButtons={true}
40                                                 isValid={this.props.isFormValid}
41                                                 formReady={this.props.formReady}
42                                                 onValidateForm={() => this.props.onValidateForm(forms.CREATE_FORM) }
43                                                 className='entitlement-pools-form'>
44                                                 <GridSection hasLastColSet>
45                                                         <GridItem colSpan={4} lastColInRow>
46                                                                 <Input
47                                                                         data-test-id='name'
48                                                                         onChange={displayName => onDataChanged({displayName})}
49                                                                         label={i18n('Name')}
50                                                                         isRequired={true}
51                                                                         isValid={genericFieldInfo.displayName.isValid}
52                                                                         errorText={genericFieldInfo.displayName.errorText}
53                                                                         value={displayName}
54                                                                         type='text'/>
55                                                         </GridItem>
56                                                         <GridItem colSpan={4} lastColInRow>
57                                                                 <Input
58                                                                         label={i18n('Description')}
59                                                                         onChange={description => onDataChanged({description})}
60                                                                         value={description}
61                                                                         isValid={genericFieldInfo.description.isValid}
62                                                                         errorText={genericFieldInfo.description.errorText}
63                                                                         data-test-id='description'
64                                                                         type='textarea'/>
65                                                         </GridItem>
66                                                 </GridSection>
67                                         </Form>
68                                 }
69                         </div>
70                 );
71         }
72
73         submit() {
74                 const {onSubmit, data} = this.props;
75                 onSubmit(data);
76         }
77 }
78
79 export default ComponentCreationView;