@bigbinary/neeto-rules-frontend 1.2.0-beta2 → 2.0.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
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, createElement, useMemo as useMemo$1, forwardRef, createContext, useCallback as useCallback$1, Component, Fragment as Fragment$1, memo } from 'react';
3
- import { isNotEmpty, isPresent, renameKeys, findBy, noop as noop$4, nullSafe, toLabelAndValue, removeBy } from '@bigbinary/neeto-cist';
3
+ import { isNotEmpty, removeBy, isPresent, renameKeys, findBy, noop as noop$4, nullSafe, toLabelAndValue } from '@bigbinary/neeto-cist';
4
4
  import { DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/constants';
5
5
  import { useMutationWithInvalidation, useQueryParams, withImmutableActions, withT, useStateWithDependency, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import Container from '@bigbinary/neeto-molecules/Container';
@@ -12,7 +12,7 @@ import Button from '@bigbinary/neetoui/Button';
12
12
  import { useTranslation, Trans } from 'react-i18next';
13
13
  import { jsx as jsx$1, jsxs, Fragment } from 'react/jsx-runtime';
14
14
  import ReactDOM, { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
15
- import { Reorder, Delete, Check, Search, Close, Plus, Refresh, Eye, Help, Down, Up } from '@bigbinary/neeto-icons';
15
+ import Reorder from '@bigbinary/neeto-icons/Reorder';
16
16
  import Pane from '@bigbinary/neetoui/Pane';
17
17
  import Typography from '@bigbinary/neetoui/Typography';
18
18
  import Pagination from '@bigbinary/neetoui/Pagination';
@@ -31,7 +31,12 @@ import { buildUrl, joinHyphenCase, hyphenize } from '@bigbinary/neeto-commons-fr
31
31
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
32
32
  import Switch from '@bigbinary/neetoui/Switch';
33
33
  import { useFormikContext, useField, FieldArray, ErrorMessage, Formik, Form as Form$1 } from 'formik';
34
+ import Plus from '@bigbinary/neeto-icons/Plus';
35
+ import Delete from '@bigbinary/neeto-icons/Delete';
36
+ import Refresh from '@bigbinary/neeto-icons/Refresh';
34
37
  import classNames$1 from 'classnames';
38
+ import Check from '@bigbinary/neeto-icons/Check';
39
+ import Search from '@bigbinary/neeto-icons/Search';
35
40
  import Dropdown$1 from '@bigbinary/neetoui/Dropdown';
36
41
  import Input$2 from '@bigbinary/neetoui/Input';
37
42
  import Textarea from '@bigbinary/neetoui/formik/Textarea';
@@ -44,14 +49,19 @@ import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
44
49
  import MultiEmailInput from '@bigbinary/neetoui/formik/MultiEmailInput';
45
50
  import Input$3 from '@bigbinary/neetoui/formik/Input';
46
51
  import useHotkeys from '@bigbinary/neeto-hotkeys';
52
+ import Close from '@bigbinary/neeto-icons/Close';
47
53
  import Checkbox from '@bigbinary/neetoui/Checkbox';
48
54
  import { isPhoneNumberValid } from '@bigbinary/neeto-molecules/PhoneNumber';
49
55
  import Tag from '@bigbinary/neetoui/Tag';
50
56
  import * as yup from 'yup';
51
57
  import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
58
+ import Eye from '@bigbinary/neeto-icons/Eye';
52
59
  import Tooltip from '@bigbinary/neetoui/Tooltip';
53
60
  import Select$2 from '@bigbinary/neetoui/formik/Select';
54
61
  import Radio from '@bigbinary/neetoui/formik/Radio';
62
+ import Help from '@bigbinary/neeto-icons/Help';
63
+ import Down from '@bigbinary/neeto-icons/Down';
64
+ import Up from '@bigbinary/neeto-icons/Up';
55
65
 
56
66
  function _typeof$3(o) {
57
67
  "@babel/helpers - typeof";
@@ -9615,8 +9625,9 @@ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
9615
9625
  onDelete = _ref.onDelete,
9616
9626
  _ref$moreDropdownItem = _ref.moreDropdownItems,
9617
9627
  moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem,
9618
- automationRulesPath = _ref.automationRulesPath;
9619
- return [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
9628
+ automationRulesPath = _ref.automationRulesPath,
9629
+ allowCloning = _ref.allowCloning;
9630
+ var defaultOptions = [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
9620
9631
  var _onClick = _ref2.onClick,
9621
9632
  others = _objectWithoutProperties$1(_ref2, _excluded$h);
9622
9633
  return _objectSpread$o(_objectSpread$o({}, others), {}, {
@@ -9647,6 +9658,12 @@ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
9647
9658
  return onDelete(rule);
9648
9659
  }
9649
9660
  }]);
9661
+ if (!allowCloning) {
9662
+ return removeBy({
9663
+ key: "clone"
9664
+ }, defaultOptions);
9665
+ }
9666
+ return defaultOptions;
9650
9667
  };
9651
9668
  var getColumnData = function getColumnData(_ref3) {
9652
9669
  var handleChangeStatus = _ref3.handleChangeStatus,
@@ -9759,7 +9776,9 @@ var RulesTable = function RulesTable(_ref) {
9759
9776
  onCloneSuccess = _ref.onCloneSuccess,
9760
9777
  onUpdateSuccess = _ref.onUpdateSuccess,
9761
9778
  page = _ref.page,
9762
- setPage = _ref.setPage;
9779
+ setPage = _ref.setPage,
9780
+ _ref$allowCloning = _ref.allowCloning,
9781
+ allowCloning = _ref$allowCloning === void 0 ? true : _ref$allowCloning;
9763
9782
  var _useQueryParams = useQueryParams(),
9764
9783
  _useQueryParams$searc = _useQueryParams.searchTerm,
9765
9784
  searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
@@ -9796,15 +9815,17 @@ var RulesTable = function RulesTable(_ref) {
9796
9815
  url: url,
9797
9816
  payload: payload
9798
9817
  }, {
9799
- onSuccess: onUpdateSuccess
9818
+ onSuccess: function onSuccess() {
9819
+ return onUpdateSuccess === null || onUpdateSuccess === void 0 ? void 0 : onUpdateSuccess();
9820
+ }
9800
9821
  });
9801
9822
  };
9802
9823
  var handleCloneSuccess = function handleCloneSuccess() {
9803
- onCloneSuccess();
9824
+ onCloneSuccess === null || onCloneSuccess === void 0 || onCloneSuccess();
9804
9825
  hidePreviewPane();
9805
9826
  };
9806
9827
  var handleDeleteSuccess = function handleDeleteSuccess() {
9807
- onDeleteSuccess();
9828
+ onDeleteSuccess === null || onDeleteSuccess === void 0 || onDeleteSuccess();
9808
9829
  hidePreviewPane();
9809
9830
  setSelectedRule(null);
9810
9831
  };
@@ -9822,7 +9843,8 @@ var RulesTable = function RulesTable(_ref) {
9822
9843
  onDelete: setSelectedRule,
9823
9844
  onPreview: onPreview,
9824
9845
  automationRulesPath: automationRulesPath,
9825
- moreDropdownItems: moreDropdownItems
9846
+ moreDropdownItems: moreDropdownItems,
9847
+ allowCloning: allowCloning
9826
9848
  });
9827
9849
  if (isLoading && isEmpty(rules)) {
9828
9850
  return /*#__PURE__*/jsx$1(PageLoader, {});
@@ -9901,7 +9923,7 @@ var RulesTable = function RulesTable(_ref) {
9901
9923
  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; }
9902
9924
  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; }
9903
9925
  var NeetoRules = function NeetoRules(_ref) {
9904
- var _helpPopoverProps$hel, _cloneRule$onSuccess, _deleteRule$onSuccess, _updateRule$onSuccess, _reorderRules$onSucce;
9926
+ var _helpPopoverProps$hel, _cloneRule$allowed, _cloneRule$onSuccess, _deleteRule$onSuccess, _updateRule$onSuccess, _reorderRules$onSucce;
9905
9927
  var breadcrumbs = _ref.breadcrumbs,
9906
9928
  automationRulesPath = _ref.automationRulesPath,
9907
9929
  url = _ref.automationRulesEndpoint,
@@ -9959,6 +9981,7 @@ var NeetoRules = function NeetoRules(_ref) {
9959
9981
  totalCount: totalCount,
9960
9982
  url: url
9961
9983
  }, rulesTableProps)), {}, {
9984
+ allowCloning: (_cloneRule$allowed = cloneRule === null || cloneRule === void 0 ? void 0 : cloneRule.allowed) !== null && _cloneRule$allowed !== void 0 ? _cloneRule$allowed : true,
9962
9985
  isLoading: isLoading || isFetching,
9963
9986
  onCloneSuccess: cloneRule === null || cloneRule === void 0 || (_cloneRule$onSuccess = cloneRule.onSuccess) === null || _cloneRule$onSuccess === void 0 ? void 0 : _cloneRule$onSuccess.callback,
9964
9987
  onDeleteSuccess: deleteRule === null || deleteRule === void 0 || (_deleteRule$onSuccess = deleteRule.onSuccess) === null || _deleteRule$onSuccess === void 0 ? void 0 : _deleteRule$onSuccess.callback,