@bigbinary/neeto-rules-frontend 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9428,7 +9428,8 @@ var RulesReorder = function RulesReorder(_ref) {
9428
9428
  rules = _ref.rules,
9429
9429
  _ref$paginationProps = _ref.paginationProps,
9430
9430
  paginationProps = _ref$paginationProps === void 0 ? {} : _ref$paginationProps,
9431
- url = _ref.url;
9431
+ url = _ref.url,
9432
+ onReorderSuccess = _ref.onReorderSuccess;
9432
9433
  var _useState = useState(rules),
9433
9434
  _useState2 = _slicedToArray$1(_useState, 2),
9434
9435
  initialRules = _useState2[0],
@@ -9454,7 +9455,10 @@ var RulesReorder = function RulesReorder(_ref) {
9454
9455
  }
9455
9456
  }
9456
9457
  }, {
9457
- onSuccess: onClose
9458
+ onSuccess: function onSuccess() {
9459
+ onReorderSuccess === null || onReorderSuccess === void 0 || onReorderSuccess();
9460
+ onClose();
9461
+ }
9458
9462
  });
9459
9463
  };
9460
9464
  var onDragEnd = function onDragEnd(result) {
@@ -9748,7 +9752,12 @@ var RulesTable = function RulesTable(_ref) {
9748
9752
  rules = _ref$rules === void 0 ? [] : _ref$rules,
9749
9753
  totalCount = _ref.totalCount,
9750
9754
  helpDocUrl = _ref.helpDocUrl,
9751
- isLoading = _ref.isLoading;
9755
+ isLoading = _ref.isLoading,
9756
+ onDeleteSuccess = _ref.onDeleteSuccess,
9757
+ onCloneSuccess = _ref.onCloneSuccess,
9758
+ onUpdateSuccess = _ref.onUpdateSuccess,
9759
+ page = _ref.page,
9760
+ setPage = _ref.setPage;
9752
9761
  var _useQueryParams = useQueryParams(),
9753
9762
  _useQueryParams$searc = _useQueryParams.searchTerm,
9754
9763
  searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
@@ -9756,10 +9765,6 @@ var RulesTable = function RulesTable(_ref) {
9756
9765
  _useState2 = _slicedToArray$1(_useState, 2),
9757
9766
  selectedRule = _useState2[0],
9758
9767
  setSelectedRule = _useState2[1];
9759
- var _useState3 = useState(DEFAULT_INIT_PAGE),
9760
- _useState4 = _slicedToArray$1(_useState3, 2),
9761
- page = _useState4[0],
9762
- setPage = _useState4[1];
9763
9768
  var _useUtilityStore = useUtilityStore(function (store) {
9764
9769
  return {
9765
9770
  hidePreviewPane: store["hidePreviewPane"]
@@ -9788,8 +9793,19 @@ var RulesTable = function RulesTable(_ref) {
9788
9793
  id: id,
9789
9794
  url: url,
9790
9795
  payload: payload
9796
+ }, {
9797
+ onSuccess: onUpdateSuccess
9791
9798
  });
9792
9799
  };
9800
+ var handleCloneSuccess = function handleCloneSuccess() {
9801
+ onCloneSuccess();
9802
+ hidePreviewPane();
9803
+ };
9804
+ var handleDeleteSuccess = function handleDeleteSuccess() {
9805
+ onDeleteSuccess();
9806
+ hidePreviewPane();
9807
+ setSelectedRule(null);
9808
+ };
9793
9809
  var columnData = getColumnData({
9794
9810
  handleChangeStatus: handleChangeStatus,
9795
9811
  additionalColumns: additionalColumns,
@@ -9798,7 +9814,7 @@ var RulesTable = function RulesTable(_ref) {
9798
9814
  id: id,
9799
9815
  url: url
9800
9816
  }, {
9801
- onSuccess: hidePreviewPane
9817
+ onSuccess: handleCloneSuccess
9802
9818
  });
9803
9819
  },
9804
9820
  onDelete: setSelectedRule,
@@ -9806,7 +9822,7 @@ var RulesTable = function RulesTable(_ref) {
9806
9822
  automationRulesPath: automationRulesPath,
9807
9823
  moreDropdownItems: moreDropdownItems
9808
9824
  });
9809
- if (isLoading) {
9825
+ if (isLoading && isEmpty(rules)) {
9810
9826
  return /*#__PURE__*/jsx$1(PageLoader, {});
9811
9827
  }
9812
9828
  if (isEmpty(rules)) {
@@ -9842,7 +9858,7 @@ var RulesTable = function RulesTable(_ref) {
9842
9858
  currentPageNumber: page,
9843
9859
  defaultPageSize: DEFAULT_PAGE_SIZE,
9844
9860
  handlePageChange: setPage,
9845
- loading: isUpdating || isCloning || isDeleting,
9861
+ loading: isUpdating || isCloning || isDeleting || isLoading,
9846
9862
  rowData: rules.map(function (item) {
9847
9863
  return _objectSpread$n({
9848
9864
  key: item.id
@@ -9873,10 +9889,7 @@ var RulesTable = function RulesTable(_ref) {
9873
9889
  id: selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.id,
9874
9890
  url: url
9875
9891
  }, {
9876
- onSuccess: function onSuccess() {
9877
- hidePreviewPane();
9878
- setSelectedRule(null);
9879
- }
9892
+ onSuccess: handleDeleteSuccess
9880
9893
  });
9881
9894
  }
9882
9895
  })]
@@ -9886,7 +9899,7 @@ var RulesTable = function RulesTable(_ref) {
9886
9899
  function ownKeys$n(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9887
9900
  function _objectSpread$m(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$n(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$n(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9888
9901
  var NeetoRules = function NeetoRules(_ref) {
9889
- var _helpPopoverProps$hel;
9902
+ var _helpPopoverProps$hel, _cloneRule$onSuccess, _deleteRule$onSuccess, _updateRule$onSuccess, _reorderRules$onSucce;
9890
9903
  var breadcrumbs = _ref.breadcrumbs,
9891
9904
  automationRulesPath = _ref.automationRulesPath,
9892
9905
  url = _ref.automationRulesEndpoint,
@@ -9895,13 +9908,17 @@ var NeetoRules = function NeetoRules(_ref) {
9895
9908
  _ref$rulesTableProps = _ref.rulesTableProps,
9896
9909
  rulesTableProps = _ref$rulesTableProps === void 0 ? {} : _ref$rulesTableProps,
9897
9910
  _ref$helpPopoverProps = _ref.helpPopoverProps,
9898
- helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps;
9911
+ helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
9912
+ deleteRule = _ref.deleteRule,
9913
+ cloneRule = _ref.cloneRule,
9914
+ updateRule = _ref.updateRule,
9915
+ reorderRules = _ref.reorderRules;
9899
9916
  var _useState = useState(false),
9900
9917
  _useState2 = _slicedToArray$1(_useState, 2),
9901
9918
  isReorderPaneOpen = _useState2[0],
9902
9919
  setIsReorderPaneOpen = _useState2[1];
9903
9920
  var helpDocUrl = helpPopoverProps === null || helpPopoverProps === void 0 || (_helpPopoverProps$hel = helpPopoverProps.helpLinkProps) === null || _helpPopoverProps$hel === void 0 ? void 0 : _helpPopoverProps$hel.href;
9904
- var _useState3 = useState(1),
9921
+ var _useState3 = useState(DEFAULT_INIT_PAGE),
9905
9922
  _useState4 = _slicedToArray$1(_useState3, 2),
9906
9923
  page = _useState4[0],
9907
9924
  setPage = _useState4[1];
@@ -9920,7 +9937,8 @@ var NeetoRules = function NeetoRules(_ref) {
9920
9937
  rules = _useFetchAutomationRu4 === void 0 ? [] : _useFetchAutomationRu4,
9921
9938
  _useFetchAutomationRu5 = _useFetchAutomationRu3.totalCount,
9922
9939
  totalCount = _useFetchAutomationRu5 === void 0 ? 0 : _useFetchAutomationRu5,
9923
- isLoading = _useFetchAutomationRu.isLoading;
9940
+ isLoading = _useFetchAutomationRu.isLoading,
9941
+ isFetching = _useFetchAutomationRu.isFetching;
9924
9942
  var hasUnfilteredRules = isPresent(searchTerm) || totalCount > 0;
9925
9943
  return /*#__PURE__*/jsxs(Container, {
9926
9944
  children: [/*#__PURE__*/jsx$1(Header$1, {
@@ -9930,26 +9948,33 @@ var NeetoRules = function NeetoRules(_ref) {
9930
9948
  hasUnfilteredRules: hasUnfilteredRules,
9931
9949
  helpPopoverProps: helpPopoverProps,
9932
9950
  setIsReorderPaneOpen: setIsReorderPaneOpen
9933
- }), /*#__PURE__*/jsx$1(RulesTable, _objectSpread$m({}, _objectSpread$m({
9951
+ }), /*#__PURE__*/jsx$1(RulesTable, _objectSpread$m(_objectSpread$m({}, _objectSpread$m({
9934
9952
  automationRulesPath: automationRulesPath,
9935
9953
  helpDocUrl: helpDocUrl,
9936
- isLoading: isLoading,
9954
+ page: page,
9937
9955
  rules: rules,
9956
+ setPage: setPage,
9938
9957
  totalCount: totalCount,
9939
9958
  url: url
9940
- }, rulesTableProps))), allowReordering && !isLoading && /*#__PURE__*/jsx$1(RulesReorder, {
9959
+ }, rulesTableProps)), {}, {
9960
+ isLoading: isLoading || isFetching,
9961
+ onCloneSuccess: cloneRule === null || cloneRule === void 0 || (_cloneRule$onSuccess = cloneRule.onSuccess) === null || _cloneRule$onSuccess === void 0 ? void 0 : _cloneRule$onSuccess.callback,
9962
+ onDeleteSuccess: deleteRule === null || deleteRule === void 0 || (_deleteRule$onSuccess = deleteRule.onSuccess) === null || _deleteRule$onSuccess === void 0 ? void 0 : _deleteRule$onSuccess.callback,
9963
+ onUpdateSuccess: updateRule === null || updateRule === void 0 || (_updateRule$onSuccess = updateRule.onSuccess) === null || _updateRule$onSuccess === void 0 ? void 0 : _updateRule$onSuccess.callback
9964
+ })), allowReordering && !isLoading && /*#__PURE__*/jsx$1(RulesReorder, {
9941
9965
  rules: rules,
9942
9966
  url: url,
9943
9967
  isOpen: isReorderPaneOpen,
9944
9968
  paginationProps: {
9945
9969
  pageNo: page,
9946
- setPage: setPage,
9947
9970
  count: totalCount,
9948
- pageSize: DEFAULT_PAGE_SIZE
9971
+ pageSize: DEFAULT_PAGE_SIZE,
9972
+ navigate: setPage
9949
9973
  },
9950
9974
  onClose: function onClose() {
9951
9975
  return setIsReorderPaneOpen(false);
9952
- }
9976
+ },
9977
+ onReorderSuccess: reorderRules === null || reorderRules === void 0 || (_reorderRules$onSucce = reorderRules.onSuccess) === null || _reorderRules$onSucce === void 0 ? void 0 : _reorderRules$onSucce.callback
9953
9978
  })]
9954
9979
  });
9955
9980
  };
@@ -10609,6 +10634,8 @@ var DropdownField$1 = function DropdownField(_ref) {
10609
10634
  name = _ref.name,
10610
10635
  index = _ref.index,
10611
10636
  selectedField = _ref.selectedField;
10637
+ var _useTranslation = useTranslation(),
10638
+ t = _useTranslation.t;
10612
10639
  var _useFormikContext = useFormikContext(),
10613
10640
  actions = _useFormikContext.values.actions,
10614
10641
  setFieldValue = _useFormikContext.setFieldValue,
@@ -10630,8 +10657,6 @@ var DropdownField$1 = function DropdownField(_ref) {
10630
10657
  _useState6 = _slicedToArray$1(_useState5, 2),
10631
10658
  searchTerm = _useState6[0],
10632
10659
  setSearchTerm = _useState6[1];
10633
- var _useTranslation = useTranslation(),
10634
- t = _useTranslation.t;
10635
10660
  var defaultValue = ((_actions$value$index$ = actions.value[index].metadata) === null || _actions$value$index$ === void 0 ? void 0 : _actions$value$index$.value) || ((_actions$value$index = actions.value[index]) === null || _actions$value$index === void 0 ? void 0 : _actions$value$index.value);
10636
10661
  var searchedOptions = getSearchedOptions$3(dropdownOptions, searchTerm);
10637
10662
  var isValueSelected = defaultSelectedOption.label === defaultLabel && errors.actions && isNotNil((_errors$actions = errors.actions) === null || _errors$actions === void 0 || (_errors$actions = _errors$actions.value) === null || _errors$actions === void 0 ? void 0 : _errors$actions[index]) && isNotNil((_touched$actions = touched.actions) === null || _touched$actions === void 0 || (_touched$actions = _touched$actions.value) === null || _touched$actions === void 0 ? void 0 : _touched$actions[index]);