Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/settings/indexes-page/IndexesPageBodyList.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'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.List = 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"));

    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 ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    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 Item = function Item(_ref) {
      var btnLabel = _ref.btnLabel,
          disabled = _ref.disabled,
          handleReindex = _ref.handleReindex,
          _ref$item = _ref.item,
          _ref$item$completionP = _ref$item.completionPercentage,
          completionPercentage = _ref$item$completionP === void 0 ? 0 : _ref$item$completionP,
          key = _ref$item.key,
          label = _ref$item.label,
          reindexing = _ref$item.reindexing;
      return (/*#__PURE__*/_react.default.createElement(_list.default.Item, {
          className: "autofit-row-center reindex-action",
          flex: true,
          key: key
        }, /*#__PURE__*/_react.default.createElement(_list.default.ItemField, {
          expand: true
        }, label), /*#__PURE__*/_react.default.createElement(_list.default.ItemField, null, reindexing ? /*#__PURE__*/_react.default.createElement(_progressBar.default, {
          value: completionPercentage
        }) : /*#__PURE__*/_react.default.createElement(_button.default, {
          disabled: disabled,
          displayType: "secondary",
          onClick: function onClick() {
            return handleReindex(key, label);
          },
          small: true
        }, btnLabel)))
      );
    };

    var List = function List(_ref2) {
      var _ref2$indexes = _ref2.indexes,
          indexes = _ref2$indexes === void 0 ? [] : _ref2$indexes,
          getReindexStatus = _ref2.getReindexStatus,
          isReindexing = _ref2.isReindexing,
          label = _ref2.label,
          otherProps = _objectWithoutProperties(_ref2, ["indexes", "getReindexStatus", "isReindexing", "label"]);

      var items = indexes.map(function (item) {
        var status = getReindexStatus(item.key);
        return _objectSpread(_objectSpread({}, item), {}, {
          reindexing: isReindexing(item.key)
        }, status);
      });
      return (/*#__PURE__*/_react.default.createElement(_list.default, null, /*#__PURE__*/_react.default.createElement(_list.default.Header, null, label), items.map(function (item, index) {
          return (/*#__PURE__*/_react.default.createElement(List.Item, _extends({
              btnLabel: index === 0 ? Liferay.Language.get('reindex-all') : Liferay.Language.get('reindex'),
              item: item,
              key: index
            }, otherProps))
          );
        }))
      );
    };

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