import "choerodon-ui/pro/lib/button/style";
import _Button from "choerodon-ui/pro/lib/button";
import "choerodon-ui/pro/lib/icon/style";
import _Icon from "choerodon-ui/pro/lib/icon";

/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
import React, { useMemo } from 'react';
import { observer } from 'mobx-react-lite';
import "./index.less";
var prefixCls = 'c7ncd-cluster';
var TestConnect = observer(function (_ref) {
  var handleTestConnection = _ref.handleTestConnection,
      nodeRecord = _ref.nodeRecord;

  var getContent = function getContent() {
    if (nodeRecord) {
      var status = nodeRecord.get('status') || 'wait';
      var content;

      switch (status) {
        case 'success':
          content = [/*#__PURE__*/React.createElement(_Icon, {
            type: "finished",
            className: "".concat(prefixCls, "-test-text-icon")
          }), /*#__PURE__*/React.createElement("span", null, "\u6210\u529F")];
          break;

        case 'failed':
          content = [/*#__PURE__*/React.createElement(_Icon, {
            type: "highlight_off",
            className: "".concat(prefixCls, "-test-text-icon")
          }), /*#__PURE__*/React.createElement("span", null, "\u5931\u8D25")];
          break;

        case 'operating':
          content = '正在进行连接测试';
          break;

        default:
          content = '未进行连接测试';
      }

      return /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefixCls, "-test-text ").concat(prefixCls, "-test-text").concat(status ? "-".concat(status) : '')
      }, content);
    }

    return null;
  };

  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-test ").concat(prefixCls, "-test").concat(nodeRecord && nodeRecord.get('status') ? "-".concat(nodeRecord.get('status')) : '')
  }, /*#__PURE__*/React.createElement(_Button, {
    onClick: handleTestConnection,
    className: "".concat(prefixCls, "-test-btn"),
    disabled: nodeRecord && nodeRecord.get('status') === 'operating'
  }, "\u6D4B\u8BD5\u8FDE\u63A5"), getContent());
});
export default TestConnect;