@bigbinary/neeto-rules-frontend 1.2.0-beta3 → 2.0.1

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, isPresent, removeBy, 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';
@@ -30,8 +30,14 @@ import { t as t$5 } from 'i18next';
30
30
  import { buildUrl, joinHyphenCase, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
31
31
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
32
32
  import Switch from '@bigbinary/neetoui/Switch';
33
+ import Tooltip from '@bigbinary/neetoui/Tooltip';
33
34
  import { useFormikContext, useField, FieldArray, ErrorMessage, Formik, Form as Form$1 } from 'formik';
35
+ import Plus from '@bigbinary/neeto-icons/Plus';
36
+ import Delete from '@bigbinary/neeto-icons/Delete';
37
+ import Refresh from '@bigbinary/neeto-icons/Refresh';
34
38
  import classNames$1 from 'classnames';
39
+ import Check from '@bigbinary/neeto-icons/Check';
40
+ import Search from '@bigbinary/neeto-icons/Search';
35
41
  import Dropdown$1 from '@bigbinary/neetoui/Dropdown';
36
42
  import Input$2 from '@bigbinary/neetoui/Input';
37
43
  import Textarea from '@bigbinary/neetoui/formik/Textarea';
@@ -44,14 +50,18 @@ import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
44
50
  import MultiEmailInput from '@bigbinary/neetoui/formik/MultiEmailInput';
45
51
  import Input$3 from '@bigbinary/neetoui/formik/Input';
46
52
  import useHotkeys from '@bigbinary/neeto-hotkeys';
53
+ import Close from '@bigbinary/neeto-icons/Close';
47
54
  import Checkbox from '@bigbinary/neetoui/Checkbox';
48
55
  import { isPhoneNumberValid } from '@bigbinary/neeto-molecules/PhoneNumber';
49
56
  import Tag from '@bigbinary/neetoui/Tag';
50
57
  import * as yup from 'yup';
51
58
  import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
52
- import Tooltip from '@bigbinary/neetoui/Tooltip';
59
+ import Eye from '@bigbinary/neeto-icons/Eye';
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";
@@ -272,13 +282,14 @@ var Header = function Header(_ref) {
272
282
  helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
273
283
  setIsReorderPaneOpen = _ref.setIsReorderPaneOpen,
274
284
  hasUnfilteredRules = _ref.hasUnfilteredRules,
275
- allowReordering = _ref.allowReordering;
285
+ allowReordering = _ref.allowReordering,
286
+ headerProps = _ref.headerProps;
276
287
  var _useQueryParams = useQueryParams(),
277
288
  _useQueryParams$searc = _useQueryParams.searchTerm,
278
289
  searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
279
290
  var _useTranslation = useTranslation(),
280
291
  t = _useTranslation.t;
281
- return /*#__PURE__*/jsx$1(NeetoHeader, {
292
+ return /*#__PURE__*/jsx$1(NeetoHeader, _objectSpread$s({
282
293
  breadcrumbs: breadcrumbs,
283
294
  actionBlock: /*#__PURE__*/jsxs(Fragment, {
284
295
  children: [hasUnfilteredRules && allowReordering && /*#__PURE__*/jsx$1(Button, {
@@ -309,7 +320,7 @@ var Header = function Header(_ref) {
309
320
  title: t("neetoRules.common.title")
310
321
  }, helpPopoverProps))]
311
322
  })
312
- });
323
+ }, headerProps));
313
324
  };
314
325
  var Header$1 = /*#__PURE__*/React__default.memo(Header);
315
326
 
@@ -9615,8 +9626,9 @@ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
9615
9626
  onDelete = _ref.onDelete,
9616
9627
  _ref$moreDropdownItem = _ref.moreDropdownItems,
9617
9628
  moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem,
9618
- automationRulesPath = _ref.automationRulesPath;
9619
- return [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
9629
+ automationRulesPath = _ref.automationRulesPath,
9630
+ allowCloning = _ref.allowCloning;
9631
+ var defaultOptions = [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
9620
9632
  var _onClick = _ref2.onClick,
9621
9633
  others = _objectWithoutProperties$1(_ref2, _excluded$h);
9622
9634
  return _objectSpread$o(_objectSpread$o({}, others), {}, {
@@ -9639,6 +9651,9 @@ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
9639
9651
  onClick: function onClick() {
9640
9652
  return onClone(rule.id);
9641
9653
  }
9654
+ }, {
9655
+ key: "divider",
9656
+ type: "divider"
9642
9657
  }, {
9643
9658
  key: "delete",
9644
9659
  "data-test-id": "automation-rules-delete-link",
@@ -9647,6 +9662,12 @@ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
9647
9662
  return onDelete(rule);
9648
9663
  }
9649
9664
  }]);
9665
+ if (!allowCloning) {
9666
+ return removeBy({
9667
+ key: "clone"
9668
+ }, defaultOptions);
9669
+ }
9670
+ return defaultOptions;
9650
9671
  };
9651
9672
  var getColumnData = function getColumnData(_ref3) {
9652
9673
  var handleChangeStatus = _ref3.handleChangeStatus,
@@ -9699,10 +9720,17 @@ var getColumnData = function getColumnData(_ref3) {
9699
9720
  key: "description",
9700
9721
  width: 390,
9701
9722
  render: function render(description) {
9702
- return /*#__PURE__*/jsx$1(Typography, {
9703
- className: "whitespace-pre-line break-words",
9723
+ return isPresent(description) ? /*#__PURE__*/jsx$1(Tooltip, {
9724
+ content: description,
9725
+ position: "bottom",
9726
+ children: /*#__PURE__*/jsx$1(Typography, {
9727
+ className: "line-clamp-2 whitespace-pre-line",
9728
+ style: "body2",
9729
+ children: description
9730
+ })
9731
+ }) : /*#__PURE__*/jsx$1(Typography, {
9704
9732
  style: "body2",
9705
- children: description
9733
+ children: "-"
9706
9734
  });
9707
9735
  }
9708
9736
  }, {
@@ -9759,7 +9787,9 @@ var RulesTable = function RulesTable(_ref) {
9759
9787
  onCloneSuccess = _ref.onCloneSuccess,
9760
9788
  onUpdateSuccess = _ref.onUpdateSuccess,
9761
9789
  page = _ref.page,
9762
- setPage = _ref.setPage;
9790
+ setPage = _ref.setPage,
9791
+ _ref$allowCloning = _ref.allowCloning,
9792
+ allowCloning = _ref$allowCloning === void 0 ? true : _ref$allowCloning;
9763
9793
  var _useQueryParams = useQueryParams(),
9764
9794
  _useQueryParams$searc = _useQueryParams.searchTerm,
9765
9795
  searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
@@ -9824,7 +9854,8 @@ var RulesTable = function RulesTable(_ref) {
9824
9854
  onDelete: setSelectedRule,
9825
9855
  onPreview: onPreview,
9826
9856
  automationRulesPath: automationRulesPath,
9827
- moreDropdownItems: moreDropdownItems
9857
+ moreDropdownItems: moreDropdownItems,
9858
+ allowCloning: allowCloning
9828
9859
  });
9829
9860
  if (isLoading && isEmpty(rules)) {
9830
9861
  return /*#__PURE__*/jsx$1(PageLoader, {});
@@ -9903,7 +9934,7 @@ var RulesTable = function RulesTable(_ref) {
9903
9934
  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; }
9904
9935
  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; }
9905
9936
  var NeetoRules = function NeetoRules(_ref) {
9906
- var _helpPopoverProps$hel, _cloneRule$onSuccess, _deleteRule$onSuccess, _updateRule$onSuccess, _reorderRules$onSucce;
9937
+ var _helpPopoverProps$hel, _cloneRule$allowed, _cloneRule$onSuccess, _deleteRule$onSuccess, _updateRule$onSuccess, _reorderRules$onSucce;
9907
9938
  var breadcrumbs = _ref.breadcrumbs,
9908
9939
  automationRulesPath = _ref.automationRulesPath,
9909
9940
  url = _ref.automationRulesEndpoint,
@@ -9916,7 +9947,9 @@ var NeetoRules = function NeetoRules(_ref) {
9916
9947
  deleteRule = _ref.deleteRule,
9917
9948
  cloneRule = _ref.cloneRule,
9918
9949
  updateRule = _ref.updateRule,
9919
- reorderRules = _ref.reorderRules;
9950
+ reorderRules = _ref.reorderRules,
9951
+ _ref$headerProps = _ref.headerProps,
9952
+ headerProps = _ref$headerProps === void 0 ? {} : _ref$headerProps;
9920
9953
  var _useState = useState(false),
9921
9954
  _useState2 = _slicedToArray$1(_useState, 2),
9922
9955
  isReorderPaneOpen = _useState2[0],
@@ -9950,6 +9983,7 @@ var NeetoRules = function NeetoRules(_ref) {
9950
9983
  automationRulesPath: automationRulesPath,
9951
9984
  breadcrumbs: breadcrumbs,
9952
9985
  hasUnfilteredRules: hasUnfilteredRules,
9986
+ headerProps: headerProps,
9953
9987
  helpPopoverProps: helpPopoverProps,
9954
9988
  setIsReorderPaneOpen: setIsReorderPaneOpen
9955
9989
  }), /*#__PURE__*/jsx$1(RulesTable, _objectSpread$m(_objectSpread$m({}, _objectSpread$m({
@@ -9961,6 +9995,7 @@ var NeetoRules = function NeetoRules(_ref) {
9961
9995
  totalCount: totalCount,
9962
9996
  url: url
9963
9997
  }, rulesTableProps)), {}, {
9998
+ allowCloning: (_cloneRule$allowed = cloneRule === null || cloneRule === void 0 ? void 0 : cloneRule.allowed) !== null && _cloneRule$allowed !== void 0 ? _cloneRule$allowed : true,
9964
9999
  isLoading: isLoading || isFetching,
9965
10000
  onCloneSuccess: cloneRule === null || cloneRule === void 0 || (_cloneRule$onSuccess = cloneRule.onSuccess) === null || _cloneRule$onSuccess === void 0 ? void 0 : _cloneRule$onSuccess.callback,
9966
10001
  onDeleteSuccess: deleteRule === null || deleteRule === void 0 || (_deleteRule$onSuccess = deleteRule.onSuccess) === null || _deleteRule$onSuccess === void 0 ? void 0 : _deleteRule$onSuccess.callback,