2 * Copyright © 2016-2018 European Support Limited
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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import React from 'react';
17 import isEqual from 'lodash/isEqual';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import SortableListItem from './SortableListItem.js';
20 import { fileTypes } from '../HeatSetupConstants.js';
22 import Button from 'sdc-ui/lib/react/Button.js';
23 import ModuleFile from './ModuleFile.js';
25 class SortableModuleFileList extends React.Component {
28 data: this.props.modules
31 componentDidUpdate() {
32 if (!isEqual(this.state.data, this.props.modules)) {
33 /* eslint-disable-next-line */
35 data: this.props.modules
47 onModuleFileTypeChange,
48 onToggleVolFilesDisplay,
52 const childProps = module => ({
56 onModuleFileTypeChange: (value, type) => {
58 type === fileTypes.VOL.label ||
59 type === fileTypes.VOL_ENV.label
61 onToggleVolFilesDisplay({ module, value: false });
63 onModuleFileTypeChange({ module, value, type });
67 displayVolumes: Boolean(
68 module.vol || module.volEnv || module.showVolFiles
70 onToggleVolFilesDisplay: value =>
71 onToggleVolFilesDisplay({ module, value })
74 let listItems = this.state.data.map(function(item, i) {
78 updateState={data => this.setState(data)}
79 items={this.state.data}
80 draggingIndex={this.state.draggingIndex}
85 isReadOnlyMode={this.props.isReadOnlyMode}
93 className={`modules-list-wrapper ${
94 listItems.length > 0 ? 'modules-list-wrapper-divider' : ''
96 <div className="modules-list-header">
103 isReadOnlyMode || unassigned.length === 0
112 onClick={onModuleAdd}
114 isReadOnlyMode || unassigned.length === 0
120 {listItems.length > 0 && <ul>{listItems}</ul>}
126 export default SortableModuleFileList;