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 {connect} from 'react-redux';
19 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
20 import licenseModelOverviewActionHelper from '../licenseModelOverviewActionHelper.js';
21 import LicenseModelActionHelper from '../../LicenseModelActionHelper.js';
22 import LicenseModelDescriptionEdit from './LicenseModelDescriptionEdit.jsx';
23 import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
24 import {VLM_DESCRIPTION_FORM} from '../LicenseModelOverviewConstants.js';
26 export const mapStateToProps = ({licenseModel: {licenseModelEditor: {data}, licenseModelOverview: {descriptionEditor: {data: descriptionData, genericFieldInfo} }}}) => {
27 let description = (descriptionData && descriptionData.description) ? descriptionData.description : null;
28 let isReadOnlyMode = VersionControllerUtils.isReadOnly(data);
37 const mapActionsToProps = (dispatch) => {
39 onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VLM_DESCRIPTION_FORM}),
40 onCancel: () => licenseModelOverviewActionHelper.editDescriptionClose(dispatch),
41 onSubmit: (licenseModel) => {
42 licenseModelOverviewActionHelper.editDescriptionClose(dispatch);
43 LicenseModelActionHelper.saveLicenseModel(dispatch, {licenseModel});
45 onVendorDescriptionEdit: description => licenseModelOverviewActionHelper.editDescriptionOpen(dispatch,{description})
51 export class VendorDataView extends React.Component {
53 let {data: {vendorName}, description, isReadOnlyMode} = this.props;
55 <div className='vendor-data-view'>
56 <div className='vendor-title'>vendor</div>
57 <div className='vendor-name' data-test-id='vlm-summary-vendor-name'>{vendorName}</div>
59 description && !isReadOnlyMode ? this.renderDescriptionEdit() : this.renderDescription()
66 let {data: {description}, onVendorDescriptionEdit, isReadOnlyMode} = this.props;
68 <div onClick={() => {if (!isReadOnlyMode) {onVendorDescriptionEdit(description);}}} className={!isReadOnlyMode ? 'vendor-description' : 'vendor-description-readonly'}>
69 <div className='description-data' data-test-id='vlm-summary-vendor-description'>
76 renderDescriptionEdit() {
77 let {onCancel, onDataChanged, onSubmit, description, genericFieldInfo, data} = this.props;
79 <LicenseModelDescriptionEdit onClose={onCancel} onDataChanged={onDataChanged} onSubmit={onSubmit} data={data} genericFieldInfo={genericFieldInfo} description={description}/>
85 export default connect(mapStateToProps, mapActionsToProps)(VendorDataView);