"use strict";

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

var _react = _interopRequireWildcard(require("react"));

var _reactEasyState = require("react-easy-state");

var _screen = _interopRequireDefault(require("../screen"));

var _emphasize = _interopRequireDefault(require("../utils/emphasize"));

var _details = _interopRequireDefault(require("../store/details"));

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

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

class DetailedShortcuts extends _react.Component {
  componentDidMount() {
    _screen.default.key('g', () => {
      _details.default.tab = 'general';
    });

    _screen.default.key('v', () => {
      _details.default.tab = 'volumes';
    });

    _screen.default.key('p', () => {
      _details.default.tab = 'ports';
    });

    _screen.default.key('enter', () => {
      _screen.default.unkey('g');

      _screen.default.unkey('v');

      _screen.default.unkey('p');

      _screen.default.unkey('enter'); // fixme: when not using setTimeout, we get warning :
      // Can only update a mounted or mounting component


      setTimeout(() => {
        _details.default.detailed = false;
      }, 1);
    });
  }

  render() {
    const bindings = [[(0, _emphasize.default)('G'), 'General'], [(0, _emphasize.default)('V'), 'Volumes'], [(0, _emphasize.default)('P'), 'Ports'], [(0, _emphasize.default)('↵') + ' ', 'Logs view']].map(entry => entry.join(': ')).join(' | ');
    return _react.default.createElement("text", {
      left: "0%",
      top: "99%",
      width: "100%",
      height: "1",
      valign: "middle",
      tags: true,
      content: bindings
    });
  }

}

var _default = (0, _reactEasyState.view)(DetailedShortcuts);

exports.default = _default;