import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import React from 'react';
import { connect } from 'react-redux';
import { getSource, getSourceLayout } from '../../core/dataBus/selectors';
import { getCheckedState } from '../../core/controlsBus/selectors';
import { getActiveNamespace } from '../../core/namespaceIntegration/selectors';
import ExplorerBar from './component/ExplorerBar';

var ExplorerBarContainer = function ExplorerBarContainer(_ref) {
  var explorerBar = _ref.explorerBar,
      otherProps = _objectWithoutProperties(_ref, ["explorerBar"]);

  if (!explorerBar) return null;
  return React.createElement(ExplorerBar, otherProps);
};

var mapStateToProps = function mapStateToProps(state, props) {
  var namespace = getActiveNamespace(state);

  if (!namespace) {
    return {};
  }

  var namespaceProps = {
    namespace: namespace
  };

  var _getSource = getSource(state, namespaceProps),
      filesMap = _getSource.filesMap,
      foldersMap = _getSource.foldersMap;

  var _getSourceLayout = getSourceLayout(state, namespaceProps),
      sourceLayoutTree = _getSourceLayout.sourceLayoutTree;

  var _getCheckedState = getCheckedState(state),
      explorerBar = _getCheckedState.explorerBar;

  return {
    nodesTree: [sourceLayoutTree],
    filesMap: filesMap,
    foldersMap: foldersMap,
    explorerBar: explorerBar
  };
};

var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    onFolderClick: function onFolderClick(node) {
      /*dispatch(toggleFolder(node))*/
    },
    onFileClick: function onFileClick(node) {
      /*dispatch(selectNode(node));*/
    }
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(ExplorerBarContainer);