'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

var _Menu = require('@instructure/ui-menu/lib/components/Menu');

var _Menu2 = _interopRequireDefault(_Menu);

var _MenuItem = require('@instructure/ui-menu/lib/components/Menu/MenuItem');

var _MenuItem2 = _interopRequireDefault(_MenuItem);

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

var _IconMoreSolid = require('instructure-icons/lib/Solid/IconMoreSolid');

var _IconMoreSolid2 = _interopRequireDefault(_IconMoreSolid);

var _IconImportContentLine = require('instructure-icons/lib/Line/IconImportContentLine');

var _IconImportContentLine2 = _interopRequireDefault(_IconImportContentLine);

var _ScreenReaderContent = require('@instructure/ui-a11y/lib/components/ScreenReaderContent');

var _ScreenReaderContent2 = _interopRequireDefault(_ScreenReaderContent);

var _lib = require('@instructure/ui-themeable/lib');

var _lib2 = _interopRequireDefault(_lib);

var _QTIImportModal = require('../../../building/components/QTIImportModal');

var _QTIImportModal2 = _interopRequireDefault(_QTIImportModal);

var _constants = require('../../../constants');

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

var _formatMessage = require('../../../common/format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.HeaderMenu__styles__menuIcon {\n  vertical-align: middle;\n  margin-right: ' + theme.menuIconMargin + ';\n  font-size: ' + theme.menuIconFontSize + ';\n}\n';
  },
  'menuIcon': 'HeaderMenu__styles__menuIcon'
};
var HeaderMenu = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(HeaderMenu, _Component);

  function HeaderMenu() {
    (0, _classCallCheck3.default)(this, HeaderMenu);
    return (0, _possibleConstructorReturn3.default)(this, (HeaderMenu.__proto__ || Object.getPrototypeOf(HeaderMenu)).apply(this, arguments));
  }

  (0, _createClass3.default)(HeaderMenu, [{
    key: 'renderMenu',
    value: function renderMenu() {
      return _react2.default.createElement(
        _Menu2.default,
        {
          trigger: _react2.default.createElement(
            _Button2.default,
            { variant: 'icon', icon: _IconMoreSolid2.default },
            _react2.default.createElement(
              _ScreenReaderContent2.default,
              null,
              'Plus d\u2019actions d\u2019\xE9l\xE9ment de banque'
            )
          )
        },
        _react2.default.createElement(
          _MenuItem2.default,
          {
            key: 'import',
            disabled: !this.props.bank.canImport(),
            onSelect: this.props.openImportModal
          },
          _react2.default.createElement(_IconImportContentLine2.default, { className: styles.menuIcon, 'data-automation': 'sdk-headermenu-import-content' }),
          'Importer du contenu'
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      var bank = this.props.bank;

      return _react2.default.createElement(
        'div',
        null,
        this.renderMenu(),
        _react2.default.createElement(_QTIImportModal2.default, {
          parentId: bank.id,
          parentType: _constants.PARENT_TYPE_BANK,
          qtiImport: bank.getLatestImport(),
          'data-automation': 'sdk-qti-import-modal'
        })
      );
    }
  }]);
  HeaderMenu.displayName = 'HeaderMenu'
  ;
  return HeaderMenu;
}(_react.Component), _class2.propTypes = {
  openImportModal: _propTypes2.default.func.isRequired,
  bank: _reactImmutableProptypes2.default.record.isRequired
}, _temp)) || _class);
exports.default = HeaderMenu;