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 } from 'react';
17 import { connect } from 'react-redux';
19 import Tooltip from 'react-bootstrap/lib/Tooltip.js';
20 import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js';
21 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
22 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
23 import licenseModelOverviewActionHelper from '../licenseModelOverviewActionHelper.js';
24 import LicenseModelActionHelper from '../../LicenseModelActionHelper.js';
25 import LicenseModelDescriptionEdit from './LicenseModelDescriptionEdit.jsx';
26 import { VLM_DESCRIPTION_FORM } from '../LicenseModelOverviewConstants.js';
28 export const mapStateToProps = ({
30 licenseModelEditor: { data },
31 licenseModelOverview: {
32 descriptionEditor: { data: descriptionData = {}, genericFieldInfo }
36 let { description } = descriptionData;
44 const mapActionsToProps = dispatch => {
46 onDataChanged: deltaData =>
47 ValidationHelper.dataChanged(dispatch, {
49 formName: VLM_DESCRIPTION_FORM
52 licenseModelOverviewActionHelper.editDescriptionClose(dispatch),
53 onSubmit: licenseModel => {
54 licenseModelOverviewActionHelper.editDescriptionClose(dispatch);
55 LicenseModelActionHelper.saveLicenseModel(dispatch, {
59 onVendorDescriptionEdit: description =>
60 licenseModelOverviewActionHelper.editDescriptionOpen(dispatch, {
66 export class VendorDataView extends Component {
68 let { data: { vendorName }, description, isReadOnlyMode } = this.props;
70 <div className="vendor-data-view">
71 <div className="vendor-title">vendor</div>
73 className="vendor-name"
74 data-test-id="vlm-summary-vendor-name">
77 {description !== undefined && !isReadOnlyMode
78 ? this.renderDescriptionEdit()
79 : this.renderDescription()}
84 componentWillUnmount() {
85 this.props.onCancel();
90 data: { description },
91 onVendorDescriptionEdit,
97 if (!isReadOnlyMode) {
98 onVendorDescriptionEdit(description);
103 ? 'vendor-description'
104 : 'vendor-description-readonly'
108 className="description-data"
109 data-test-id="vlm-summary-vendor-description">
111 {!isReadOnlyMode && <SVGIcon name="pencil" />}
118 renderDescriptionEdit() {
128 <LicenseModelDescriptionEdit
130 onDataChanged={onDataChanged}
133 genericFieldInfo={genericFieldInfo}
134 description={description}
139 renderOverlay(children) {
140 let { data: { description }, isReadOnlyMode } = this.props;
141 if (isReadOnlyMode) {
147 className="vendor-description-tooltip"
161 export default connect(mapStateToProps, mapActionsToProps)(VendorDataView);