1 import React from 'react'
2 import LeafGroup from './LeafGroup'
3 import ListStack from './ListStack'
4 import ExplorerColumn from './ExplorerColumn'
5 import yang from '../yang/leaf-utils'
7 export default class extends React.Component {
10 this.state = {actions: [], properties: null};
15 const { model, path, isLast, selected, isReadonly, openElement, editElement, columnCloser } = this.props;
16 const element = model.getElement(path)
17 const name = element.name;
18 console.debug(`ContainerColumn: ${name}`);
19 const data = element.value;
22 const containers = [];
28 container: containers,
33 const properties = this.state.properties || element.schema.properties;
34 properties.forEach((property, index) => {
35 const list = dataDivided[property.type]
36 list && list.push(property)
37 !list && console.debug(`ContainerColumn - unhandled property : ${path}/${property.name} - ${property.type}`)
39 choices.forEach(choice => choice.properties.forEach(c => c.properties.forEach(p => leaves.push(p))));
41 leaves.length && items.push(<LeafGroup key='leaves' model={model} path={path} isReadonly={!isLast} properties={leaves} editElement={editElement} />);
42 containers.length && items.push(<ListStack key='containers' model={model} path={path} properties={containers} selected={selected} openElement={openElement} />);
43 lists.length && items.push(<ListStack key='list' model={model} path={path} properties={lists} selected={selected} openElement={openElement} />);
44 loading.length && items.push(<ListStack key='loading' model={model} path={path} properties={loading} openElement={openElement} />);
45 const actions = this.state.actions.slice();
46 !isLast || isReadonly || !leaves.length || leaves.every(p => yang.isKey(p)) || actions.push('update');
47 function invokeAction(action) {
48 editElement(path, action);
51 <ExplorerColumn title={name || path} isLast={isLast} actions={actions} handler={invokeAction} columnCloser={columnCloser} >
52 <div className='container-column' >
60 console.error("component render", e);