import "choerodon-ui/lib/avatar/style";
import _Avatar from "choerodon-ui/lib/avatar";
import React from 'react';
import { FormattedMessage } from 'react-intl';
import _ from 'lodash';
import "./index.less";
export default function (_ref) {
  var record = _ref.record,
      formatMessage = _ref.formatMessage,
      prefixCls = _ref.prefixCls,
      intlPrefix = _ref.intlPrefix;
  var statusLabel;

  if (record.get('fail')) {
    // 失败
    statusLabel = {
      status: 'failed',
      color: '#f44336'
    };
  } else if (record.get('synchro') && record.get('active')) {
    // 运行中
    statusLabel = {
      status: 'active',
      color: '#00bf96'
    };
  } else if (record.get('active')) {
    // 创建中
    statusLabel = {
      status: 'ci_created',
      color: '#4d90fe'
    };
  } else {
    // 停止
    statusLabel = {
      status: 'stop',
      color: '#d3d3d3'
    };
  }

  return /*#__PURE__*/React.createElement("ul", {
    className: "".concat(prefixCls, "-detail")
  }, /*#__PURE__*/React.createElement("li", {
    className: "detail-item-avatar"
  }, record && record.get('imgUrl') ? /*#__PURE__*/React.createElement(_Avatar, {
    size: 80,
    src: record.get('imgUrl')
  }) : /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-detail-avatar")
  }, /*#__PURE__*/React.createElement("span", null, record.get('name') ? record.get('name').slice(0, 1) : '?'))), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: "".concat(intlPrefix, ".name")
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('name'))), /*#__PURE__*/React.createElement("li", {
    className: "detail-item detail-item-has-url"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'app.status'
  })), /*#__PURE__*/React.createElement(StatusLabel, statusLabel)), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: "".concat(intlPrefix, ".type")
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('type') && formatMessage({
    id: "app.type.".concat(record.get('type'))
  }))), /*#__PURE__*/React.createElement("li", {
    className: "detail-item detail-item-has-url"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'repository.head'
  })), record && record.get('repoUrl') ? /*#__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'))) : '-'), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'createDate'
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('creationDate') || '-')), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'creator'
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('createUserName') || '-')), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'updateDate'
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('lastUpdateDate') || '-')), /*#__PURE__*/React.createElement("li", {
    className: "detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "detail-item-text"
  }, formatMessage({
    id: 'updater'
  })), /*#__PURE__*/React.createElement("span", null, record && record.get('updateUserName') || '-')));
}

function StatusLabel(props) {
  return /*#__PURE__*/React.createElement("div", {
    className: "status-label",
    style: {
      background: props.color
    }
  }, /*#__PURE__*/React.createElement("span", {
    className: "status-label-text"
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: props.status
  })));
}