import "choerodon-ui/lib/tooltip/style";
import _Tooltip from "choerodon-ui/lib/tooltip";
import React from 'react';
import { FormattedMessage } from 'react-intl';
import "./index.less";

var Details = function Details(props) {
  var intlPrefix = props.intlPrefix,
      record = props.record,
      prefixCls = props.prefixCls,
      formatMessage = props.formatMessage,
      type = props.type;

  var renderStatus = function renderStatus() {
    var status;

    if (record.get('fail')) {
      status = 'failed';
    } else if (record.get('synchro') && record.get('active')) {
      status = 'active';
    } else if (record.get('active')) {
      status = 'creating';
    } else {
      status = 'stop';
    }

    return status;
  };

  var renderMarketDetails = function renderMarketDetails() {
    return /*#__PURE__*/React.createElement("ul", {
      className: "".concat(prefixCls, "-application-detail-modal")
    }, /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u5E94\u7528\u670D\u52A1\u540D\u79F0"), /*#__PURE__*/React.createElement("span", null, record.get('devopsAppServiceName') || '-')), /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u5E94\u7528\u670D\u52A1\u7F16\u7801"), /*#__PURE__*/React.createElement("span", null, record.get('devopsAppServiceCode') || '-')), /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u6240\u5C5E\u5E02\u573A\u670D\u52A1"), /*#__PURE__*/React.createElement("span", null, record.get('marketServiceName') || '-')), /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u6240\u5C5E\u5E02\u573A\u5E94\u7528\u53CA\u7248\u672C"), /*#__PURE__*/React.createElement("span", null, "".concat(record.get('appName')))));
  };

  var renderOtherDetails = function renderOtherDetails() {
    return /*#__PURE__*/React.createElement("ul", {
      className: "".concat(prefixCls, "-application-detail-modal")
    }, /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, formatMessage({
      id: "".concat(intlPrefix, ".service.status")
    })), /*#__PURE__*/React.createElement(FormattedMessage, {
      id: renderStatus()
    })), /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, formatMessage({
      id: "".concat(intlPrefix, ".service.code")
    })), /*#__PURE__*/React.createElement("span", null, record.get('code'))), /*#__PURE__*/React.createElement("li", {
      className: "detail-item detail-item-has-url"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, record.get('shareProjectName') ? '来源项目' : formatMessage({
      id: "".concat(intlPrefix, ".service.url")
    })), /*#__PURE__*/React.createElement(_Tooltip, {
      title: record.get('repoUrl')
    }, record.get('shareProjectName') ? /*#__PURE__*/React.createElement("span", null, record.get('shareProjectName')) : /*#__PURE__*/React.createElement("a", {
      href: record.get('repoUrl'),
      className: "detail-item-url",
      target: "_blank",
      rel: "nofollow me noopener noreferrer"
    }, /*#__PURE__*/React.createElement("span", null, record.get('repoUrl'))))));
  };

  var renderMiddlewareDetails = function renderMiddlewareDetails() {
    return /*#__PURE__*/React.createElement("ul", {
      className: "".concat(prefixCls, "-application-detail-modal")
    }, /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u5E94\u7528\u6765\u6E90"), /*#__PURE__*/React.createElement("span", null, "\u5E73\u53F0\u9884\u7F6E")), /*#__PURE__*/React.createElement("li", {
      className: "detail-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "detail-item-text"
    }, "\u5E94\u7528\u53CA\u7248\u672C"), /*#__PURE__*/React.createElement("span", null, record.get('appName') || '-')));
  };

  var getContent = function getContent() {
    if (type === 'middleware_service') {
      return renderMiddlewareDetails();
    }

    if (type === 'market_service') {
      return renderMarketDetails();
    }

    return renderOtherDetails();
  };

  return getContent();
};

export default Details;