Liferay.Loader.define("portal-workflow-metrics-web@2.0.59/js/components/settings/indexes-page/IndexesPageBody.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/list', '@frontend-taglib-clay$clayui/progress-bar', 'frontend-js-react-web$react', '../../../shared/components/promises-resolver/PromisesResolver.es', './IndexesConstants.es', './IndexesPageBodyList.es', './hooks/useReindexActions.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.Body = void 0;

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

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

    var _progressBar = _interopRequireDefault(require("@frontend-taglib-clay$clayui/progress-bar"));

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

    var _PromisesResolver = _interopRequireDefault(require("../../../shared/components/promises-resolver/PromisesResolver.es"));

    var _IndexesConstants = require("./IndexesConstants.es");

    var _IndexesPageBodyList = require("./IndexesPageBodyList.es");

    var _useReindexActions2 = require("./hooks/useReindexActions.es");

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

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    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;
    }

    var Body = function Body(_ref) {
      var _ref$items = _ref.items,
          items = _ref$items === void 0 ? [] : _ref$items;

      var _useReindexActions = (0, _useReindexActions2.useReindexActions)(),
          getReindexStatus = _useReindexActions.getReindexStatus,
          handleReindex = _useReindexActions.handleReindex,
          isReindexing = _useReindexActions.isReindexing;

      var _getReindexStatus = getReindexStatus(_IndexesConstants.ALL_INDEXES_KEY),
          _getReindexStatus$com = _getReindexStatus.completionPercentage,
          completionPercentage = _getReindexStatus$com === void 0 ? 0 : _getReindexStatus$com;

      var groups = (0, _IndexesConstants.getIndexesGroups)();
      items.forEach(function (_ref2) {
        var group = _ref2.group,
            index = _objectWithoutProperties(_ref2, ["group"]);

        if (groups[group]) {
          groups[group].indexes.push(index);
        }
      });
      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_list.default, null, /*#__PURE__*/_react.default.createElement(_list.default.Item, {
          className: "autofit-row-center reindex-action",
          flex: true
        }, /*#__PURE__*/_react.default.createElement(_list.default.ItemField, {
          className: "font-weight-semi-bold",
          expand: true
        }, Liferay.Language.get('workflow-indexes')), /*#__PURE__*/_react.default.createElement(_list.default.ItemField, null, isReindexing(_IndexesConstants.ALL_INDEXES_KEY) ? /*#__PURE__*/_react.default.createElement(_progressBar.default, {
          value: completionPercentage
        }) : /*#__PURE__*/_react.default.createElement(_button.default, {
          displayType: "primary",
          onClick: function onClick() {
            return handleReindex(_IndexesConstants.ALL_INDEXES_KEY);
          },
          small: true
        }, Liferay.Language.get('reindex-all'))))), /*#__PURE__*/_react.default.createElement(_PromisesResolver.default.Resolved, null, Object.values(groups).map(function (group, index) {
          return (/*#__PURE__*/_react.default.createElement(Body.List, _extends({
              disabled: isReindexing(_IndexesConstants.ALL_INDEXES_KEY) || isReindexing(group.key),
              getReindexStatus: getReindexStatus,
              handleReindex: handleReindex,
              isReindexing: isReindexing,
              key: index
            }, group))
          );
        })))
      );
    };

    exports.Body = Body;
    Body.List = _IndexesPageBodyList.List;
    //# sourceMappingURL=IndexesPageBody.es.js.map
  }
});
//# sourceMappingURL=IndexesPageBody.es.js.map