var _excluded = ["status", "gitlabJobId", "id", "durationSeconds", "startedDate", "finishedDate", "type", "name"];

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
import React from 'react';
import { observer } from 'mobx-react-lite';
import "./index.less";
import getDuration from "../../../../../../utils/getDuration";
import DetailItem from "./detailItem";
export default observer(function (props) {
  // 抛出piplineName
  var piplineStageName = props.piplineStageName,
      piplineStageStatus = props.piplineStageStatus,
      jobRecordVOList = props.jobRecordVOList,
      stageSeconds = props.stageSeconds,
      stageType = props.stageType,
      parallel = props.parallel,
      _props$triggerType = props.triggerType,
      triggerType = _props$triggerType === void 0 ? 'auto' : _props$triggerType,
      handleRefresh = props.handleRefresh,
      history = props.history,
      location = props.location,
      stageId = props.stageId,
      cdRecordId = props.cdRecordId,
      viewId = props.viewId,
      gitlabPipelineId = props.gitlabPipelineId;

  var renderItem = function renderItem() {
    var hasJobs = jobRecordVOList && jobRecordVOList.length > 0;
    var lists = hasJobs && jobRecordVOList.map(function (item, i) {
      // eslint-disable-next-line no-param-reassign
      item.display = 'none';
      return item;
    });
    return hasJobs ? lists.map(function (item) {
      var status = item.status,
          gitlabJobId = item.gitlabJobId,
          jobRecordId = item.id,
          durationSeconds = item.durationSeconds,
          startedDate = item.startedDate,
          finishedDate = item.finishedDate,
          type = item.type,
          name = item.name,
          rest = _objectWithoutProperties(item, _excluded);

      return /*#__PURE__*/React.createElement(DetailItem, Object.assign({
        gitlabPipelineId: gitlabPipelineId,
        key: gitlabJobId,
        jobStatus: status,
        jobRecordId: jobRecordId,
        handleRefresh: handleRefresh,
        history: history,
        location: location,
        stageId: stageId,
        jobDurationSeconds: durationSeconds,
        itemType: type,
        jobName: name,
        gitlabJobId: gitlabJobId,
        cdRecordId: cdRecordId,
        viewId: viewId
      }, rest));
    }) : '无执行详情...';
  };

  var realType = stageType === null || stageType === void 0 ? void 0 : stageType.toUpperCase();
  return /*#__PURE__*/React.createElement("div", {
    className: "c7n-piplineManage-detail-column c7n-piplineManage-detail-column-".concat(piplineStageStatus)
  }, /*#__PURE__*/React.createElement("div", {
    className: "c7n-piplineManage-detail-column-header"
  }, /*#__PURE__*/React.createElement("span", null, piplineStageName), /*#__PURE__*/React.createElement("span", {
    className: "c7n-piplineManage-stage-type c7n-piplineManage-stage-type-".concat(realType)
  }, realType), stageSeconds ? /*#__PURE__*/React.createElement("span", null, getDuration(stageSeconds)) : null), /*#__PURE__*/React.createElement("div", {
    className: "c7n-piplineManage-detail-column-lists"
  }, /*#__PURE__*/React.createElement("h6", null, "\u4EFB\u52A1\u5217\u8868", /*#__PURE__*/React.createElement("span", {
    className: "c7n-piplineManage-stage-type-task c7n-piplineManage-stage-type-task-".concat(parallel || realType === 'CI' ? 'parallel' : 'serial')
  }, parallel || realType === 'CI' ? '任务并行' : '任务串行')), renderItem()), /*#__PURE__*/React.createElement("div", {
    className: "c7n-piplineManage-detail-column-type"
  }, /*#__PURE__*/React.createElement("svg", {
    xmlns: "http://www.w3.org/2000/svg",
    width: "28",
    height: "9",
    viewBox: "0 0 28 9"
  }, /*#__PURE__*/React.createElement("path", {
    fill: "#6887E8",
    d: "M511.5,131 L520.5,135.5 L511.5,140 L511.5,136 L493,136 L493,135 L511.5,135 L511.5,131 Z",
    transform: "translate(-493 -131)"
  }))));
});