Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/sla/list-page/SLAListPageTableItem.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/layout', '@frontend-taglib-clay$clayui/table', 'frontend-js-react-web$react', '../../../shared/components/quick-action-kebab/QuickActionKebab.es', '../../../shared/components/router/ChildLink.es', '../../../shared/hooks/useRouter.es', '../../../shared/util/duration.es', '../../../shared/util/moment.es', './SLAListPage.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

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

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _layout = _interopRequireDefault(require("@frontend-taglib-clay$clayui/layout"));

    var _table = _interopRequireDefault(require("@frontend-taglib-clay$clayui/table"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _QuickActionKebab = _interopRequireDefault(require("../../../shared/components/quick-action-kebab/QuickActionKebab.es"));

    var _ChildLink = _interopRequireDefault(require("../../../shared/components/router/ChildLink.es"));

    var _useRouter2 = require("../../../shared/hooks/useRouter.es");

    var _duration = require("../../../shared/util/duration.es");

    var _moment = _interopRequireDefault(require("../../../shared/util/moment.es"));

    var _SLAListPage = require("./SLAListPage.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    var Item = function Item(_ref) {
      var dateModified = _ref.dateModified,
          description = _ref.description,
          duration = _ref.duration,
          id = _ref.id,
          name = _ref.name,
          processId = _ref.processId,
          status = _ref.status;

      var _useRouter = (0, _useRouter2.useRouter)(),
          history = _useRouter.history,
          search = _useRouter.location.search;

      var _useContext = (0, _react.useContext)(_SLAListPage.SLAListPageContext),
          showDeleteModal = _useContext.showDeleteModal;

      var handleDelete = (0, _react.useCallback)(function () {
        showDeleteModal(id);
      }, [id, showDeleteModal]);
      var blocked = status === 2;
      var durationString = (0, _duration.formatDuration)(duration);
      var blockedStatusClass = blocked ? 'text-danger' : '';
      var statusText = blocked ? Liferay.Language.get('blocked') : Liferay.Language.get('running');
      var dropDownItems = [{
        label: Liferay.Language.get('edit'),
        onClick: function onClick() {
          history.push({
            pathname: "/sla/".concat(processId, "/edit/").concat(id),
            search: search
          });
        }
      }, {
        label: Liferay.Language.get('delete'),
        onClick: handleDelete
      }];
      return (/*#__PURE__*/_react.default.createElement(_table.default.Row, null, /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, /*#__PURE__*/_react.default.createElement("div", {
          className: "table-list-title"
        }, blocked && /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "text-danger",
          symbol: "exclamation-full"
        }), ' ', /*#__PURE__*/_react.default.createElement(_ChildLink.default, {
          to: "/sla/".concat(processId, "/edit/").concat(id)
        }, name))), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, description), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          className: blockedStatusClass
        }, statusText), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, durationString), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, _moment.default.utc(dateModified).format(Liferay.Language.get('mmm-dd'))), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          className: "actions"
        }, /*#__PURE__*/_react.default.createElement(_layout.default.ContentCol, null, /*#__PURE__*/_react.default.createElement(_QuickActionKebab.default, {
          dropDownItems: dropDownItems
        }))))
      );
    };

    exports.Item = Item;
    //# sourceMappingURL=SLAListPageTableItem.es.js.map
  }
});
//# sourceMappingURL=SLAListPageTableItem.es.js.map