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, onMoreVersionsClick, onCreate, onSave, onClose,
26 onVersionControllerAction, onNavigate, children, meta, onManagePermissions, onOpenCommentCommitModal, onOpenPermissions, onOpenRevisionsModal} = this.props;
27 let {versionControllerProps} = this.props;
28 const {className = ''} = React.Children.only(children).props;
29 const child = this.prepareChild();
32 versionControllerProps = {
33 ...versionControllerProps,
34 onClose: () => onClose(versionControllerProps)
38 <div className='software-product-view'>
39 <div className='software-product-navigation-side-bar'>
40 <NavigationSideBar {...navigationBarProps} onSelect={onNavigate} onToggle={onToggle}/>
42 <div className='software-product-landing-view-right-side flex-column'>
44 {...versionControllerProps}
45 onVersionSwitching={version => onVersionSwitching(version, meta)}
46 onMoreVersionsClick={onMoreVersionsClick}
47 onManagePermissions={onManagePermissions}
48 onOpenCommentCommitModal={onOpenCommentCommitModal}
49 onOpenPermissions={onOpenPermissions}
50 onOpenRevisionsModal={onOpenRevisionsModal}
51 callVCAction={(action, version, comment) => onVersionControllerAction(action, version, comment, meta)}
52 onCreate={onCreate && this.handleCreate}
53 onSave={onSave && this.handleSave}/>
54 <div className={classnames('content-area', `${className}`)}>
65 const {onSave, onCreate, children} = this.props;
67 const additionalChildProps = {ref: 'editor'};
69 additionalChildProps.onSave = onSave;
72 additionalChildProps.onCreate = onCreate;
75 const child = React.cloneElement(React.Children.only(children), additionalChildProps);
82 const childInstance = this.refs.editor.getWrappedInstance();
83 if (childInstance.save) {
84 return childInstance.save();
86 return this.props.onSave();
90 handleCreate = () => {
91 const childInstance = this.refs.editor.getWrappedInstance();
92 if (childInstance.create) {
93 childInstance.create();
95 this.props.onCreate();