@bigbinary/neeto-rules-frontend 0.7.4 → 0.8.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/README.md +61 -0
- package/app/javascript/src/translations/en.json +17 -0
- package/dist/index.cjs.js +449 -62
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +439 -61
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -16,17 +16,26 @@ var ramda = require('ramda');
|
|
|
16
16
|
var reactI18next = require('react-i18next');
|
|
17
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
18
18
|
var i18next = require('i18next');
|
|
19
|
+
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
20
|
+
var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
|
|
21
|
+
var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
|
|
22
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
23
|
+
var NoData = require('@bigbinary/neetoui/NoData');
|
|
24
|
+
var Table = require('@bigbinary/neetoui/Table');
|
|
25
|
+
var reactQuery = require('react-query');
|
|
26
|
+
var axios = require('axios');
|
|
27
|
+
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
28
|
+
var Switch = require('@bigbinary/neetoui/Switch');
|
|
29
|
+
var reactRouterDom = require('react-router-dom');
|
|
19
30
|
var ReactDOM = require('react-dom');
|
|
20
31
|
var Pagination = require('@bigbinary/neetoui/Pagination');
|
|
21
|
-
var reactRouterDom = require('react-router-dom');
|
|
22
32
|
var shallow = require('zustand/shallow');
|
|
23
33
|
var classNames$1 = require('classnames');
|
|
24
34
|
var formik = require('formik');
|
|
25
35
|
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
26
36
|
var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
|
|
27
37
|
var yup = require('yup');
|
|
28
|
-
var
|
|
29
|
-
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
38
|
+
var utils$1 = require('@bigbinary/neeto-editor/utils');
|
|
30
39
|
var Dropdown$1 = require('@bigbinary/neetoui/Dropdown');
|
|
31
40
|
var Input$2 = require('@bigbinary/neetoui/Input');
|
|
32
41
|
var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
@@ -34,6 +43,7 @@ var Label = require('@bigbinary/neetoui/Label');
|
|
|
34
43
|
var Select$1 = require('@bigbinary/neetoui/Select');
|
|
35
44
|
var dayjs = require('dayjs');
|
|
36
45
|
var DatePicker = require('@bigbinary/neetoui/DatePicker');
|
|
46
|
+
var FormikEditor = require('@bigbinary/neeto-editor/FormikEditor');
|
|
37
47
|
var MultiEmailInput = require('@bigbinary/neetoui/formik/MultiEmailInput');
|
|
38
48
|
var Input$3 = require('@bigbinary/neetoui/formik/Input');
|
|
39
49
|
var useHotkeys = require('@bigbinary/neeto-hotkeys');
|
|
@@ -70,6 +80,13 @@ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
|
70
80
|
var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
|
|
71
81
|
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
72
82
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
83
|
+
var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
|
|
84
|
+
var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
|
|
85
|
+
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
86
|
+
var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
|
|
87
|
+
var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
|
|
88
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
89
|
+
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
73
90
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
74
91
|
var Pagination__default = /*#__PURE__*/_interopDefaultLegacy(Pagination);
|
|
75
92
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames$1);
|
|
@@ -82,6 +99,7 @@ var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
|
|
|
82
99
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select$1);
|
|
83
100
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
84
101
|
var DatePicker__default = /*#__PURE__*/_interopDefaultLegacy(DatePicker);
|
|
102
|
+
var FormikEditor__default = /*#__PURE__*/_interopDefaultLegacy(FormikEditor);
|
|
85
103
|
var MultiEmailInput__default = /*#__PURE__*/_interopDefaultLegacy(MultiEmailInput);
|
|
86
104
|
var Input__default$1 = /*#__PURE__*/_interopDefaultLegacy(Input$3);
|
|
87
105
|
var useHotkeys__default = /*#__PURE__*/_interopDefaultLegacy(useHotkeys);
|
|
@@ -449,8 +467,8 @@ var CONDITION_VALUE_TYPES = {
|
|
|
449
467
|
var INPUT_FIELD_TYPES = ["email", "text", "number", "decimal", "url", "regex"];
|
|
450
468
|
var MAXIMUM_OPTION_LENGTH$3 = 7;
|
|
451
469
|
|
|
452
|
-
function ownKeys$
|
|
453
|
-
function _objectSpread$
|
|
470
|
+
function ownKeys$u(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; }
|
|
471
|
+
function _objectSpread$s(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$u(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$u(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
454
472
|
var ConditionsDetail = function ConditionsDetail(_ref) {
|
|
455
473
|
var conditions = _ref.conditions,
|
|
456
474
|
conditionOptions = _ref.conditionOptions,
|
|
@@ -466,7 +484,7 @@ var ConditionsDetail = function ConditionsDetail(_ref) {
|
|
|
466
484
|
t = _useTranslation.t;
|
|
467
485
|
var conditionsList = conditions.value;
|
|
468
486
|
var allConditions = viewMore && conditionsList.length > PREVIEW_CONDITION_LIMIT ? conditionsList : conditionsList.slice(0, PREVIEW_CONDITION_LIMIT);
|
|
469
|
-
var allConditionVerbs = _objectSpread$
|
|
487
|
+
var allConditionVerbs = _objectSpread$s(_objectSpread$s({}, VERB_LABELS), conditionVerbs);
|
|
470
488
|
var getLogicOperator = function getLogicOperator(joinType) {
|
|
471
489
|
return joinType === "or_operator" ? "or" : "and";
|
|
472
490
|
};
|
|
@@ -622,8 +640,8 @@ var EventsDetail = function EventsDetail(_ref) {
|
|
|
622
640
|
});
|
|
623
641
|
};
|
|
624
642
|
|
|
625
|
-
function ownKeys$
|
|
626
|
-
function _objectSpread$
|
|
643
|
+
function ownKeys$t(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; }
|
|
644
|
+
function _objectSpread$r(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$t(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$t(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
627
645
|
var RulePreview = reactUtils.withT(function (_ref) {
|
|
628
646
|
var t = _ref.t,
|
|
629
647
|
isLoading = _ref.isLoading,
|
|
@@ -644,7 +662,7 @@ var RulePreview = reactUtils.withT(function (_ref) {
|
|
|
644
662
|
style: "h4",
|
|
645
663
|
weight: "semibold",
|
|
646
664
|
children: ruleDetails.name.value
|
|
647
|
-
}), neetoCist.isNotEmpty(moreDropdownProps) && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], _objectSpread$
|
|
665
|
+
}), neetoCist.isNotEmpty(moreDropdownProps) && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], _objectSpread$r({}, moreDropdownProps))]
|
|
648
666
|
})
|
|
649
667
|
}), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
|
|
650
668
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -690,6 +708,419 @@ var RulePreview = reactUtils.withT(function (_ref) {
|
|
|
690
708
|
});
|
|
691
709
|
});
|
|
692
710
|
|
|
711
|
+
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
712
|
+
if (source == null) return {};
|
|
713
|
+
var target = {};
|
|
714
|
+
var sourceKeys = Object.keys(source);
|
|
715
|
+
var key, i;
|
|
716
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
717
|
+
key = sourceKeys[i];
|
|
718
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
719
|
+
target[key] = source[key];
|
|
720
|
+
}
|
|
721
|
+
return target;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function _objectWithoutProperties$1(source, excluded) {
|
|
725
|
+
if (source == null) return {};
|
|
726
|
+
var target = _objectWithoutPropertiesLoose$2(source, excluded);
|
|
727
|
+
var key, i;
|
|
728
|
+
if (Object.getOwnPropertySymbols) {
|
|
729
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
730
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
731
|
+
key = sourceSymbolKeys[i];
|
|
732
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
733
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
734
|
+
target[key] = source[key];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return target;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
var _excluded$k = ["url"];
|
|
741
|
+
var fetch = function fetch(_ref) {
|
|
742
|
+
var url = _ref.url,
|
|
743
|
+
params = _objectWithoutProperties$1(_ref, _excluded$k);
|
|
744
|
+
return axios__default["default"].get(url, {
|
|
745
|
+
params: params
|
|
746
|
+
});
|
|
747
|
+
};
|
|
748
|
+
var update$1 = function update(_ref2) {
|
|
749
|
+
var url = _ref2.url,
|
|
750
|
+
id = _ref2.id,
|
|
751
|
+
payload = _ref2.payload;
|
|
752
|
+
return axios__default["default"].patch("".concat(url, "/").concat(id), payload);
|
|
753
|
+
};
|
|
754
|
+
var clone = function clone(_ref3) {
|
|
755
|
+
var url = _ref3.url,
|
|
756
|
+
id = _ref3.id;
|
|
757
|
+
return axios__default["default"].post("".concat(url, "/").concat(id, "/clone"));
|
|
758
|
+
};
|
|
759
|
+
var destroy = function destroy(_ref4) {
|
|
760
|
+
var url = _ref4.url,
|
|
761
|
+
id = _ref4.id;
|
|
762
|
+
return axios__default["default"]["delete"]("".concat(url, "/").concat(id));
|
|
763
|
+
};
|
|
764
|
+
var automationRulesApi = {
|
|
765
|
+
fetch: fetch,
|
|
766
|
+
update: update$1,
|
|
767
|
+
clone: clone,
|
|
768
|
+
destroy: destroy
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
//TODO: Remove if not used
|
|
772
|
+
var AUTOMATION_RULES = "automation-rules";
|
|
773
|
+
var STALE_TIME = 3200000;
|
|
774
|
+
|
|
775
|
+
function ownKeys$s(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; }
|
|
776
|
+
function _objectSpread$q(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$s(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$s(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
777
|
+
var useFetchAutomationRules = function useFetchAutomationRules(params) {
|
|
778
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
779
|
+
return reactQuery.useQuery([AUTOMATION_RULES, params], function () {
|
|
780
|
+
return automationRulesApi.fetch(params);
|
|
781
|
+
}, _objectSpread$q({
|
|
782
|
+
staleTime: STALE_TIME,
|
|
783
|
+
select: function select(response) {
|
|
784
|
+
return response.data || response;
|
|
785
|
+
},
|
|
786
|
+
keepPreviousData: true
|
|
787
|
+
}, options));
|
|
788
|
+
};
|
|
789
|
+
var useUpdateAutomationRule = function useUpdateAutomationRule() {
|
|
790
|
+
return reactUtils.useMutationWithInvalidation(automationRulesApi.update, {
|
|
791
|
+
keysToInvalidate: [AUTOMATION_RULES]
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
var useCloneAutomationRule = function useCloneAutomationRule() {
|
|
795
|
+
return reactUtils.useMutationWithInvalidation(automationRulesApi.clone, {
|
|
796
|
+
keysToInvalidate: [AUTOMATION_RULES]
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
var useDeleteAutomationRule = function useDeleteAutomationRule() {
|
|
800
|
+
return reactUtils.useMutationWithInvalidation(automationRulesApi.destroy, {
|
|
801
|
+
keysToInvalidate: [AUTOMATION_RULES]
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
var createRoutes = function createRoutes(basePath) {
|
|
806
|
+
return {
|
|
807
|
+
index: basePath,
|
|
808
|
+
"new": "".concat(basePath, "/new"),
|
|
809
|
+
edit: "".concat(basePath, "/:ruleId/edit")
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
var STATUS_KEYS = {
|
|
814
|
+
ENABLED: "enabled",
|
|
815
|
+
DISABLED: "disabled"
|
|
816
|
+
};
|
|
817
|
+
var DEFAULT_INIT_PAGE = 1;
|
|
818
|
+
|
|
819
|
+
function _arrayWithoutHoles$1(arr) {
|
|
820
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
function _iterableToArray$1(iter) {
|
|
824
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function _nonIterableSpread$1() {
|
|
828
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function _toConsumableArray$1(arr) {
|
|
832
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
var DisableMessage = reactUtils.withT(function (_ref) {
|
|
836
|
+
var t = _ref.t,
|
|
837
|
+
disabledReason = _ref.disabledReason;
|
|
838
|
+
return ramda.isNotNil(disabledReason) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
839
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
840
|
+
"class": "text-red-600",
|
|
841
|
+
component: "span",
|
|
842
|
+
style: "body2",
|
|
843
|
+
children: t(disabledReason)
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
var _excluded$j = ["onClick"],
|
|
849
|
+
_excluded2 = ["handleChangeStatus", "additionalColumns", "onPreview"];
|
|
850
|
+
function ownKeys$r(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; }
|
|
851
|
+
function _objectSpread$p(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$r(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$r(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
852
|
+
var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
|
|
853
|
+
var rule = _ref.rule,
|
|
854
|
+
onClone = _ref.onClone,
|
|
855
|
+
onDelete = _ref.onDelete,
|
|
856
|
+
_ref$moreDropdownItem = _ref.moreDropdownItems,
|
|
857
|
+
moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem,
|
|
858
|
+
automationRulesPath = _ref.automationRulesPath;
|
|
859
|
+
return [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
|
|
860
|
+
var _onClick = _ref2.onClick,
|
|
861
|
+
others = _objectWithoutProperties$1(_ref2, _excluded$j);
|
|
862
|
+
return _objectSpread$p(_objectSpread$p({}, others), {}, {
|
|
863
|
+
onClick: function onClick() {
|
|
864
|
+
return _onClick(rule);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
})), [{
|
|
868
|
+
key: "edit",
|
|
869
|
+
className: "neeto-ui-btn",
|
|
870
|
+
"data-test-id": "automation-rules-edit-link",
|
|
871
|
+
label: i18next.t("neetoRules.button.edit"),
|
|
872
|
+
to: utils.buildUrl(createRoutes(automationRulesPath).edit, {
|
|
873
|
+
ruleId: rule.id
|
|
874
|
+
})
|
|
875
|
+
}, {
|
|
876
|
+
key: "clone",
|
|
877
|
+
"data-test-id": "automation-rules-clone-link",
|
|
878
|
+
label: i18next.t("neetoRules.button.clone"),
|
|
879
|
+
onClick: function onClick() {
|
|
880
|
+
return onClone(rule.id);
|
|
881
|
+
}
|
|
882
|
+
}, {
|
|
883
|
+
key: "delete",
|
|
884
|
+
"data-test-id": "automation-rules-delete-link",
|
|
885
|
+
label: i18next.t("neetoRules.button.delete"),
|
|
886
|
+
onClick: function onClick() {
|
|
887
|
+
return onDelete(rule);
|
|
888
|
+
}
|
|
889
|
+
}]);
|
|
890
|
+
};
|
|
891
|
+
var getColumnData = function getColumnData(_ref3) {
|
|
892
|
+
var handleChangeStatus = _ref3.handleChangeStatus,
|
|
893
|
+
_ref3$additionalColum = _ref3.additionalColumns,
|
|
894
|
+
additionalColumns = _ref3$additionalColum === void 0 ? [] : _ref3$additionalColum,
|
|
895
|
+
onPreview = _ref3.onPreview,
|
|
896
|
+
otherProps = _objectWithoutProperties$1(_ref3, _excluded2);
|
|
897
|
+
return [{
|
|
898
|
+
title: i18next.t("neetoRules.labels.name"),
|
|
899
|
+
dataIndex: "name",
|
|
900
|
+
key: "name",
|
|
901
|
+
ellipsis: true,
|
|
902
|
+
width: 440,
|
|
903
|
+
render: function render(name, rule) {
|
|
904
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
905
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
906
|
+
className: "flex items-center justify-between gap-x-3",
|
|
907
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
908
|
+
className: "whitespace-pre-line break-words text-left",
|
|
909
|
+
style: "link",
|
|
910
|
+
onClick: function onClick() {
|
|
911
|
+
return onPreview(rule.id);
|
|
912
|
+
},
|
|
913
|
+
children: name
|
|
914
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
|
|
915
|
+
dropdownProps: {
|
|
916
|
+
strategy: "fixed"
|
|
917
|
+
},
|
|
918
|
+
menuItems: buildActionDropdownMenuItems(_objectSpread$p({
|
|
919
|
+
rule: rule
|
|
920
|
+
}, otherProps))
|
|
921
|
+
})]
|
|
922
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DisableMessage, {
|
|
923
|
+
disabledReason: rule.disabledReason
|
|
924
|
+
})]
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
}, {
|
|
928
|
+
title: i18next.t("neetoRules.labels.description"),
|
|
929
|
+
dataIndex: "description",
|
|
930
|
+
key: "description",
|
|
931
|
+
width: 390,
|
|
932
|
+
render: function render(description) {
|
|
933
|
+
return /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
934
|
+
className: "whitespace-pre-line break-words",
|
|
935
|
+
style: "body2",
|
|
936
|
+
children: description
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
}, {
|
|
940
|
+
title: i18next.t("neetoRules.labels.active"),
|
|
941
|
+
key: "active",
|
|
942
|
+
width: 100,
|
|
943
|
+
align: "center",
|
|
944
|
+
render: function render(_, rule) {
|
|
945
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
946
|
+
className: "flex justify-center",
|
|
947
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Switch__default["default"], {
|
|
948
|
+
checked: rule.status === STATUS_KEYS.ENABLED,
|
|
949
|
+
"data-test-id": "automation-rules-state-switch-row",
|
|
950
|
+
disabled: !!rule.disabledReason,
|
|
951
|
+
onChange: function onChange(e) {
|
|
952
|
+
handleChangeStatus(e, rule.id);
|
|
953
|
+
}
|
|
954
|
+
})
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}].concat(_toConsumableArray$1(additionalColumns));
|
|
958
|
+
};
|
|
959
|
+
var renderNoDataHelpText = function renderNoDataHelpText(helpDocUrl) {
|
|
960
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
961
|
+
i18nKey: "neetoRules.noData.helpText",
|
|
962
|
+
components: {
|
|
963
|
+
a: /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Link, {
|
|
964
|
+
className: "neeto-ui-text-primary-600 underline",
|
|
965
|
+
target: "_blank",
|
|
966
|
+
to: {
|
|
967
|
+
pathname: helpDocUrl
|
|
968
|
+
}
|
|
969
|
+
})
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
function ownKeys$q(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; }
|
|
975
|
+
function _objectSpread$o(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$q(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$q(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
976
|
+
var RulesTable = function RulesTable(_ref) {
|
|
977
|
+
var url = _ref.automationRulesEndpoint,
|
|
978
|
+
additionalColumns = _ref.additionalColumns,
|
|
979
|
+
_ref$automationRulesP = _ref.automationRulesPath,
|
|
980
|
+
automationRulesPath = _ref$automationRulesP === void 0 ? "/" : _ref$automationRulesP,
|
|
981
|
+
onPreview = _ref.onPreview,
|
|
982
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
983
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
|
|
984
|
+
_ref$moreDropdownItem = _ref.moreDropdownItems,
|
|
985
|
+
moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem;
|
|
986
|
+
var _useState = React.useState(null),
|
|
987
|
+
_useState2 = _slicedToArray$1(_useState, 2),
|
|
988
|
+
selectedRule = _useState2[0],
|
|
989
|
+
setSelectedRule = _useState2[1];
|
|
990
|
+
var _useState3 = React.useState(DEFAULT_INIT_PAGE),
|
|
991
|
+
_useState4 = _slicedToArray$1(_useState3, 2),
|
|
992
|
+
page = _useState4[0],
|
|
993
|
+
setPage = _useState4[1];
|
|
994
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
995
|
+
t = _useTranslation.t;
|
|
996
|
+
var _useQueryParams = reactUtils.useQueryParams(),
|
|
997
|
+
_useQueryParams$searc = _useQueryParams.searchTerm,
|
|
998
|
+
searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
|
|
999
|
+
var _useFetchAutomationRu = useFetchAutomationRules({
|
|
1000
|
+
url: url,
|
|
1001
|
+
page: page,
|
|
1002
|
+
pageSize: constants.DEFAULT_PAGE_SIZE,
|
|
1003
|
+
searchTerm: searchTerm
|
|
1004
|
+
}),
|
|
1005
|
+
_useFetchAutomationRu2 = _useFetchAutomationRu.data,
|
|
1006
|
+
_useFetchAutomationRu3 = _useFetchAutomationRu2 === void 0 ? {} : _useFetchAutomationRu2,
|
|
1007
|
+
_useFetchAutomationRu4 = _useFetchAutomationRu3.rules,
|
|
1008
|
+
rules = _useFetchAutomationRu4 === void 0 ? [] : _useFetchAutomationRu4,
|
|
1009
|
+
_useFetchAutomationRu5 = _useFetchAutomationRu3.totalCount,
|
|
1010
|
+
totalCount = _useFetchAutomationRu5 === void 0 ? 0 : _useFetchAutomationRu5,
|
|
1011
|
+
isLoading = _useFetchAutomationRu.isLoading;
|
|
1012
|
+
var _useUpdateAutomationR = useUpdateAutomationRule(),
|
|
1013
|
+
updateRule = _useUpdateAutomationR.mutate,
|
|
1014
|
+
isUpdating = _useUpdateAutomationR.isLoading;
|
|
1015
|
+
var _useCloneAutomationRu = useCloneAutomationRule(),
|
|
1016
|
+
cloneRule = _useCloneAutomationRu.mutate,
|
|
1017
|
+
isCloning = _useCloneAutomationRu.isLoading;
|
|
1018
|
+
var _useDeleteAutomationR = useDeleteAutomationRule(),
|
|
1019
|
+
deleteRule = _useDeleteAutomationR.mutate,
|
|
1020
|
+
isDeleting = _useDeleteAutomationR.isLoading;
|
|
1021
|
+
var handleChangeStatus = function handleChangeStatus(event, id) {
|
|
1022
|
+
var status = event.target.checked ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED;
|
|
1023
|
+
var payload = {
|
|
1024
|
+
rule: {
|
|
1025
|
+
status: status
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
updateRule({
|
|
1029
|
+
id: id,
|
|
1030
|
+
url: url,
|
|
1031
|
+
payload: payload
|
|
1032
|
+
});
|
|
1033
|
+
};
|
|
1034
|
+
var columnData = getColumnData({
|
|
1035
|
+
handleChangeStatus: handleChangeStatus,
|
|
1036
|
+
additionalColumns: additionalColumns,
|
|
1037
|
+
onClone: function onClone(id) {
|
|
1038
|
+
return cloneRule({
|
|
1039
|
+
id: id,
|
|
1040
|
+
url: url
|
|
1041
|
+
});
|
|
1042
|
+
},
|
|
1043
|
+
onDelete: setSelectedRule,
|
|
1044
|
+
onPreview: onPreview,
|
|
1045
|
+
automationRulesPath: automationRulesPath,
|
|
1046
|
+
moreDropdownItems: moreDropdownItems
|
|
1047
|
+
});
|
|
1048
|
+
if (isLoading) {
|
|
1049
|
+
return /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {});
|
|
1050
|
+
}
|
|
1051
|
+
if (ramda.isEmpty(rules)) {
|
|
1052
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1053
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1054
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$o({
|
|
1055
|
+
title: t("neetoRules.noData.title")
|
|
1056
|
+
}, ramda.isEmpty(searchTerm) && {
|
|
1057
|
+
helpText: helpDocUrl ? renderNoDataHelpText(helpDocUrl) : null,
|
|
1058
|
+
primaryButtonProps: {
|
|
1059
|
+
label: t("neetoRules.button.addNew"),
|
|
1060
|
+
to: createRoutes(automationRulesPath)["new"]
|
|
1061
|
+
}
|
|
1062
|
+
}))
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1066
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"], {
|
|
1067
|
+
leftActionBlock: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1068
|
+
className: "mr-4 font-semibold",
|
|
1069
|
+
style: "h4",
|
|
1070
|
+
children: t("neetoRules.common.automationRuleWithCount", {
|
|
1071
|
+
count: totalCount
|
|
1072
|
+
})
|
|
1073
|
+
})
|
|
1074
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
1075
|
+
hasPagination: totalCount > constants.DEFAULT_PAGE_SIZE,
|
|
1076
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
1077
|
+
columnData: columnData,
|
|
1078
|
+
totalCount: totalCount,
|
|
1079
|
+
fixedHeight: true,
|
|
1080
|
+
allowClick: false,
|
|
1081
|
+
currentPageNumber: page,
|
|
1082
|
+
defaultPageSize: constants.DEFAULT_PAGE_SIZE,
|
|
1083
|
+
handlePageChange: setPage,
|
|
1084
|
+
loading: isUpdating || isLoading || isCloning || isDeleting,
|
|
1085
|
+
rowData: rules.map(function (item) {
|
|
1086
|
+
return _objectSpread$o({
|
|
1087
|
+
key: item.id
|
|
1088
|
+
}, item);
|
|
1089
|
+
}),
|
|
1090
|
+
rowSelection: false,
|
|
1091
|
+
scroll: {
|
|
1092
|
+
x: 0
|
|
1093
|
+
},
|
|
1094
|
+
tableLayout: "fixed"
|
|
1095
|
+
})
|
|
1096
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
|
|
1097
|
+
isOpen: !!selectedRule,
|
|
1098
|
+
isSubmitting: isDeleting,
|
|
1099
|
+
submitButtonLabel: t("neetoRules.button.delete"),
|
|
1100
|
+
title: t("neetoRules.deleteAlert.title"),
|
|
1101
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1102
|
+
i18nKey: "neetoRules.deleteAlert.message",
|
|
1103
|
+
values: {
|
|
1104
|
+
name: selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.name
|
|
1105
|
+
}
|
|
1106
|
+
}),
|
|
1107
|
+
onClose: function onClose() {
|
|
1108
|
+
return setSelectedRule(null);
|
|
1109
|
+
},
|
|
1110
|
+
onSubmit: function onSubmit() {
|
|
1111
|
+
return deleteRule({
|
|
1112
|
+
id: selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.id,
|
|
1113
|
+
url: url
|
|
1114
|
+
}, {
|
|
1115
|
+
onSuccess: function onSuccess() {
|
|
1116
|
+
return setSelectedRule(null);
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
})]
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
|
|
693
1124
|
function _typeof$2(o) {
|
|
694
1125
|
"@babel/helpers - typeof";
|
|
695
1126
|
|
|
@@ -1288,7 +1719,7 @@ function _extends$2() {
|
|
|
1288
1719
|
}, _extends$2.apply(null, arguments);
|
|
1289
1720
|
}
|
|
1290
1721
|
|
|
1291
|
-
function _objectWithoutPropertiesLoose$
|
|
1722
|
+
function _objectWithoutPropertiesLoose$1(r, e) {
|
|
1292
1723
|
if (null == r) return {};
|
|
1293
1724
|
var t = {};
|
|
1294
1725
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
@@ -1522,7 +1953,7 @@ function finalPropsSelectorFactory(dispatch, _ref) {
|
|
|
1522
1953
|
initMapDispatchToProps,
|
|
1523
1954
|
initMergeProps
|
|
1524
1955
|
} = _ref,
|
|
1525
|
-
options = _objectWithoutPropertiesLoose$
|
|
1956
|
+
options = _objectWithoutPropertiesLoose$1(_ref, _excluded$i);
|
|
1526
1957
|
|
|
1527
1958
|
const mapStateToProps = initMapStateToProps(dispatch, options);
|
|
1528
1959
|
const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
|
@@ -2037,7 +2468,7 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
|
|
|
2037
2468
|
const {
|
|
2038
2469
|
reactReduxForwardedRef
|
|
2039
2470
|
} = props,
|
|
2040
|
-
wrapperProps = _objectWithoutPropertiesLoose$
|
|
2471
|
+
wrapperProps = _objectWithoutPropertiesLoose$1(props, _excluded$h);
|
|
2041
2472
|
|
|
2042
2473
|
return [props.context, reactReduxForwardedRef, wrapperProps];
|
|
2043
2474
|
}, [props]);
|
|
@@ -9904,35 +10335,6 @@ function _objectDestructuringEmpty(obj) {
|
|
|
9904
10335
|
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
9905
10336
|
}
|
|
9906
10337
|
|
|
9907
|
-
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
9908
|
-
if (source == null) return {};
|
|
9909
|
-
var target = {};
|
|
9910
|
-
var sourceKeys = Object.keys(source);
|
|
9911
|
-
var key, i;
|
|
9912
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
9913
|
-
key = sourceKeys[i];
|
|
9914
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
9915
|
-
target[key] = source[key];
|
|
9916
|
-
}
|
|
9917
|
-
return target;
|
|
9918
|
-
}
|
|
9919
|
-
|
|
9920
|
-
function _objectWithoutProperties$1(source, excluded) {
|
|
9921
|
-
if (source == null) return {};
|
|
9922
|
-
var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
|
9923
|
-
var key, i;
|
|
9924
|
-
if (Object.getOwnPropertySymbols) {
|
|
9925
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
9926
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
9927
|
-
key = sourceSymbolKeys[i];
|
|
9928
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
9929
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
9930
|
-
target[key] = source[key];
|
|
9931
|
-
}
|
|
9932
|
-
}
|
|
9933
|
-
return target;
|
|
9934
|
-
}
|
|
9935
|
-
|
|
9936
10338
|
var propTypes = {exports: {}};
|
|
9937
10339
|
|
|
9938
10340
|
/**
|
|
@@ -10024,22 +10426,6 @@ var factoryWithThrowingShims = function() {
|
|
|
10024
10426
|
var propTypesExports = propTypes.exports;
|
|
10025
10427
|
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
10026
10428
|
|
|
10027
|
-
function _arrayWithoutHoles$1(arr) {
|
|
10028
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
|
|
10029
|
-
}
|
|
10030
|
-
|
|
10031
|
-
function _iterableToArray$1(iter) {
|
|
10032
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
10033
|
-
}
|
|
10034
|
-
|
|
10035
|
-
function _nonIterableSpread$1() {
|
|
10036
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10037
|
-
}
|
|
10038
|
-
|
|
10039
|
-
function _toConsumableArray$1(arr) {
|
|
10040
|
-
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
|
|
10041
|
-
}
|
|
10042
|
-
|
|
10043
10429
|
var ACTION_TYPES = {
|
|
10044
10430
|
emailToIds: "emailToIds",
|
|
10045
10431
|
email: "email",
|
|
@@ -10192,7 +10578,7 @@ var getConditionsSchema = function getConditionsSchema(element) {
|
|
|
10192
10578
|
} else if ([CONDITION_VALUE_TYPES.textarea].includes(type)) {
|
|
10193
10579
|
return yup__namespace.object({
|
|
10194
10580
|
value: yup__namespace.string().test("text", i18next.t("neetoRules.validations.required.text"), function (value) {
|
|
10195
|
-
return !
|
|
10581
|
+
return !utils$1.isEditorEmpty(value);
|
|
10196
10582
|
})
|
|
10197
10583
|
});
|
|
10198
10584
|
}
|
|
@@ -10221,7 +10607,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
10221
10607
|
subject: !selectedAction.hideSubject ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.subject")) : schema,
|
|
10222
10608
|
emails: selectedAction.type === ACTION_TYPES.emailToIds ? yup__namespace.array().min(1, i18next.t("neetoRules.validations.required.emailId")).required(i18next.t("neetoRules.validations.required.emailId")).of(yup__namespace.string().email(i18next.t("neetoRules.validations.inValidEmail"))) : schema,
|
|
10223
10609
|
body: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
|
|
10224
|
-
return !
|
|
10610
|
+
return !utils$1.isEditorEmpty(value);
|
|
10225
10611
|
}),
|
|
10226
10612
|
value: selectedAction.type === ACTION_TYPES.emailTo ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.value")) : schema
|
|
10227
10613
|
});
|
|
@@ -10233,7 +10619,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
10233
10619
|
return PhoneNumber.isPhoneNumberValid(value);
|
|
10234
10620
|
})) : schema,
|
|
10235
10621
|
body: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
|
|
10236
|
-
return !
|
|
10622
|
+
return !utils$1.isEditorEmpty(value);
|
|
10237
10623
|
}),
|
|
10238
10624
|
value: selectedAction.type === ACTION_TYPES.smsTo ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.value")) : schema
|
|
10239
10625
|
});
|
|
@@ -10256,7 +10642,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
10256
10642
|
} else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.note || (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.textarea) {
|
|
10257
10643
|
return yup__namespace.object({
|
|
10258
10644
|
value: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
|
|
10259
|
-
return !
|
|
10645
|
+
return !utils$1.isEditorEmpty(value);
|
|
10260
10646
|
})
|
|
10261
10647
|
});
|
|
10262
10648
|
} else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.dropdown || (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.date) {
|
|
@@ -11229,7 +11615,7 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
11229
11615
|
React.useEffect(function () {
|
|
11230
11616
|
setFieldValue(name, editorData);
|
|
11231
11617
|
}, [debouncedValue]);
|
|
11232
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
11618
|
+
return /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], _objectSpread$f({
|
|
11233
11619
|
addons: addons,
|
|
11234
11620
|
autoFocus: autoFocus,
|
|
11235
11621
|
defaults: defaults,
|
|
@@ -22680,5 +23066,6 @@ NeetoRules.EventConditions = EventConditions;
|
|
|
22680
23066
|
exports.NeetoRulesForm = NeetoRules;
|
|
22681
23067
|
exports.RulePreview = RulePreview;
|
|
22682
23068
|
exports.RulesReorder = RulesReorder;
|
|
23069
|
+
exports.RulesTable = RulesTable;
|
|
22683
23070
|
exports.useCustomDataStore = useCustomDataStore;
|
|
22684
23071
|
//# sourceMappingURL=index.cjs.js.map
|