import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import EditorModeEdit from '@material-ui/icons/Edit';

var EditFile =
/*#__PURE__*/
function (_PureComponent) {
  _inherits(EditFile, _PureComponent);

  function EditFile() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, EditFile);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(EditFile)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleEdit", function () {
      var _this$props = _this.props,
          filePath = _this$props.filePath,
          localization = _this$props.localization;

      if (confirm(localization.common.wantToOpen(filePath))) {
        _this.props.globalEvent.emit('message.editor', {
          data: {
            value: filePath
          }
        });
      }
    });

    return _this;
  }

  _createClass(EditFile, [{
    key: "render",
    value: function render() {
      var localization = this.props.localization;
      return React.createElement(Button, {
        variant: "text",
        onClick: this.handleEdit
      }, React.createElement(EditorModeEdit, null), localization.common.editFile);
    }
  }]);

  return EditFile;
}(PureComponent);

_defineProperty(EditFile, "propTypes", {
  filePath: PropTypes.string.isRequired,
  localization: PropTypes.object.isRequired,
  globalEvent: PropTypes.object.isRequired
});

export { EditFile as default };