UNPKG

feeles-ide

Version:

The hackable and serializable IDE to make learning material

70 lines (56 loc) 2.3 kB
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _createClass from 'babel-runtime/helpers/createClass'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import FlatButton from 'material-ui/FlatButton'; import EditorModeEdit from 'material-ui/svg-icons/editor/mode-edit'; import { Tab } from '../ChromeTab/'; var EditFile = function (_PureComponent) { _inherits(EditFile, _PureComponent); function EditFile() { var _ref; var _temp, _this, _ret; _classCallCheck(this, EditFile); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = EditFile.__proto__ || _Object$getPrototypeOf(EditFile)).call.apply(_ref, [this].concat(args))), _this), _this.handleEdit = function () { var _this$props = _this.props, fileKey = _this$props.fileKey, localization = _this$props.localization; var getFile = function getFile() { return _this.props.findFile(function (item) { return item.key === fileKey; }); }; var item = getFile(); if (item && confirm(localization.common.wantToOpen(item.name))) { var tab = new Tab({ getFile: getFile }); _this.props.selectTab(tab); } }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(EditFile, [{ key: 'render', value: function render() { var localization = this.props.localization; return React.createElement(FlatButton, { disabled: !this.props.fileKey, label: localization.common.editFile, icon: React.createElement(EditorModeEdit, null), onClick: this.handleEdit }); } }]); return EditFile; }(PureComponent); EditFile.propTypes = { fileKey: PropTypes.string.isRequired, findFile: PropTypes.func.isRequired, selectTab: PropTypes.func.isRequired, localization: PropTypes.object.isRequired }; export default EditFile;