UNPKG

feeles-ide

Version:

The hackable and serializable IDE to make learning material

152 lines (135 loc) 4.53 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, { Component } from 'react'; import PropTypes from 'prop-types'; import Dialog from 'material-ui/Dialog'; import Table, { TableBody, TableRow, TableRowColumn } from 'material-ui/Table'; import TextField from 'material-ui/TextField'; import { Confirm, Abort } from './Buttons'; var getStyles = function getStyles() { return { root: { fontSize: 16 }, left: { textAlign: 'right' } }; }; var RenameDialog = function (_Component) { _inherits(RenameDialog, _Component); function RenameDialog() { var _ref; var _temp, _this, _ret; _classCallCheck(this, RenameDialog); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = RenameDialog.__proto__ || _Object$getPrototypeOf(RenameDialog)).call.apply(_ref, [this].concat(args))), _this), _this.state = { changed: false, name: _this.props.content.name, type: _this.props.content.type }, _this.confirm = function () { var _this$props = _this.props, onRequestClose = _this$props.onRequestClose, resolve = _this$props.resolve; var _this$state = _this.state, changed = _this$state.changed, name = _this$state.name, type = _this$state.type; resolve(changed ? { name: name, type: type } : {}); onRequestClose(); }, _this.handleNameChange = function (event, name) { _this.setState({ changed: true, name: name }); }, _this.handleTypeChange = function (event, type) { _this.setState({ changed: true, type: type }); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(RenameDialog, [{ key: 'render', value: function render() { var onRequestClose = this.props.onRequestClose; var _state = this.state, changed = _state.changed, name = _state.name, type = _state.type; var actions = [React.createElement(Abort, { key: 'close', onClick: onRequestClose }), React.createElement(Confirm, { key: 'confirm', label: 'Confirm', disabled: !changed, onClick: this.confirm })]; var _getStyles = getStyles(this.props, this.context), root = _getStyles.root, left = _getStyles.left; return React.createElement( Dialog, { open: true, title: 'File Preference', actions: actions, modal: false, style: root, onRequestClose: onRequestClose }, React.createElement( Table, { selectable: false }, React.createElement( TableBody, { displayRowCheckbox: false }, React.createElement( TableRow, null, React.createElement( TableRowColumn, { style: left }, 'Name' ), React.createElement( TableRowColumn, null, React.createElement(TextField, { id: 'name', defaultValue: name, onChange: this.handleNameChange }) ) ), React.createElement( TableRow, null, React.createElement( TableRowColumn, { style: left }, 'Type' ), React.createElement( TableRowColumn, null, React.createElement(TextField, { id: 'type', defaultValue: type, onChange: this.handleTypeChange }) ) ) ) ) ); } }]); return RenameDialog; }(Component); RenameDialog.propTypes = { resolve: PropTypes.func.isRequired, onRequestClose: PropTypes.func.isRequired, content: PropTypes.any }; RenameDialog.contextTypes = { muiTheme: PropTypes.object.isRequired }; export default RenameDialog;