@bigbinary/neeto-rules-frontend 2.5.16 → 2.5.17
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 +45 -0
- package/app/javascript/src/translations/en.json +38 -9
- package/dist/NeetoRules.js +12 -32
- package/dist/NeetoRules.js.map +1 -1
- package/dist/NeetoRulesForm.js +5112 -3423
- package/dist/NeetoRulesForm.js.map +1 -1
- package/dist/RulePreview.js +26 -19
- package/dist/RulePreview.js.map +1 -1
- package/dist/RulesReorder.js +2 -1
- package/dist/RulesReorder.js.map +1 -1
- package/dist/cjs/NeetoRules.js +19 -39
- package/dist/cjs/NeetoRules.js.map +1 -1
- package/dist/cjs/NeetoRulesForm.js +5109 -3420
- package/dist/cjs/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/RulePreview.js +27 -20
- package/dist/cjs/RulePreview.js.map +1 -1
- package/dist/cjs/RulesReorder.js +2 -1
- package/dist/cjs/RulesReorder.js.map +1 -1
- package/dist/cjs/index.js +24 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/{constants-C0OOtVhT.js → constants-BkPVd-Gz.js} +10 -8
- package/dist/constants-BkPVd-Gz.js.map +1 -0
- package/dist/{constants-CB5HRjxq.js → constants-DghBXpIM.js} +10 -7
- package/dist/constants-DghBXpIM.js.map +1 -0
- package/dist/{index-CYeamuNR.js → index-DXdpXQae.js} +7 -85
- package/dist/index-DXdpXQae.js.map +1 -0
- package/dist/{index-DGlpB-_C.js → index-e15PIyUY.js} +6 -88
- package/dist/index-e15PIyUY.js.map +1 -0
- package/dist/index.js +24 -19
- package/dist/index.js.map +1 -1
- package/dist/useAutomationRulesApi-CVgffrQW.js +102 -0
- package/dist/useAutomationRulesApi-CVgffrQW.js.map +1 -0
- package/dist/useAutomationRulesApi-Dex5R8oY.js +109 -0
- package/dist/useAutomationRulesApi-Dex5R8oY.js.map +1 -0
- package/dist/useUtilityStore-BcSUEW_u.js +70 -0
- package/dist/useUtilityStore-BcSUEW_u.js.map +1 -0
- package/dist/useUtilityStore-DhJI92iM.js +74 -0
- package/dist/useUtilityStore-DhJI92iM.js.map +1 -0
- package/package.json +4 -1
- package/types.d.ts +14 -0
- package/dist/constants-C0OOtVhT.js.map +0 -1
- package/dist/constants-CB5HRjxq.js.map +0 -1
- package/dist/index-CYeamuNR.js.map +0 -1
- package/dist/index-DGlpB-_C.js.map +0 -1
- package/dist/useUtilityStore-BGuo9bko.js +0 -27
- package/dist/useUtilityStore-BGuo9bko.js.map +0 -1
- package/dist/useUtilityStore-KjKihXb0.js +0 -25
- package/dist/useUtilityStore-KjKihXb0.js.map +0 -1
- package/dist/utils-BngEaPaz.js +0 -26
- package/dist/utils-BngEaPaz.js.map +0 -1
- package/dist/utils-CvS2p6ZS.js +0 -23
- package/dist/utils-CvS2p6ZS.js.map +0 -1
|
@@ -7,90 +7,12 @@ import Pane from '@bigbinary/neetoui/Pane';
|
|
|
7
7
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
8
8
|
import Button from '@bigbinary/neetoui/Button';
|
|
9
9
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
10
|
-
import { equals, clone
|
|
10
|
+
import { equals, clone } from 'ramda';
|
|
11
11
|
import { useTranslation } from 'react-i18next';
|
|
12
|
-
import {
|
|
13
|
-
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
14
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
15
|
-
import axios from 'axios';
|
|
16
|
-
import { A as AUTOMATION_RULES, S as STALE_TIME } from './index-9h4B7JZZ.js';
|
|
12
|
+
import { u as useFetchAutomationRules, a as useReorderAutomationRules } from './useAutomationRulesApi-CVgffrQW.js';
|
|
17
13
|
import { withRouter } from 'react-router-dom';
|
|
18
14
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
19
15
|
|
|
20
|
-
var _excluded = ["url"];
|
|
21
|
-
var fetch = function fetch(_ref) {
|
|
22
|
-
var url = _ref.url,
|
|
23
|
-
params = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
-
return axios.get(url, {
|
|
25
|
-
params: params
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var update = function update(_ref2) {
|
|
29
|
-
var url = _ref2.url,
|
|
30
|
-
id = _ref2.id,
|
|
31
|
-
payload = _ref2.payload;
|
|
32
|
-
return axios.patch("".concat(url, "/").concat(id), payload);
|
|
33
|
-
};
|
|
34
|
-
var clone = function clone(_ref3) {
|
|
35
|
-
var url = _ref3.url,
|
|
36
|
-
id = _ref3.id;
|
|
37
|
-
return axios.post("".concat(url, "/").concat(id, "/clone"));
|
|
38
|
-
};
|
|
39
|
-
var destroy = function destroy(_ref4) {
|
|
40
|
-
var url = _ref4.url,
|
|
41
|
-
id = _ref4.id;
|
|
42
|
-
return axios["delete"]("".concat(url, "/").concat(id));
|
|
43
|
-
};
|
|
44
|
-
var reorder = function reorder(_ref5) {
|
|
45
|
-
var url = _ref5.url,
|
|
46
|
-
payload = _ref5.payload;
|
|
47
|
-
return axios.patch("".concat(url, "/reorder"), payload);
|
|
48
|
-
};
|
|
49
|
-
var automationRulesApi = {
|
|
50
|
-
fetch: fetch,
|
|
51
|
-
update: update,
|
|
52
|
-
clone: clone,
|
|
53
|
-
destroy: destroy,
|
|
54
|
-
reorder: reorder
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function ownKeys$3(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; }
|
|
58
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
59
|
-
var useFetchAutomationRules = function useFetchAutomationRules(params) {
|
|
60
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
61
|
-
return useQuery(_objectSpread$3({
|
|
62
|
-
queryKey: [AUTOMATION_RULES, params.url, params],
|
|
63
|
-
queryFn: function queryFn() {
|
|
64
|
-
return automationRulesApi.fetch(params);
|
|
65
|
-
},
|
|
66
|
-
staleTime: STALE_TIME,
|
|
67
|
-
select: function select(response) {
|
|
68
|
-
return response.data || response;
|
|
69
|
-
},
|
|
70
|
-
placeholderData: keepPreviousData
|
|
71
|
-
}, options));
|
|
72
|
-
};
|
|
73
|
-
var useUpdateAutomationRule = function useUpdateAutomationRule(url) {
|
|
74
|
-
return useMutationWithInvalidation(automationRulesApi.update, {
|
|
75
|
-
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
var useCloneAutomationRule = function useCloneAutomationRule(url) {
|
|
79
|
-
return useMutationWithInvalidation(automationRulesApi.clone, {
|
|
80
|
-
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
var useDeleteAutomationRule = function useDeleteAutomationRule(url) {
|
|
84
|
-
return useMutationWithInvalidation(automationRulesApi.destroy, {
|
|
85
|
-
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
var useReorderAutomationRules = function useReorderAutomationRules(url) {
|
|
89
|
-
return useMutationWithInvalidation(automationRulesApi.reorder, {
|
|
90
|
-
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
16
|
var INITIAL_RULES_DATA = {
|
|
95
17
|
rules: [],
|
|
96
18
|
totalCount: 0
|
|
@@ -137,7 +59,7 @@ var DraggableItem = function DraggableItem(props) {
|
|
|
137
59
|
children: [/*#__PURE__*/jsx(Reorder, {}), /*#__PURE__*/jsx("div", {
|
|
138
60
|
className: "neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3",
|
|
139
61
|
"data-cy": "automation-rule-reorder-container",
|
|
140
|
-
children: rule.name
|
|
62
|
+
children: rule.name || rule.defaultName
|
|
141
63
|
})]
|
|
142
64
|
}), "list_".concat(rule.id));
|
|
143
65
|
}
|
|
@@ -196,7 +118,7 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
196
118
|
var items = reorderList({
|
|
197
119
|
endIndex: destination.index,
|
|
198
120
|
firstDisplayOrder: firstDisplayOrder,
|
|
199
|
-
list: clone
|
|
121
|
+
list: clone(reorderedRules),
|
|
200
122
|
startIndex: source.index
|
|
201
123
|
});
|
|
202
124
|
setReorderedRules(items);
|
|
@@ -243,7 +165,7 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
243
165
|
children: [/*#__PURE__*/jsx(Reorder, {}), /*#__PURE__*/jsx("div", {
|
|
244
166
|
className: "neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3",
|
|
245
167
|
children: /*#__PURE__*/jsx("div", {
|
|
246
|
-
children: reorderedRules[rubric.source.index].name
|
|
168
|
+
children: reorderedRules[rubric.source.index].name || reorderedRules[rubric.source.index].defaultName
|
|
247
169
|
})
|
|
248
170
|
})]
|
|
249
171
|
}), "list_".concat(reorderedRules[rubric.source.index].id));
|
|
@@ -280,5 +202,5 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
280
202
|
});
|
|
281
203
|
};
|
|
282
204
|
|
|
283
|
-
export { INITIAL_RULES_DATA as I, RulesReorder as R
|
|
284
|
-
//# sourceMappingURL=index-
|
|
205
|
+
export { INITIAL_RULES_DATA as I, RulesReorder as R };
|
|
206
|
+
//# sourceMappingURL=index-DXdpXQae.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DXdpXQae.js","sources":["../app/javascript/src/components/NeetoRules/constants.js","../app/javascript/src/components/NeetoRules/RulesReorder/utils.js","../app/javascript/src/components/NeetoRules/RulesReorder/DraggableItem.jsx","../app/javascript/src/components/NeetoRules/RulesReorder/index.jsx"],"sourcesContent":["export const STATUS_KEYS = { ENABLED: \"enabled\", DISABLED: \"disabled\" };\n\nexport const DEFAULT_INIT_PAGE = 1;\n\nexport const INITIAL_RULES_DATA = { rules: [], totalCount: 0 };\n","export const reorderList = ({\n endIndex,\n firstDisplayOrder,\n list,\n startIndex,\n}) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n result.splice(endIndex, 0, removed);\n\n return result.map((item, index) => ({\n ...item,\n displayOrder: firstDisplayOrder + index,\n }));\n};\n\nexport const getDragItemStyle = (isDragging, draggableStyle) => ({\n // styles we need to apply on draggables\n ...draggableStyle,\n\n ...(isDragging && { zIndex: 99999 }),\n});\n","import { Draggable } from \"@hello-pangea/dnd\";\nimport { Reorder } from \"neetoicons\";\nimport { withRouter } from \"react-router-dom\";\n\nimport { getDragItemStyle } from \"./utils\";\n\nconst DraggableItem = props => {\n const { rule, ruleIndex } = props;\n\n return (\n <Draggable draggableId={`item_${rule.id}`} index={ruleIndex}>\n {(provided, snapshot) => (\n <div\n className=\"neeto-ui-text-gray-800 mb-3 flex items-center space-x-4 font-medium\"\n key={`list_${rule.id}`}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n style={getDragItemStyle(\n snapshot.isDragging,\n provided.draggableProps.style\n )}\n >\n <Reorder />\n <div\n className=\"neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3\"\n data-cy=\"automation-rule-reorder-container\"\n >\n {rule.name || rule.defaultName}\n </div>\n </div>\n )}\n </Draggable>\n );\n};\n\nexport default withRouter(DraggableItem);\n","import { useEffect, useState } from \"react\";\n\nimport { DragDropContext, Droppable } from \"@hello-pangea/dnd\";\nimport { Reorder as NeetoUIReorderIcon } from \"neetoicons\";\nimport { Pane, Typography, Button, Spinner } from \"neetoui\";\nimport { clone, equals } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchAutomationRules,\n useReorderAutomationRules,\n} from \"hooks/reactQuery/useAutomationRulesApi\";\n\nimport DraggableItem from \"./DraggableItem\";\nimport { getDragItemStyle, reorderList } from \"./utils\";\n\nimport { INITIAL_RULES_DATA } from \"../constants\";\n\nconst RulesReorder = ({\n isOpen,\n totalCount,\n url,\n onClose,\n onReorderSuccess,\n}) => {\n const [reorderedRules, setReorderedRules] = useState([]);\n\n const { t } = useTranslation();\n\n const { data: { rules } = INITIAL_RULES_DATA, isLoading } =\n useFetchAutomationRules({ pageSize: totalCount, url }, { enabled: isOpen });\n\n const { mutate: reOrder, isPending } = useReorderAutomationRules(url);\n\n const firstDisplayOrder = rules[0]?.displayOrder ?? 1;\n\n const handleReorderSave = () =>\n reOrder(\n { url, payload: { reorder: { rules: reorderedRules } } },\n {\n onSuccess: () => {\n onReorderSuccess?.();\n onClose();\n },\n }\n );\n\n const onDragEnd = ({ destination, source }) => {\n if (!destination || source.index === destination.index) return;\n\n const items = reorderList({\n endIndex: destination.index,\n firstDisplayOrder,\n list: clone(reorderedRules),\n startIndex: source.index,\n });\n setReorderedRules(items);\n };\n\n useEffect(() => {\n setReorderedRules(rules);\n }, [rules]);\n\n if (isLoading) {\n return (\n <Pane {...{ isOpen, onClose }}>\n <div className=\"flex h-full w-full items-center justify-center\">\n <Spinner />\n </div>\n </Pane>\n );\n }\n\n return (\n <Pane {...{ isOpen, onClose }}>\n <Pane.Header>\n <Typography style=\"h2\" weight=\"semibold\">\n {t(\"neetoRules.common.reorder\")}\n </Typography>\n </Pane.Header>\n <Pane.Body>\n <Typography className=\"mb-3\" style=\"body2\">\n {t(\"neetoRules.description.reorder\")}\n </Typography>\n <div className=\"flex flex-col items-center\">\n <DragDropContext {...{ onDragEnd }}>\n <Droppable\n droppableId=\"droppable\"\n renderClone={(provided, snapshot, rubric) => (\n <div\n className=\"neeto-ui-text-gray-800 mb-3 flex items-center space-x-4 font-medium\"\n key={`list_${reorderedRules[rubric.source.index].id}`}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n style={getDragItemStyle(\n snapshot.isDragging,\n provided.draggableProps.style\n )}\n >\n <NeetoUIReorderIcon />\n <div className=\"neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3\">\n <div>\n {reorderedRules[rubric.source.index].name ||\n reorderedRules[rubric.source.index].defaultName}\n </div>\n </div>\n </div>\n )}\n >\n {provided => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {reorderedRules.map((rule, index) => (\n <DraggableItem\n {...{ rule }}\n key={rule.id}\n ruleIndex={index}\n />\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n </div>\n </Pane.Body>\n <Pane.Footer className=\"flex items-center gap-x-2\">\n <Button\n disabled={isPending || equals(rules, reorderedRules)}\n label={t(\"neetoRules.common.saveChange\")}\n loading={isPending}\n style=\"primary\"\n onClick={handleReorderSave}\n />\n <Button\n label={t(\"neetoRules.buttons.cancel\")}\n style=\"text\"\n onClick={onClose}\n />\n </Pane.Footer>\n </Pane>\n );\n};\nexport default RulesReorder;\n"],"names":["INITIAL_RULES_DATA","rules","totalCount","reorderList","_ref","endIndex","firstDisplayOrder","list","startIndex","result","Array","from","_result$splice","splice","_result$splice2","_slicedToArray","removed","map","item","index","_objectSpread","displayOrder","getDragItemStyle","isDragging","draggableStyle","zIndex","DraggableItem","props","rule","ruleIndex","_jsx","Draggable","draggableId","concat","id","children","provided","snapshot","_jsxs","className","ref","innerRef","draggableProps","dragHandleProps","style","Reorder","name","defaultName","withRouter","RulesReorder","_rules$0$displayOrder","_rules$","isOpen","url","onClose","onReorderSuccess","_useState","useState","_useState2","reorderedRules","setReorderedRules","_useTranslation","useTranslation","t","_useFetchAutomationRu","useFetchAutomationRules","pageSize","enabled","_useFetchAutomationRu2","data","_useFetchAutomationRu3","isLoading","_useReorderAutomation","useReorderAutomationRules","reOrder","mutate","isPending","handleReorderSave","payload","reorder","onSuccess","onDragEnd","_ref2","destination","source","items","clone","useEffect","Pane","Spinner","Header","Typography","weight","Body","DragDropContext","Droppable","droppableId","renderClone","rubric","NeetoUIReorderIcon","droppableProps","_createElement","key","placeholder","Footer","Button","disabled","equals","label","loading","onClick"],"mappings":";;;;;;;;;;;;;;;AAIO,IAAMA,kBAAkB,GAAG;AAAEC,EAAAA,KAAK,EAAE,EAAE;AAAEC,EAAAA,UAAU,EAAE;AAAE;;;;ACJtD,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAKlB;AAAA,EAAA,IAJJC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IACjBC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IACJC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;AAEV,EAAA,IAAMC,MAAM,GAAGC,KAAK,CAACC,IAAI,CAACJ,IAAI,CAAC;EAC/B,IAAAK,cAAA,GAAkBH,MAAM,CAACI,MAAM,CAACL,UAAU,EAAE,CAAC,CAAC;IAAAM,eAAA,GAAAC,cAAA,CAAAH,cAAA,EAAA,CAAA,CAAA;AAAvCI,IAAAA,OAAO,GAAAF,eAAA,CAAA,CAAA,CAAA;EACdL,MAAM,CAACI,MAAM,CAACR,QAAQ,EAAE,CAAC,EAAEW,OAAO,CAAC;AAEnC,EAAA,OAAOP,MAAM,CAACQ,GAAG,CAAC,UAACC,IAAI,EAAEC,KAAK,EAAA;AAAA,IAAA,OAAAC,eAAA,CAAAA,eAAA,CAAA,EAAA,EACzBF,IAAI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EAAA,EAAA;gBAAE5D,GAAG,EAAEJ,QAAQ,CAACK,QAAS;gBAAAN,QAAA,EAAA,CACtDwB,cAAc,CAAC1C,GAAG,CAAC,UAACW,IAAI,EAAET,KAAK,EAAA;kBAAA,oBAC9BkF,aAAA,CAAC3E,eAAa,EAAA;AACNE,oBAAAA,IAAI,EAAJA,IAAI;oBACV0E,GAAG,EAAE1E,IAAI,CAACM,EAAG;AACbL,oBAAAA,SAAS,EAAEV;AAAM,mBAClB,CAAC;AAAA,iBACH,CAAC,EACDiB,QAAQ,CAACmE,WAAW;AAAA,eAAA,CAClB,CAAC;AAAA;WAEC;SACI;AAAC,OACf,CAAC;AAAA,KACG,CAAC,eACZjE,IAAA,CAACkD,IAAI,CAACgB,MAAM,EAAA;AAACjE,MAAAA,SAAS,EAAC,2BAA2B;MAAAJ,QAAA,EAAA,cAChDL,GAAA,CAAC2E,MAAM,EAAA;QACLC,QAAQ,EAAE9B,SAAS,IAAI+B,MAAM,CAAC1G,KAAK,EAAE0D,cAAc,CAAE;AACrDiD,QAAAA,KAAK,EAAE7C,CAAC,CAAC,8BAA8B,CAAE;AACzC8C,QAAAA,OAAO,EAAEjC,SAAU;AACnBhC,QAAAA,KAAK,EAAC,SAAS;AACfkE,QAAAA,OAAO,EAAEjC;AAAkB,OAC5B,CAAC,eACF/C,GAAA,CAAC2E,MAAM,EAAA;AACLG,QAAAA,KAAK,EAAE7C,CAAC,CAAC,2BAA2B,CAAE;AACtCnB,QAAAA,KAAK,EAAC,MAAM;AACZkE,QAAAA,OAAO,EAAExD;AAAQ,OAClB,CAAC;AAAA,KACS,CAAC;AAAA,GACV,CAAC;AAEX;;;;"}
|
|
@@ -11,88 +11,10 @@ var Button = require('@bigbinary/neetoui/Button');
|
|
|
11
11
|
var Spinner = require('@bigbinary/neetoui/Spinner');
|
|
12
12
|
var ramda = require('ramda');
|
|
13
13
|
var reactI18next = require('react-i18next');
|
|
14
|
-
var
|
|
15
|
-
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
16
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
17
|
-
var axios = require('axios');
|
|
18
|
-
var constants = require('./index-DFwPrb81.js');
|
|
14
|
+
var useAutomationRulesApi = require('./useAutomationRulesApi-Dex5R8oY.js');
|
|
19
15
|
var reactRouterDom = require('react-router-dom');
|
|
20
16
|
var jsxRuntime = require('react/jsx-runtime');
|
|
21
17
|
|
|
22
|
-
var _excluded = ["url"];
|
|
23
|
-
var fetch = function fetch(_ref) {
|
|
24
|
-
var url = _ref.url,
|
|
25
|
-
params = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
-
return axios.get(url, {
|
|
27
|
-
params: params
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var update = function update(_ref2) {
|
|
31
|
-
var url = _ref2.url,
|
|
32
|
-
id = _ref2.id,
|
|
33
|
-
payload = _ref2.payload;
|
|
34
|
-
return axios.patch("".concat(url, "/").concat(id), payload);
|
|
35
|
-
};
|
|
36
|
-
var clone = function clone(_ref3) {
|
|
37
|
-
var url = _ref3.url,
|
|
38
|
-
id = _ref3.id;
|
|
39
|
-
return axios.post("".concat(url, "/").concat(id, "/clone"));
|
|
40
|
-
};
|
|
41
|
-
var destroy = function destroy(_ref4) {
|
|
42
|
-
var url = _ref4.url,
|
|
43
|
-
id = _ref4.id;
|
|
44
|
-
return axios["delete"]("".concat(url, "/").concat(id));
|
|
45
|
-
};
|
|
46
|
-
var reorder = function reorder(_ref5) {
|
|
47
|
-
var url = _ref5.url,
|
|
48
|
-
payload = _ref5.payload;
|
|
49
|
-
return axios.patch("".concat(url, "/reorder"), payload);
|
|
50
|
-
};
|
|
51
|
-
var automationRulesApi = {
|
|
52
|
-
fetch: fetch,
|
|
53
|
-
update: update,
|
|
54
|
-
clone: clone,
|
|
55
|
-
destroy: destroy,
|
|
56
|
-
reorder: reorder
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
function ownKeys$3(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; }
|
|
60
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
61
|
-
var useFetchAutomationRules = function useFetchAutomationRules(params) {
|
|
62
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
|
-
return reactQuery.useQuery(_objectSpread$3({
|
|
64
|
-
queryKey: [constants.AUTOMATION_RULES, params.url, params],
|
|
65
|
-
queryFn: function queryFn() {
|
|
66
|
-
return automationRulesApi.fetch(params);
|
|
67
|
-
},
|
|
68
|
-
staleTime: constants.STALE_TIME,
|
|
69
|
-
select: function select(response) {
|
|
70
|
-
return response.data || response;
|
|
71
|
-
},
|
|
72
|
-
placeholderData: reactQuery.keepPreviousData
|
|
73
|
-
}, options));
|
|
74
|
-
};
|
|
75
|
-
var useUpdateAutomationRule = function useUpdateAutomationRule(url) {
|
|
76
|
-
return reactUtils.useMutationWithInvalidation(automationRulesApi.update, {
|
|
77
|
-
keysToInvalidate: [[constants.AUTOMATION_RULES, url]]
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
var useCloneAutomationRule = function useCloneAutomationRule(url) {
|
|
81
|
-
return reactUtils.useMutationWithInvalidation(automationRulesApi.clone, {
|
|
82
|
-
keysToInvalidate: [[constants.AUTOMATION_RULES, url]]
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
var useDeleteAutomationRule = function useDeleteAutomationRule(url) {
|
|
86
|
-
return reactUtils.useMutationWithInvalidation(automationRulesApi.destroy, {
|
|
87
|
-
keysToInvalidate: [[constants.AUTOMATION_RULES, url]]
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
var useReorderAutomationRules = function useReorderAutomationRules(url) {
|
|
91
|
-
return reactUtils.useMutationWithInvalidation(automationRulesApi.reorder, {
|
|
92
|
-
keysToInvalidate: [[constants.AUTOMATION_RULES, url]]
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
18
|
var INITIAL_RULES_DATA = {
|
|
97
19
|
rules: [],
|
|
98
20
|
totalCount: 0
|
|
@@ -139,7 +61,7 @@ var DraggableItem = function DraggableItem(props) {
|
|
|
139
61
|
children: [/*#__PURE__*/jsxRuntime.jsx(Reorder, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
140
62
|
className: "neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3",
|
|
141
63
|
"data-cy": "automation-rule-reorder-container",
|
|
142
|
-
children: rule.name
|
|
64
|
+
children: rule.name || rule.defaultName
|
|
143
65
|
})]
|
|
144
66
|
}), "list_".concat(rule.id));
|
|
145
67
|
}
|
|
@@ -162,7 +84,7 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
162
84
|
setReorderedRules = _useState2[1];
|
|
163
85
|
var _useTranslation = reactI18next.useTranslation(),
|
|
164
86
|
t = _useTranslation.t;
|
|
165
|
-
var _useFetchAutomationRu = useFetchAutomationRules({
|
|
87
|
+
var _useFetchAutomationRu = useAutomationRulesApi.useFetchAutomationRules({
|
|
166
88
|
pageSize: totalCount,
|
|
167
89
|
url: url
|
|
168
90
|
}, {
|
|
@@ -172,7 +94,7 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
172
94
|
_useFetchAutomationRu3 = _useFetchAutomationRu2 === void 0 ? INITIAL_RULES_DATA : _useFetchAutomationRu2,
|
|
173
95
|
rules = _useFetchAutomationRu3.rules,
|
|
174
96
|
isLoading = _useFetchAutomationRu.isLoading;
|
|
175
|
-
var _useReorderAutomation = useReorderAutomationRules(url),
|
|
97
|
+
var _useReorderAutomation = useAutomationRulesApi.useReorderAutomationRules(url),
|
|
176
98
|
reOrder = _useReorderAutomation.mutate,
|
|
177
99
|
isPending = _useReorderAutomation.isPending;
|
|
178
100
|
var firstDisplayOrder = (_rules$0$displayOrder = (_rules$ = rules[0]) === null || _rules$ === void 0 ? void 0 : _rules$.displayOrder) !== null && _rules$0$displayOrder !== void 0 ? _rules$0$displayOrder : 1;
|
|
@@ -245,7 +167,7 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
245
167
|
children: [/*#__PURE__*/jsxRuntime.jsx(Reorder, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
246
168
|
className: "neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3",
|
|
247
169
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
248
|
-
children: reorderedRules[rubric.source.index].name
|
|
170
|
+
children: reorderedRules[rubric.source.index].name || reorderedRules[rubric.source.index].defaultName
|
|
249
171
|
})
|
|
250
172
|
})]
|
|
251
173
|
}), "list_".concat(reorderedRules[rubric.source.index].id));
|
|
@@ -284,8 +206,4 @@ var RulesReorder = function RulesReorder(_ref) {
|
|
|
284
206
|
|
|
285
207
|
exports.INITIAL_RULES_DATA = INITIAL_RULES_DATA;
|
|
286
208
|
exports.RulesReorder = RulesReorder;
|
|
287
|
-
|
|
288
|
-
exports.useDeleteAutomationRule = useDeleteAutomationRule;
|
|
289
|
-
exports.useFetchAutomationRules = useFetchAutomationRules;
|
|
290
|
-
exports.useUpdateAutomationRule = useUpdateAutomationRule;
|
|
291
|
-
//# sourceMappingURL=index-DGlpB-_C.js.map
|
|
209
|
+
//# sourceMappingURL=index-e15PIyUY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-e15PIyUY.js","sources":["../app/javascript/src/components/NeetoRules/constants.js","../app/javascript/src/components/NeetoRules/RulesReorder/utils.js","../app/javascript/src/components/NeetoRules/RulesReorder/DraggableItem.jsx","../app/javascript/src/components/NeetoRules/RulesReorder/index.jsx"],"sourcesContent":["export const STATUS_KEYS = { ENABLED: \"enabled\", DISABLED: \"disabled\" };\n\nexport const DEFAULT_INIT_PAGE = 1;\n\nexport const INITIAL_RULES_DATA = { rules: [], totalCount: 0 };\n","export const reorderList = ({\n endIndex,\n firstDisplayOrder,\n list,\n startIndex,\n}) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n result.splice(endIndex, 0, removed);\n\n return result.map((item, index) => ({\n ...item,\n displayOrder: firstDisplayOrder + index,\n }));\n};\n\nexport const getDragItemStyle = (isDragging, draggableStyle) => ({\n // styles we need to apply on draggables\n ...draggableStyle,\n\n ...(isDragging && { zIndex: 99999 }),\n});\n","import { Draggable } from \"@hello-pangea/dnd\";\nimport { Reorder } from \"neetoicons\";\nimport { withRouter } from \"react-router-dom\";\n\nimport { getDragItemStyle } from \"./utils\";\n\nconst DraggableItem = props => {\n const { rule, ruleIndex } = props;\n\n return (\n <Draggable draggableId={`item_${rule.id}`} index={ruleIndex}>\n {(provided, snapshot) => (\n <div\n className=\"neeto-ui-text-gray-800 mb-3 flex items-center space-x-4 font-medium\"\n key={`list_${rule.id}`}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n style={getDragItemStyle(\n snapshot.isDragging,\n provided.draggableProps.style\n )}\n >\n <Reorder />\n <div\n className=\"neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3\"\n data-cy=\"automation-rule-reorder-container\"\n >\n {rule.name || rule.defaultName}\n </div>\n </div>\n )}\n </Draggable>\n );\n};\n\nexport default withRouter(DraggableItem);\n","import { useEffect, useState } from \"react\";\n\nimport { DragDropContext, Droppable } from \"@hello-pangea/dnd\";\nimport { Reorder as NeetoUIReorderIcon } from \"neetoicons\";\nimport { Pane, Typography, Button, Spinner } from \"neetoui\";\nimport { clone, equals } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchAutomationRules,\n useReorderAutomationRules,\n} from \"hooks/reactQuery/useAutomationRulesApi\";\n\nimport DraggableItem from \"./DraggableItem\";\nimport { getDragItemStyle, reorderList } from \"./utils\";\n\nimport { INITIAL_RULES_DATA } from \"../constants\";\n\nconst RulesReorder = ({\n isOpen,\n totalCount,\n url,\n onClose,\n onReorderSuccess,\n}) => {\n const [reorderedRules, setReorderedRules] = useState([]);\n\n const { t } = useTranslation();\n\n const { data: { rules } = INITIAL_RULES_DATA, isLoading } =\n useFetchAutomationRules({ pageSize: totalCount, url }, { enabled: isOpen });\n\n const { mutate: reOrder, isPending } = useReorderAutomationRules(url);\n\n const firstDisplayOrder = rules[0]?.displayOrder ?? 1;\n\n const handleReorderSave = () =>\n reOrder(\n { url, payload: { reorder: { rules: reorderedRules } } },\n {\n onSuccess: () => {\n onReorderSuccess?.();\n onClose();\n },\n }\n );\n\n const onDragEnd = ({ destination, source }) => {\n if (!destination || source.index === destination.index) return;\n\n const items = reorderList({\n endIndex: destination.index,\n firstDisplayOrder,\n list: clone(reorderedRules),\n startIndex: source.index,\n });\n setReorderedRules(items);\n };\n\n useEffect(() => {\n setReorderedRules(rules);\n }, [rules]);\n\n if (isLoading) {\n return (\n <Pane {...{ isOpen, onClose }}>\n <div className=\"flex h-full w-full items-center justify-center\">\n <Spinner />\n </div>\n </Pane>\n );\n }\n\n return (\n <Pane {...{ isOpen, onClose }}>\n <Pane.Header>\n <Typography style=\"h2\" weight=\"semibold\">\n {t(\"neetoRules.common.reorder\")}\n </Typography>\n </Pane.Header>\n <Pane.Body>\n <Typography className=\"mb-3\" style=\"body2\">\n {t(\"neetoRules.description.reorder\")}\n </Typography>\n <div className=\"flex flex-col items-center\">\n <DragDropContext {...{ onDragEnd }}>\n <Droppable\n droppableId=\"droppable\"\n renderClone={(provided, snapshot, rubric) => (\n <div\n className=\"neeto-ui-text-gray-800 mb-3 flex items-center space-x-4 font-medium\"\n key={`list_${reorderedRules[rubric.source.index].id}`}\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n style={getDragItemStyle(\n snapshot.isDragging,\n provided.draggableProps.style\n )}\n >\n <NeetoUIReorderIcon />\n <div className=\"neeto-ui-bg-white neeto-ui-border-gray-400 neeto-ui-rounded neeto-ui-shadow-xs flex w-96 items-center space-x-4 border border-solid p-3\">\n <div>\n {reorderedRules[rubric.source.index].name ||\n reorderedRules[rubric.source.index].defaultName}\n </div>\n </div>\n </div>\n )}\n >\n {provided => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {reorderedRules.map((rule, index) => (\n <DraggableItem\n {...{ rule }}\n key={rule.id}\n ruleIndex={index}\n />\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n </div>\n </Pane.Body>\n <Pane.Footer className=\"flex items-center gap-x-2\">\n <Button\n disabled={isPending || equals(rules, reorderedRules)}\n label={t(\"neetoRules.common.saveChange\")}\n loading={isPending}\n style=\"primary\"\n onClick={handleReorderSave}\n />\n <Button\n label={t(\"neetoRules.buttons.cancel\")}\n style=\"text\"\n onClick={onClose}\n />\n </Pane.Footer>\n </Pane>\n );\n};\nexport default RulesReorder;\n"],"names":["INITIAL_RULES_DATA","rules","totalCount","reorderList","_ref","endIndex","firstDisplayOrder","list","startIndex","result","Array","from","_result$splice","splice","_result$splice2","_slicedToArray","removed","map","item","index","_objectSpread","displayOrder","getDragItemStyle","isDragging","draggableStyle","zIndex","DraggableItem","props","rule","ruleIndex","_jsx","Draggable","draggableId","concat","id","children","provided","snapshot","_jsxs","className","ref","innerRef","draggableProps","dragHandleProps","style","Reorder","name","defaultName","withRouter","RulesReorder","_rules$0$displayOrder","_rules$","isOpen","url","onClose","onReorderSuccess","_useState","useState","_useState2","reorderedRules","setReorderedRules","_useTranslation","useTranslation","t","_useFetchAutomationRu","useFetchAutomationRules","pageSize","enabled","_useFetchAutomationRu2","data","_useFetchAutomationRu3","isLoading","_useReorderAutomation","useReorderAutomationRules","reOrder","mutate","isPending","handleReorderSave","payload","reorder","onSuccess","onDragEnd","_ref2","destination","source","items","clone","useEffect","Pane","Spinner","Header","Typography","weight","Body","DragDropContext","Droppable","droppableId","renderClone","rubric","NeetoUIReorderIcon","droppableProps","_createElement","key","placeholder","Footer","Button","disabled","equals","label","loading","onClick"],"mappings":";;;;;;;;;;;;;;;;;AAIO,IAAMA,kBAAkB,GAAG;AAAEC,EAAAA,KAAK,EAAE,EAAE;AAAEC,EAAAA,UAAU,EAAE;AAAE;;;;ACJtD,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAKlB;AAAA,EAAA,IAJJC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IACjBC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IACJC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;AAEV,EAAA,IAAMC,MAAM,GAAGC,KAAK,CAACC,IAAI,CAACJ,IAAI,CAAC;EAC/B,IAAAK,cAAA,GAAkBH,MAAM,CAACI,MAAM,CAACL,UAAU,EAAE,CAAC,CAAC;IAAAM,eAAA,GAAAC,cAAA,CAAAH,cAAA,EAAA,CAAA,CAAA;AAAvCI,IAAAA,OAAO,GAAAF,eAAA,CAAA,CAAA,CAAA;EACdL,MAAM,CAACI,MAAM,CAACR,QAAQ,EAAE,CAAC,EAAEW,OAAO,CAAC;AAEnC,EAAA,OAAOP,MAAM,CAACQ,GAAG,CAAC,UAACC,IAAI,EAAEC,KAAK,EAAA;AAAA,IAAA,OAAAC,eAAA,CAAAA,eAAA,CAAA,EAAA,EACzBF,IAAI,CAAA,EAAA,EAAA,EAAA;MACPG,YAAY,EAAEf,iBAAiB,GAAGa;A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AAAN,QAAA,EAAA,CACtDwB,cAAc,CAAC1C,GAAG,CAAC,UAACW,IAAI,EAAET,KAAK,EAAA;kBAAA,oBAC9BkF,mBAAA,CAAC3E,eAAa,EAAA;AACNE,oBAAAA,IAAI,EAAJA,IAAI;oBACV0E,GAAG,EAAE1E,IAAI,CAACM,EAAG;AACbL,oBAAAA,SAAS,EAAEV;AAAM,mBAClB,CAAC;AAAA,iBACH,CAAC,EACDiB,QAAQ,CAACmE,WAAW;AAAA,eAAA,CAClB,CAAC;AAAA;WAEC;SACI;AAAC,OACf,CAAC;AAAA,KACG,CAAC,eACZjE,eAAA,CAACkD,IAAI,CAACgB,MAAM,EAAA;AAACjE,MAAAA,SAAS,EAAC,2BAA2B;MAAAJ,QAAA,EAAA,cAChDL,cAAA,CAAC2E,MAAM,EAAA;QACLC,QAAQ,EAAE9B,SAAS,IAAI+B,YAAM,CAAC1G,KAAK,EAAE0D,cAAc,CAAE;AACrDiD,QAAAA,KAAK,EAAE7C,CAAC,CAAC,8BAA8B,CAAE;AACzC8C,QAAAA,OAAO,EAAEjC,SAAU;AACnBhC,QAAAA,KAAK,EAAC,SAAS;AACfkE,QAAAA,OAAO,EAAEjC;AAAkB,OAC5B,CAAC,eACF/C,cAAA,CAAC2E,MAAM,EAAA;AACLG,QAAAA,KAAK,EAAE7C,CAAC,CAAC,2BAA2B,CAAE;AACtCnB,QAAAA,KAAK,EAAC,MAAM;AACZkE,QAAAA,OAAO,EAAExD;AAAQ,OAClB,CAAC;AAAA,KACS,CAAC;AAAA,GACV,CAAC;AAEX;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { A as AUTOMATION_RULES_QUERY_KEY } from './index-9h4B7JZZ.js';
|
|
2
2
|
export { default as CannedResponsesPane } from './CannedResponsesPane.js';
|
|
3
3
|
export { default as NeetoRules } from './NeetoRules.js';
|
|
4
|
-
export { R as RulesReorder } from './index-
|
|
4
|
+
export { R as RulesReorder } from './index-DXdpXQae.js';
|
|
5
5
|
export { u as useCustomDataStore } from './useCustomDataStore-B1qHMIGJ.js';
|
|
6
6
|
export { default as NeetoRulesForm } from './NeetoRulesForm.js';
|
|
7
7
|
export { default as RulePreview } from './RulePreview.js';
|
|
@@ -28,42 +28,48 @@ import '@bigbinary/neetoui/Label';
|
|
|
28
28
|
import 'react/jsx-runtime';
|
|
29
29
|
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
30
30
|
import '@bigbinary/neeto-molecules/Container';
|
|
31
|
+
import './useAutomationRulesApi-CVgffrQW.js';
|
|
32
|
+
import '@tanstack/react-query';
|
|
33
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
34
|
+
import 'axios';
|
|
31
35
|
import '@bigbinary/neeto-molecules/Header';
|
|
32
36
|
import '@bigbinary/neetoui/Button';
|
|
33
|
-
import './
|
|
37
|
+
import './useUtilityStore-BcSUEW_u.js';
|
|
38
|
+
import 'zustand';
|
|
34
39
|
import 'zustand/shallow';
|
|
35
40
|
import '@bigbinary/neeto-molecules/SubHeader';
|
|
36
41
|
import '@bigbinary/neeto-molecules/TableWrapper';
|
|
37
42
|
import '@bigbinary/neetoui/Alert';
|
|
38
43
|
import '@bigbinary/neetoui/Table';
|
|
39
44
|
import '@bigbinary/neetoui/NoData';
|
|
40
|
-
import './useUtilityStore-KjKihXb0.js';
|
|
41
|
-
import 'zustand';
|
|
42
|
-
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
43
45
|
import '@bigbinary/neeto-commons-frontend/utils';
|
|
44
46
|
import '@bigbinary/neeto-molecules/MoreDropdown';
|
|
45
47
|
import '@bigbinary/neetoui/Switch';
|
|
46
|
-
import '@bigbinary/neetoui/Tooltip';
|
|
47
48
|
import '@hello-pangea/dnd';
|
|
48
49
|
import '@bigbinary/neeto-icons/Reorder';
|
|
49
|
-
import '@tanstack/react-query';
|
|
50
|
-
import 'axios';
|
|
51
50
|
import 'react-router-dom';
|
|
52
51
|
import '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
53
52
|
import '@bigbinary/neeto-icons/Plus';
|
|
54
53
|
import '@bigbinary/neeto-icons/Delete';
|
|
55
54
|
import '@bigbinary/neeto-icons/Refresh';
|
|
56
55
|
import 'classnames';
|
|
57
|
-
import '
|
|
58
|
-
import '@bigbinary/
|
|
59
|
-
import '@bigbinary/neetoui/
|
|
56
|
+
import 'yup';
|
|
57
|
+
import '@bigbinary/neetoui/formik/Radio';
|
|
58
|
+
import '@bigbinary/neetoui/managers';
|
|
59
|
+
import '@bigbinary/neeto-icons/Collapse';
|
|
60
|
+
import '@bigbinary/neeto-icons/Left';
|
|
60
61
|
import '@bigbinary/neetoui/formik/Textarea';
|
|
62
|
+
import '@bigbinary/neetoui/formik/Input';
|
|
63
|
+
import '@bigbinary/neetoui/formik/Switch';
|
|
64
|
+
import '@monaco-editor/react';
|
|
65
|
+
import '@bigbinary/neeto-icons/Help';
|
|
66
|
+
import '@bigbinary/neeto-molecules/DynamicVariables';
|
|
61
67
|
import '@bigbinary/neetoui/Select';
|
|
62
68
|
import '@bigbinary/neetoui/DatePicker';
|
|
63
|
-
import '@bigbinary/neeto-editor/FormikEditor';
|
|
64
69
|
import '@bigbinary/neetoui/formik/MultiEmailInput';
|
|
65
|
-
import '@bigbinary/
|
|
70
|
+
import '@bigbinary/neeto-editor/FormikEditor';
|
|
66
71
|
import '@bigbinary/neeto-hotkeys';
|
|
72
|
+
import '@bigbinary/neeto-icons/Check';
|
|
67
73
|
import '@bigbinary/neeto-icons/Close';
|
|
68
74
|
import '@bigbinary/neetoui/Checkbox';
|
|
69
75
|
import 'react-select/creatable';
|
|
@@ -71,14 +77,13 @@ import '@babel/runtime/helpers/toArray';
|
|
|
71
77
|
import '@bigbinary/neeto-molecules/PhoneNumber';
|
|
72
78
|
import '@bigbinary/neetoui/Tag';
|
|
73
79
|
import 'react-select';
|
|
74
|
-
import '
|
|
80
|
+
import './constants-DghBXpIM.js';
|
|
81
|
+
import '@bigbinary/neetoui/Radio';
|
|
75
82
|
import '@bigbinary/neeto-editor/utils';
|
|
76
|
-
import './constants-CB5HRjxq.js';
|
|
77
83
|
import '@bigbinary/neeto-icons/Eye';
|
|
78
|
-
import '@bigbinary/neetoui/Popover';
|
|
79
|
-
import '@bigbinary/neetoui/formik/Radio';
|
|
80
|
-
import '@bigbinary/neeto-icons/Help';
|
|
81
|
-
import '@babel/runtime/helpers/typeof';
|
|
82
84
|
import '@bigbinary/neeto-icons/Down';
|
|
85
|
+
import '@bigbinary/neetoui/Dropdown';
|
|
86
|
+
import '@bigbinary/neetoui/Tooltip';
|
|
87
|
+
import '@babel/runtime/helpers/typeof';
|
|
83
88
|
import '@bigbinary/neeto-icons/Up';
|
|
84
89
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { useQuery, keepPreviousData } from '@tanstack/react-query';
|
|
3
|
+
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
import { A as AUTOMATION_RULES, S as STALE_TIME } from './index-9h4B7JZZ.js';
|
|
7
|
+
|
|
8
|
+
var _excluded = ["url"];
|
|
9
|
+
var fetch = function fetch(_ref) {
|
|
10
|
+
var url = _ref.url,
|
|
11
|
+
params = _objectWithoutProperties(_ref, _excluded);
|
|
12
|
+
return axios.get(url, {
|
|
13
|
+
params: params
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var show = function show(_ref2) {
|
|
17
|
+
var url = _ref2.url,
|
|
18
|
+
id = _ref2.id;
|
|
19
|
+
return axios.get("".concat(url, "/").concat(id));
|
|
20
|
+
};
|
|
21
|
+
var update = function update(_ref3) {
|
|
22
|
+
var url = _ref3.url,
|
|
23
|
+
id = _ref3.id,
|
|
24
|
+
payload = _ref3.payload;
|
|
25
|
+
return axios.patch("".concat(url, "/").concat(id), payload);
|
|
26
|
+
};
|
|
27
|
+
var clone = function clone(_ref4) {
|
|
28
|
+
var url = _ref4.url,
|
|
29
|
+
id = _ref4.id;
|
|
30
|
+
return axios.post("".concat(url, "/").concat(id, "/clone"));
|
|
31
|
+
};
|
|
32
|
+
var destroy = function destroy(_ref5) {
|
|
33
|
+
var url = _ref5.url,
|
|
34
|
+
id = _ref5.id;
|
|
35
|
+
return axios["delete"]("".concat(url, "/").concat(id));
|
|
36
|
+
};
|
|
37
|
+
var reorder = function reorder(_ref6) {
|
|
38
|
+
var url = _ref6.url,
|
|
39
|
+
payload = _ref6.payload;
|
|
40
|
+
return axios.patch("".concat(url, "/reorder"), payload);
|
|
41
|
+
};
|
|
42
|
+
var automationRulesApi = {
|
|
43
|
+
fetch: fetch,
|
|
44
|
+
show: show,
|
|
45
|
+
update: update,
|
|
46
|
+
clone: clone,
|
|
47
|
+
destroy: destroy,
|
|
48
|
+
reorder: reorder
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function ownKeys(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; }
|
|
52
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
53
|
+
var useFetchAutomationRules = function useFetchAutomationRules(params) {
|
|
54
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
55
|
+
return useQuery(_objectSpread({
|
|
56
|
+
queryKey: [AUTOMATION_RULES, params.url, params],
|
|
57
|
+
queryFn: function queryFn() {
|
|
58
|
+
return automationRulesApi.fetch(params);
|
|
59
|
+
},
|
|
60
|
+
staleTime: STALE_TIME,
|
|
61
|
+
select: function select(response) {
|
|
62
|
+
return response.data || response;
|
|
63
|
+
},
|
|
64
|
+
placeholderData: keepPreviousData
|
|
65
|
+
}, options));
|
|
66
|
+
};
|
|
67
|
+
var useShowAutomationRule = function useShowAutomationRule(params) {
|
|
68
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
+
return useQuery(_objectSpread({
|
|
70
|
+
queryKey: [AUTOMATION_RULES, params.id, "show"],
|
|
71
|
+
queryFn: function queryFn() {
|
|
72
|
+
return automationRulesApi.show(params);
|
|
73
|
+
},
|
|
74
|
+
select: function select(response) {
|
|
75
|
+
return response.data || response;
|
|
76
|
+
}
|
|
77
|
+
}, options));
|
|
78
|
+
};
|
|
79
|
+
var useUpdateAutomationRule = function useUpdateAutomationRule(url) {
|
|
80
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
81
|
+
return useMutationWithInvalidation(automationRulesApi.update, _objectSpread({
|
|
82
|
+
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
83
|
+
}, options));
|
|
84
|
+
};
|
|
85
|
+
var useCloneAutomationRule = function useCloneAutomationRule(url) {
|
|
86
|
+
return useMutationWithInvalidation(automationRulesApi.clone, {
|
|
87
|
+
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
var useDeleteAutomationRule = function useDeleteAutomationRule(url) {
|
|
91
|
+
return useMutationWithInvalidation(automationRulesApi.destroy, {
|
|
92
|
+
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
var useReorderAutomationRules = function useReorderAutomationRules(url) {
|
|
96
|
+
return useMutationWithInvalidation(automationRulesApi.reorder, {
|
|
97
|
+
keysToInvalidate: [[AUTOMATION_RULES, url]]
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { useReorderAutomationRules as a, useUpdateAutomationRule as b, useCloneAutomationRule as c, useDeleteAutomationRule as d, useShowAutomationRule as e, useFetchAutomationRules as u };
|
|
102
|
+
//# sourceMappingURL=useAutomationRulesApi-CVgffrQW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutomationRulesApi-CVgffrQW.js","sources":["../app/javascript/src/apis/automation_rules.js","../app/javascript/src/hooks/reactQuery/useAutomationRulesApi.js"],"sourcesContent":["import axios from \"axios\";\n\nconst fetch = ({ url, ...params }) => axios.get(url, { params });\n\nconst show = ({ url, id }) => axios.get(`${url}/${id}`);\n\nconst update = ({ url, id, payload }) => axios.patch(`${url}/${id}`, payload);\n\nconst clone = ({ url, id }) => axios.post(`${url}/${id}/clone`);\n\nconst destroy = ({ url, id }) => axios.delete(`${url}/${id}`);\n\nconst reorder = ({ url, payload }) => axios.patch(`${url}/reorder`, payload);\n\nconst automationRulesApi = {\n fetch,\n show,\n update,\n clone,\n destroy,\n reorder,\n};\n\nexport default automationRulesApi;\n","import { keepPreviousData, useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport automationRulesApi from \"apis/automation_rules\";\nimport { AUTOMATION_RULES, STALE_TIME } from \"common/constants\";\n\nconst useFetchAutomationRules = (params, options = {}) =>\n useQuery({\n queryKey: [AUTOMATION_RULES, params.url, params],\n queryFn: () => automationRulesApi.fetch(params),\n staleTime: STALE_TIME,\n select: response => response.data || response,\n placeholderData: keepPreviousData,\n ...options,\n });\n\nconst useShowAutomationRule = (params, options = {}) =>\n useQuery({\n queryKey: [AUTOMATION_RULES, params.id, \"show\"],\n queryFn: () => automationRulesApi.show(params),\n select: response => response.data || response,\n ...options,\n });\n\nconst useUpdateAutomationRule = (url, options = {}) =>\n useMutationWithInvalidation(automationRulesApi.update, {\n keysToInvalidate: [[AUTOMATION_RULES, url]],\n ...options,\n });\n\nconst useCloneAutomationRule = url =>\n useMutationWithInvalidation(automationRulesApi.clone, {\n keysToInvalidate: [[AUTOMATION_RULES, url]],\n });\n\nconst useDeleteAutomationRule = url =>\n useMutationWithInvalidation(automationRulesApi.destroy, {\n keysToInvalidate: [[AUTOMATION_RULES, url]],\n });\n\nconst useReorderAutomationRules = url =>\n useMutationWithInvalidation(automationRulesApi.reorder, {\n keysToInvalidate: [[AUTOMATION_RULES, url]],\n });\nexport {\n useFetchAutomationRules,\n useShowAutomationRule,\n useUpdateAutomationRule,\n useCloneAutomationRule,\n useDeleteAutomationRule,\n useReorderAutomationRules,\n};\n"],"names":["fetch","_ref","url","params","_objectWithoutProperties","_excluded","axios","get","show","_ref2","id","concat","update","_ref3","payload","patch","clone","_ref4","post","destroy","_ref5","reorder","_ref6","automationRulesApi","useFetchAutomationRules","options","arguments","length","undefined","useQuery","_objectSpread","queryKey","AUTOMATION_RULES","queryFn","staleTime","STALE_TIME","select","response","data","placeholderData","keepPreviousData","useShowAutomationRule","useUpdateAutomationRule","useMutationWithInvalidation","keysToInvalidate","useCloneAutomationRule","useDeleteAutomationRule","useReorderAutomationRules"],"mappings":";;;;;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAKA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAMC,GAAG,GAAAD,IAAA,CAAHC,GAAG;AAAKC,IAAAA,MAAM,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA;AAAA,EAAA,OAAO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