import React from 'react';
import { connect } from 'react-redux';
import { getActiveNamespace } from '../../../../core/namespaceIntegration/selectors';
import { getProjectMetadata } from '../../../../core/dataBus/selectors';
import { CONTROLS_KEYS } from '../../../../core/controlsBus/constants';
import { toggleSwitch, fireButtonAction } from '../../../../core/controlsBus/actions';
import { getSwitches, getCheckedState, getDisabledState } from '../../../../core/controlsBus/selectors';
import ViewSwitchList from './List/ViewSwitchList';

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

  var _ref = namespace ? getProjectMetadata(state, {
    namespace: namespace
  }) : {
    fullFeaturesSupport: false
  },
      fullFeaturesSupport = _ref.fullFeaturesSupport;

  var switches = getSwitches(state);
  return {
    activeNamespace: namespace,
    checkedState: getCheckedState(state),
    disabledState: getDisabledState(state),
    switches: fullFeaturesSupport ? switches : switches.filter(function (s) {
      return s.key !== CONTROLS_KEYS.DEPENDENCIES_DIAGRAM_ON;
    })
  };
};

var mapDispatchToProps = {
  toggleSwitch: toggleSwitch,
  fireButtonAction: fireButtonAction
};
export default connect(mapStateToProps, mapDispatchToProps)(ViewSwitchList);