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 classnames from 'classnames';
19 import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx';
20 import NavigationSideBar from 'nfvo-components/panel/NavigationSideBar.jsx';
22 export default class TabulatedEditor extends React.Component {
25 const {navigationBarProps, onToggle, onVersionSwitching, onCreate, onSave, onClose, onVersionControllerAction, onNavigate, children, meta} = this.props;
26 let {versionControllerProps} = this.props;
27 const {className = ''} = React.Children.only(children).props;
28 const child = this.prepareChild();
31 versionControllerProps = {
32 ...versionControllerProps,
33 onClose: () => onClose(versionControllerProps)
37 <div className='software-product-view'>
38 <div className='software-product-navigation-side-bar'>
39 <NavigationSideBar {...navigationBarProps} onSelect={onNavigate} onToggle={onToggle}/>
41 <div className='software-product-landing-view-right-side flex-column'>
43 {...versionControllerProps}
44 onVersionSwitching={version => onVersionSwitching(version, meta)}
45 callVCAction={(action, version) => onVersionControllerAction(action, version, meta)}
46 onCreate={onCreate && this.handleCreate}
47 onSave={onSave && this.handleSave}/>
48 <div className={classnames('content-area', `${className}`)}>
59 const {onSave, onCreate, children} = this.props;
61 const additionalChildProps = {ref: 'editor'};
63 additionalChildProps.onSave = onSave;
66 additionalChildProps.onCreate = onCreate;
69 const child = React.cloneElement(React.Children.only(children), additionalChildProps);
76 const childInstance = this.refs.editor.getWrappedInstance();
77 if (childInstance.save) {
78 return childInstance.save();
80 return this.props.onSave();
84 handleCreate = () => {
85 const childInstance = this.refs.editor.getWrappedInstance();
86 if (childInstance.create) {
87 childInstance.create();
89 this.props.onCreate();