import "choerodon-ui/pro/lib/tooltip/style";
import _Tooltip from "choerodon-ui/pro/lib/tooltip";
import "choerodon-ui/pro/lib/icon/style";
import _Icon from "choerodon-ui/pro/lib/icon";
import "choerodon-ui/lib/steps/style";
import _Steps from "choerodon-ui/lib/steps";

/* 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 { useFormStore } from "../../stores";
import "./index.less";
var Step = _Steps.Step;
var STATUS = {
  success: 'finish',
  failed: 'error',
  operating: 'process',
  wait: 'wait'
};
var TestConnect = observer(function (_ref) {
  var connectRecord = _ref.connectRecord;

  var _useFormStore = useFormStore(),
      prefixCls = _useFormStore.prefixCls;

  var subfixCls = "".concat(prefixCls, "-final-connect");

  var getContent = function getContent() {
    if (connectRecord) {
      var configuration = connectRecord.configuration,
          system = connectRecord.system,
          memory = connectRecord.memory,
          cpu = connectRecord.cpu;
      return /*#__PURE__*/React.createElement(_Steps, {
        progressDot: true,
        size: "small"
      }, /*#__PURE__*/React.createElement(Step, {
        status: STATUS[configuration.status],
        title: configuration.status === 'failed' && configuration.errorMessage ? /*#__PURE__*/React.createElement("span", null, "\u914D\u7F6E\u6821\u9A8C", /*#__PURE__*/React.createElement(_Tooltip, {
          title: configuration.errorMessage
        }, /*#__PURE__*/React.createElement(_Icon, {
          type: "info",
          className: "".concat(subfixCls, "-test-failed-icon")
        }))) : '配置校验'
      }), /*#__PURE__*/React.createElement(Step // @ts-ignore
      , {
        status: STATUS[system.status],
        title: system.status === 'failed' && system.errorMessage ? /*#__PURE__*/React.createElement("span", null, "\u8282\u70B9\u7CFB\u7EDF\u6821\u9A8C", /*#__PURE__*/React.createElement(_Tooltip, {
          title: system.errorMessage
        }, /*#__PURE__*/React.createElement(_Icon, {
          type: "info",
          className: "".concat(subfixCls, "-test-failed-icon")
        }))) : '节点系统校验'
      }), /*#__PURE__*/React.createElement(Step // @ts-ignore
      , {
        status: STATUS[memory.status],
        title: memory.status === 'failed' && memory.errorMessage ? /*#__PURE__*/React.createElement("span", null, "\u8282\u70B9\u5185\u5B58\u6821\u9A8C", /*#__PURE__*/React.createElement(_Tooltip, {
          title: memory.errorMessage
        }, /*#__PURE__*/React.createElement(_Icon, {
          type: "info",
          className: "".concat(subfixCls, "-test-failed-icon")
        }))) : '节点内存校验'
      }), /*#__PURE__*/React.createElement(Step // @ts-ignore
      , {
        status: STATUS[cpu.status],
        title: cpu.status === 'failed' && cpu.errorMessage ? /*#__PURE__*/React.createElement("span", null, "\u8282\u70B9CPU\u6821\u9A8C", /*#__PURE__*/React.createElement(_Tooltip, {
          title: cpu.errorMessage
        }, /*#__PURE__*/React.createElement(_Icon, {
          type: "info",
          className: "".concat(subfixCls, "-test-failed-icon")
        }))) : '节点CPU校验'
      }));
    }

    return null;
  };

  return /*#__PURE__*/React.createElement("div", {
    id: "loadingProgress",
    className: "".concat(subfixCls, "-test ").concat(subfixCls, "-test").concat(connectRecord && connectRecord.status ? "-".concat(connectRecord.status) : '')
  }, (connectRecord === null || connectRecord === void 0 ? void 0 : connectRecord.errorMsg) && /*#__PURE__*/React.createElement(_Tooltip, {
    title: connectRecord === null || connectRecord === void 0 ? void 0 : connectRecord.errorMsg
  }, /*#__PURE__*/React.createElement(_Icon, {
    type: "info",
    className: "".concat(subfixCls, "-test-finalMes")
  })), getContent());
});
export default TestConnect;