"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _tooltip = _interopRequireDefault(require("../../../../tooltip"));

var _openData = require("../../../../../utils/open-data");

var _dynamicOperate = _interopRequireDefault(require("../../../img/dynamic-operate.png"));

var _drawerManager = _interopRequireDefault(require("../../../../drawer-manager"));

var _constant = require("../../../constant");

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var prefix = 'titaui-dynamic-operation';

var DynamicOperation = function DynamicOperation(_ref) {
  var feedOperations = _ref.feedOperations,
      data = _ref.data;
  var feedType = data.feedType,
      krId = data.krId,
      okrId = data.okrId,
      taskId = data.taskId,
      workId = data.workId,
      mileStoneId = data.mileStoneId;

  if (!(feedType === _constant.EFeedType.O || feedType === _constant.EFeedType.Kr || feedType === _constant.EFeedType.MileStone || feedType === _constant.EFeedType.Project || feedType === _constant.EFeedType.Task)) {
    return /*#__PURE__*/_react["default"].createElement("span", null);
  }

  var handleClickShowAll = function handleClickShowAll() {
    if (feedType === _constant.EFeedType.Kr) {
      _drawerManager["default"].open('krDetail', {
        krId: krId
      });
    } else if (feedType === _constant.EFeedType.O) {
      _drawerManager["default"].open('okrDetail', {
        okrId: okrId,
        activeTabKey: 'cooperation'
      });
    } else if (feedType === _constant.EFeedType.Task) {
      window.Talent.app.vent.trigger('global-pull-screen', taskId, 'task');
    } else if (feedType === _constant.EFeedType.Project) {
      window.open(window.location.href.replace(window.location.hash, "#work?iTalentNavCode=tita-work&work_id=".concat(workId)));
    } else if (feedType === _constant.EFeedType.MileStone) {
      window.Talent.app.vent.trigger('global-pull-screen', mileStoneId, 'milestone', new window.Talent.Model(data), {
        option: true,
        width: 465,
        React: _react["default"],
        ReactDom: window.ReactDom,
        ReactComponents: window.ReactComponents
      });
    }
  };

  return feedOperations.comments && /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "__operate")
  }, feedOperations.comments.map(function (comment, index) {
    var createTime = comment.createTime,
        content = comment.content;
    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "__operate-item")
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "__operate-item-left")
    }, /*#__PURE__*/_react["default"].createElement("img", {
      className: "".concat(prefix, "__operate-icon"),
      src: _dynamicOperate["default"],
      alt: ""
    }), /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "__operate-time")
    }, createTime)), /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "__operate-item-right")
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "__operate-user")
    }, /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Text, {
      maxWidth: 98,
      text: /*#__PURE__*/_react["default"].createElement(_openData.OpenUserName, {
        name: comment.publishUser.name,
        id: comment.publishUser.userId
      })
    })), /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "__operate-content")
    }, (0, _openData.parseHtmlAndTextTag)(content)))), index === 2 && feedOperations.total > 3 && /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "__operate-item")
    }, /*#__PURE__*/_react["default"].createElement("img", {
      className: "".concat(prefix, "__operate-icon"),
      src: _dynamicOperate["default"],
      alt: ""
    }), /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "__operate-item-total"),
      onClick: handleClickShowAll
    }, "\u5168\u90E8\u64CD\u4F5C", /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "__operate-item-total-num")
    }, feedOperations.total), /*#__PURE__*/_react["default"].createElement("i", {
      className: (0, _classnames["default"])('tu-icon-APP-xi')
    }))));
  }));
};

var _default = DynamicOperation;
exports["default"] = _default;