@bigbinary/neeto-rules-frontend 2.5.15-beta-3 → 2.5.15-beta-5
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/app/javascript/src/translations/en.json +9 -4
- package/dist/NeetoRulesForm.js +242 -35
- package/dist/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/NeetoRulesForm.js +240 -33
- package/dist/cjs/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
|
@@ -168,8 +168,6 @@
|
|
|
168
168
|
"endpoint": "Endpoint",
|
|
169
169
|
"key": "Key",
|
|
170
170
|
"value": "Value",
|
|
171
|
-
"addKeyValuePair": "Add new key value pair",
|
|
172
|
-
"additionalData": "Additional data",
|
|
173
171
|
"remove_tags": "Remove tags",
|
|
174
172
|
"add_tags": "Add tags",
|
|
175
173
|
"change_status": "Change status",
|
|
@@ -178,7 +176,10 @@
|
|
|
178
176
|
"assign_group": "Assign {{taxonomies.group.singular}}",
|
|
179
177
|
"assign_agent": "Assign {{taxonomies.agent.singular}}",
|
|
180
178
|
"change_priority": "Change priority",
|
|
181
|
-
"selectCannedResponse": "Select a canned response"
|
|
179
|
+
"selectCannedResponse": "Select a canned response",
|
|
180
|
+
"headers": "Headers",
|
|
181
|
+
"includeHeaders": "Include headers",
|
|
182
|
+
"addEntity": "Add {{entity}}"
|
|
182
183
|
},
|
|
183
184
|
"placeholders": {
|
|
184
185
|
"if": "If",
|
|
@@ -242,7 +243,8 @@
|
|
|
242
243
|
"invalidUrlEntity": "{{entity}} must be a valid URL",
|
|
243
244
|
"maximumEmails": "Only up to {{max}} email addresses are allowed",
|
|
244
245
|
"maxDelay": "Delay can't be more than {{max}}",
|
|
245
|
-
"minDelay": "Delay can't be less than {{min}}"
|
|
246
|
+
"minDelay": "Delay can't be less than {{min}}",
|
|
247
|
+
"invalidJsonBody": "Body should be a valid JSON"
|
|
246
248
|
},
|
|
247
249
|
"conditionVerbs": {
|
|
248
250
|
"is": "Is",
|
|
@@ -373,6 +375,9 @@
|
|
|
373
375
|
"helpText": {
|
|
374
376
|
"description": "Automation rules feature allows you to create rules to automate specific actions when certain events occur.",
|
|
375
377
|
"addDelay": "Add a delay so the following actions execute after the specified time"
|
|
378
|
+
},
|
|
379
|
+
"apiFields": {
|
|
380
|
+
"insertPlaceholder": "Insert placeholder: {{label}}"
|
|
376
381
|
}
|
|
377
382
|
}
|
|
378
383
|
}
|
package/dist/NeetoRulesForm.js
CHANGED
|
@@ -3,9 +3,9 @@ import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructurin
|
|
|
3
3
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
5
|
import { shallow } from 'zustand/shallow';
|
|
6
|
-
import { useRef, useEffect, createElement,
|
|
6
|
+
import { useRef, useEffect, createElement, forwardRef, useState, useMemo, memo, Fragment as Fragment$1 } from 'react';
|
|
7
7
|
import { useFormikContext, useField, FieldArray, ErrorMessage, Formik, Form as Form$1 } from 'formik';
|
|
8
|
-
import { findBy, isNotEmpty, isPresent, renameKeys, nullSafe, noop, toLabelAndValue, removeBy } from '@bigbinary/neeto-cist';
|
|
8
|
+
import { findBy, isNotEmpty, isPresent, hyphenate, renameKeys, nullSafe, noop, toLabelAndValue, removeBy, isNotPresent } from '@bigbinary/neeto-cist';
|
|
9
9
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
10
10
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
11
11
|
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
@@ -24,7 +24,10 @@ import { t as t$1 } from 'i18next';
|
|
|
24
24
|
import Left from '@bigbinary/neeto-icons/Left';
|
|
25
25
|
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
26
26
|
import Input$1 from '@bigbinary/neetoui/formik/Input';
|
|
27
|
+
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
27
28
|
import { withT, useStateWithDependency, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
29
|
+
import Editor from '@monaco-editor/react';
|
|
30
|
+
import DynamicVariables from '@bigbinary/neeto-molecules/DynamicVariables';
|
|
28
31
|
import Label from '@bigbinary/neetoui/Label';
|
|
29
32
|
import Select from '@bigbinary/neetoui/Select';
|
|
30
33
|
import { dayjs, joinHyphenCase, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
@@ -56,14 +59,14 @@ import Container from '@bigbinary/neeto-molecules/Container';
|
|
|
56
59
|
import NeetoHeader from '@bigbinary/neeto-molecules/Header';
|
|
57
60
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
58
61
|
import Help from '@bigbinary/neeto-icons/Help';
|
|
59
|
-
import Switch from '@bigbinary/neetoui/Switch';
|
|
62
|
+
import Switch$1 from '@bigbinary/neetoui/Switch';
|
|
60
63
|
import { u as useCustomDataStore } from './useCustomDataStore-B1qHMIGJ.js';
|
|
61
64
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
62
65
|
import 'zustand';
|
|
63
66
|
|
|
64
67
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
65
68
|
|
|
66
|
-
var css = ".neeto-filters-error-boundary{align-items:center;background-color:rgb(var(--neeto-ui-gray-100));border-radius:var(--neeto-ui-rounded-sm);display:flex;gap:1rem;margin-bottom:.75rem;padding:.5rem 1.25rem}.neeto-filters-error-boundary p{color:rgb(var(--neeto-ui-gray-800))}.neeto-rules-main-content__container{height:100dvh!important}.neeto-rules-main-card .neeto-ui-btn.underline{text-align:left}.neeto-rules-side-panel{flex-grow:0;flex-shrink:0}.neeto-rules-side-panel--small{width:320px}@media (min-width:1024px){.neeto-rules-side-panel--small{width:380px}}.neeto-rules-side-panel--large{width:380px}@media (min-width:1024px){.neeto-rules-side-panel--large{width:480px}}\n/*# sourceMappingURL=data:application/json;base64,
|
|
69
|
+
var css = ".neeto-filters-error-boundary{align-items:center;background-color:rgb(var(--neeto-ui-gray-100));border-radius:var(--neeto-ui-rounded-sm);display:flex;gap:1rem;margin-bottom:.75rem;padding:.5rem 1.25rem}.neeto-filters-error-boundary p{color:rgb(var(--neeto-ui-gray-800))}.neeto-rules-main-content__container{height:100dvh!important}.neeto-rules-main-card .neeto-ui-btn.underline{text-align:left}.neeto-rules-side-panel{flex-grow:0;flex-shrink:0}.neeto-rules-side-panel--small{width:320px}@media (min-width:1024px){.neeto-rules-side-panel--small{width:380px}}.neeto-rules-side-panel--large{width:380px}@media (min-width:1024px){.neeto-rules-side-panel--large{width:480px}}.neeto-rules-json-editor__wrapper{height:35vh;position:relative}.neeto-rules-json-editor__editor{height:100%}.neeto-rules-json-editor__dynamic-variables{position:absolute;right:1rem;top:1rem;z-index:10}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19lcnJvci1ib3VuZGFyeS5zY3NzIiwiYXBwL2phdmFzY3JpcHQvc3JjL3N0eWxlc2hlZXRzL21haW4uc2NzcyIsImFwcC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ge1xuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgICBoZWlnaHQ6IDM1dmg7XG4gIH1cblxuICAmX19lZGl0b3Ige1xuICAgIGhlaWdodDogMTAwJTtcbiAgfVxuXG4gICZfX2R5bmFtaWMtdmFyaWFibGVzIHtcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgdG9wOiAxcmVtO1xuICAgIHJpZ2h0OiAxcmVtO1xuICAgIHotaW5kZXg6IDEwO1xuICB9XG59XG4iXX0= */";
|
|
67
70
|
n(css,{});
|
|
68
71
|
|
|
69
72
|
var useActiveField = function useActiveField(name) {
|
|
@@ -89,7 +92,7 @@ var useActiveField = function useActiveField(name) {
|
|
|
89
92
|
useEffect(function () {
|
|
90
93
|
if (!shouldAutoFocus || activeField) return;
|
|
91
94
|
setFieldActive();
|
|
92
|
-
}, []);
|
|
95
|
+
}, [name]);
|
|
93
96
|
useEffect(function () {
|
|
94
97
|
var shouldFocus = shouldFocusRef.current;
|
|
95
98
|
shouldFocusRef.current = true;
|
|
@@ -104,10 +107,12 @@ var useActiveField = function useActiveField(name) {
|
|
|
104
107
|
shouldFocusRef.current = !ref.current;
|
|
105
108
|
if (needsRerender) {
|
|
106
109
|
setPanelState(assocPath(["data", "activeField"], null));
|
|
110
|
+
requestAnimationFrame(function () {
|
|
111
|
+
return setPanelState(assocPath(["data", "activeField"], name));
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
setPanelState(assocPath(["data", "activeField"], name));
|
|
107
115
|
}
|
|
108
|
-
requestAnimationFrame(function () {
|
|
109
|
-
return setPanelState(assocPath(["data", "activeField"], name));
|
|
110
|
-
});
|
|
111
116
|
};
|
|
112
117
|
var resetActiveField = function resetActiveField() {
|
|
113
118
|
return setPanelState(assocPath(["data", "activeField"], null));
|
|
@@ -553,14 +558,27 @@ var LongTextField = function LongTextField(_ref2) {
|
|
|
553
558
|
};
|
|
554
559
|
LongTextField.Target = Target$j;
|
|
555
560
|
|
|
556
|
-
var
|
|
561
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
557
562
|
key: "",
|
|
558
563
|
value: ""
|
|
559
564
|
};
|
|
560
565
|
var SAMPLE_ENDPOINT = "https://example.com";
|
|
566
|
+
var JSON_LANGUAGE = "json";
|
|
567
|
+
var EDITOR_CONFIG = {
|
|
568
|
+
formatOnType: true,
|
|
569
|
+
formatOnPaste: true,
|
|
570
|
+
automaticLayout: true,
|
|
571
|
+
tabSize: 2,
|
|
572
|
+
minimap: {
|
|
573
|
+
enabled: false
|
|
574
|
+
},
|
|
575
|
+
scrollBeyondLastLine: false,
|
|
576
|
+
autoIndent: "full"
|
|
577
|
+
};
|
|
578
|
+
var API_REQUEST_FIELDS = ["endpoint", "body", "enableCustomHeaders", "customHeaders"];
|
|
561
579
|
|
|
562
580
|
var addOption = function addOption(arrayHelpers) {
|
|
563
|
-
return arrayHelpers.push(
|
|
581
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
564
582
|
};
|
|
565
583
|
var removeOption = function removeOption(_ref) {
|
|
566
584
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -575,8 +593,8 @@ var hasKeyOrValue = whereAny({
|
|
|
575
593
|
key: isNotEmpty,
|
|
576
594
|
value: isNotEmpty
|
|
577
595
|
});
|
|
578
|
-
var
|
|
579
|
-
return isPresent(
|
|
596
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
597
|
+
return isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
580
598
|
};
|
|
581
599
|
|
|
582
600
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -585,30 +603,27 @@ var dotPath = useWith(path, [split(".")]);
|
|
|
585
603
|
var KeyValuePairsField = withT(function (_ref) {
|
|
586
604
|
var t = _ref.t,
|
|
587
605
|
name = _ref.name,
|
|
588
|
-
|
|
589
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
606
|
+
entity = _ref.entity,
|
|
590
607
|
onFocus = _ref.onFocus;
|
|
591
608
|
return /*#__PURE__*/jsx(FieldArray, {
|
|
592
609
|
name: name,
|
|
593
610
|
children: function children(arrayHelpers) {
|
|
594
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
611
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
595
612
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
596
613
|
return /*#__PURE__*/jsxs("div", {
|
|
597
|
-
className: "space-y-3",
|
|
598
|
-
children: [
|
|
599
|
-
children: label
|
|
600
|
-
}), data.map(function (_, index) {
|
|
614
|
+
className: "flex flex-col space-y-3",
|
|
615
|
+
children: [data.map(function (_, index) {
|
|
601
616
|
return /*#__PURE__*/jsxs("div", {
|
|
602
617
|
className: "flex h-8 space-x-3",
|
|
603
618
|
children: [/*#__PURE__*/jsx(Input$1, {
|
|
604
619
|
onFocus: onFocus,
|
|
605
|
-
className: "w-
|
|
620
|
+
className: "w-1/3",
|
|
606
621
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
607
622
|
placeholder: t("neetoRules.labels.key"),
|
|
608
623
|
type: "text"
|
|
609
624
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
610
625
|
onFocus: onFocus,
|
|
611
|
-
className: "w-3
|
|
626
|
+
className: "w-2/3",
|
|
612
627
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
613
628
|
placeholder: t("neetoRules.labels.value"),
|
|
614
629
|
type: "text",
|
|
@@ -628,7 +643,10 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
628
643
|
}, index);
|
|
629
644
|
}), /*#__PURE__*/jsx(Button, {
|
|
630
645
|
onFocus: onFocus,
|
|
631
|
-
|
|
646
|
+
className: "w-30 ml-auto",
|
|
647
|
+
label: t("neetoRules.labels.addEntity", {
|
|
648
|
+
entity: entity
|
|
649
|
+
}),
|
|
632
650
|
style: "secondary",
|
|
633
651
|
onClick: function onClick() {
|
|
634
652
|
return addOption(arrayHelpers);
|
|
@@ -639,6 +657,167 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
639
657
|
});
|
|
640
658
|
});
|
|
641
659
|
|
|
660
|
+
var CustomHeaders = function CustomHeaders(_ref) {
|
|
661
|
+
var name = _ref.name,
|
|
662
|
+
onFocus = _ref.onFocus;
|
|
663
|
+
var _useFormikContext = useFormikContext(),
|
|
664
|
+
values = _useFormikContext.values,
|
|
665
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
666
|
+
var _useTranslation = useTranslation(),
|
|
667
|
+
t = _useTranslation.t;
|
|
668
|
+
var switchName = "".concat(name, ".enableCustomHeaders");
|
|
669
|
+
var keyValuePairsFieldName = "".concat(name, ".customHeaders");
|
|
670
|
+
var isCustomHeadersEnabled = dotPath(switchName, values);
|
|
671
|
+
var handleChange = function handleChange(_ref2) {
|
|
672
|
+
var checked = _ref2.target.checked;
|
|
673
|
+
if (!checked) {
|
|
674
|
+
setFieldValue(keyValuePairsFieldName, [CUSTOM_HEADERS_INITIAL_VALUE]);
|
|
675
|
+
}
|
|
676
|
+
setFieldValue(switchName, checked);
|
|
677
|
+
};
|
|
678
|
+
var label = t("neetoRules.labels.includeHeaders");
|
|
679
|
+
return /*#__PURE__*/jsxs("div", {
|
|
680
|
+
className: "flex flex-col space-y-4 mb-4",
|
|
681
|
+
children: [/*#__PURE__*/jsx(Switch, {
|
|
682
|
+
label: label,
|
|
683
|
+
onFocus: onFocus,
|
|
684
|
+
"data-cy": "neeto-rules-api-fields-".concat(hyphenate(label), "-switch"),
|
|
685
|
+
name: switchName,
|
|
686
|
+
onChange: handleChange
|
|
687
|
+
}), isCustomHeadersEnabled && /*#__PURE__*/jsx(KeyValuePairsField, {
|
|
688
|
+
onFocus: onFocus,
|
|
689
|
+
entity: t("neetoRules.labels.headers"),
|
|
690
|
+
name: "".concat(name, ".customHeaders")
|
|
691
|
+
})]
|
|
692
|
+
});
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
var JsonEditor = function JsonEditor(_ref) {
|
|
696
|
+
var name = _ref.name,
|
|
697
|
+
onFocus = _ref.onFocus,
|
|
698
|
+
_ref$initialValue = _ref.initialValue,
|
|
699
|
+
initialValue = _ref$initialValue === void 0 ? "{}" : _ref$initialValue,
|
|
700
|
+
_ref$variables = _ref.variables,
|
|
701
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables;
|
|
702
|
+
var editorRef = useRef(null);
|
|
703
|
+
var completionProviderRef = useRef(null);
|
|
704
|
+
var _useField = useField(name),
|
|
705
|
+
_useField2 = _slicedToArray(_useField, 3);
|
|
706
|
+
_useField2[0];
|
|
707
|
+
var _useField2$ = _useField2[1],
|
|
708
|
+
touched = _useField2$.touched,
|
|
709
|
+
error = _useField2$.error,
|
|
710
|
+
_useField2$2 = _useField2[2],
|
|
711
|
+
setValue = _useField2$2.setValue,
|
|
712
|
+
setTouched = _useField2$2.setTouched;
|
|
713
|
+
var _useTranslation = useTranslation(),
|
|
714
|
+
t = _useTranslation.t;
|
|
715
|
+
var handleEditorDidMount = function handleEditorDidMount(editor, monaco) {
|
|
716
|
+
editorRef.current = editor;
|
|
717
|
+
completionProviderRef.current = monaco.languages.registerCompletionItemProvider(JSON_LANGUAGE, {
|
|
718
|
+
triggerCharacters: ["{"],
|
|
719
|
+
provideCompletionItems: function provideCompletionItems(model, position) {
|
|
720
|
+
var lineContent = model.getLineContent(position.lineNumber);
|
|
721
|
+
var beforeCursor = lineContent.slice(0, position.column - 1);
|
|
722
|
+
if (!beforeCursor.endsWith('"{')) {
|
|
723
|
+
return {
|
|
724
|
+
suggestions: []
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
var suggestions = variables.map(function (_ref2) {
|
|
728
|
+
var key = _ref2.key,
|
|
729
|
+
label = _ref2.label;
|
|
730
|
+
return {
|
|
731
|
+
label: label,
|
|
732
|
+
kind: monaco.languages.CompletionItemKind.Variable,
|
|
733
|
+
insertText: "{".concat(key, "}}"),
|
|
734
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
735
|
+
detail: t("neetoRules.apiFields.insertPlaceholder", {
|
|
736
|
+
label: label
|
|
737
|
+
})
|
|
738
|
+
};
|
|
739
|
+
});
|
|
740
|
+
return {
|
|
741
|
+
suggestions: suggestions
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
};
|
|
746
|
+
var insertVariable = function insertVariable(_ref3) {
|
|
747
|
+
var key = _ref3.key;
|
|
748
|
+
var editor = editorRef.current;
|
|
749
|
+
if (!editor) return;
|
|
750
|
+
var selection = editor.getSelection();
|
|
751
|
+
var range = {
|
|
752
|
+
startLineNumber: selection.startLineNumber,
|
|
753
|
+
startColumn: selection.startColumn,
|
|
754
|
+
endLineNumber: selection.endLineNumber,
|
|
755
|
+
endColumn: selection.endColumn
|
|
756
|
+
};
|
|
757
|
+
var text = "\"{{".concat(key, "}}\"");
|
|
758
|
+
editor.executeEdits("", [{
|
|
759
|
+
range: range,
|
|
760
|
+
text: text,
|
|
761
|
+
forceMoveMarkers: true
|
|
762
|
+
}]);
|
|
763
|
+
var position = editor.getPosition();
|
|
764
|
+
editor.setPosition({
|
|
765
|
+
lineNumber: position.lineNumber,
|
|
766
|
+
column: position.column + text.length
|
|
767
|
+
});
|
|
768
|
+
editor.focus();
|
|
769
|
+
};
|
|
770
|
+
var handleChange = function handleChange(value) {
|
|
771
|
+
setTouched(true);
|
|
772
|
+
setValue(value);
|
|
773
|
+
};
|
|
774
|
+
useEffect(function () {
|
|
775
|
+
var editor = editorRef.current;
|
|
776
|
+
if (!editor) return;
|
|
777
|
+
var currentValue = editor.getValue();
|
|
778
|
+
if (currentValue !== initialValue) {
|
|
779
|
+
editor.setValue(initialValue);
|
|
780
|
+
}
|
|
781
|
+
}, [initialValue]);
|
|
782
|
+
useEffect(function () {
|
|
783
|
+
return function () {
|
|
784
|
+
var _completionProviderRe;
|
|
785
|
+
(_completionProviderRe = completionProviderRef.current) === null || _completionProviderRe === void 0 || _completionProviderRe.dispose();
|
|
786
|
+
completionProviderRef.current = null;
|
|
787
|
+
};
|
|
788
|
+
}, []);
|
|
789
|
+
return /*#__PURE__*/jsxs("div", {
|
|
790
|
+
className: "space-y-2 mb-2",
|
|
791
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
792
|
+
required: true,
|
|
793
|
+
"data-cy": "api-field-body",
|
|
794
|
+
children: t("neetoRules.labels.body")
|
|
795
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
796
|
+
className: "neeto-rules-json-editor__wrapper",
|
|
797
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
798
|
+
className: "neeto-rules-json-editor__dynamic-variables",
|
|
799
|
+
children: /*#__PURE__*/jsx(DynamicVariables, {
|
|
800
|
+
variables: variables,
|
|
801
|
+
onVariableClick: insertVariable
|
|
802
|
+
})
|
|
803
|
+
}), /*#__PURE__*/jsx(Editor, {
|
|
804
|
+
onFocus: onFocus,
|
|
805
|
+
className: "neeto-rules-json-editor__editor",
|
|
806
|
+
defaultLanguage: JSON_LANGUAGE,
|
|
807
|
+
defaultValue: initialValue,
|
|
808
|
+
height: "100%",
|
|
809
|
+
options: EDITOR_CONFIG,
|
|
810
|
+
theme: "vs-dark",
|
|
811
|
+
onChange: handleChange,
|
|
812
|
+
onMount: handleEditorDidMount
|
|
813
|
+
}), error && touched && /*#__PURE__*/jsx("div", {
|
|
814
|
+
className: "neeto-ui-input__error",
|
|
815
|
+
children: error
|
|
816
|
+
})]
|
|
817
|
+
})]
|
|
818
|
+
});
|
|
819
|
+
};
|
|
820
|
+
|
|
642
821
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
643
822
|
var selectedField = _ref.selectedField,
|
|
644
823
|
templates = _ref.templates,
|
|
@@ -725,7 +904,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
725
904
|
var _useTranslation2 = useTranslation(),
|
|
726
905
|
t = _useTranslation2.t;
|
|
727
906
|
var _useFormikContext = useFormikContext(),
|
|
728
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
907
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
908
|
+
values = _useFormikContext.values;
|
|
729
909
|
var _useActiveField2 = useActiveField(name, {
|
|
730
910
|
shouldAutoFocus: shouldAutoFocus
|
|
731
911
|
}),
|
|
@@ -734,8 +914,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
734
914
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
735
915
|
var isTemplateSelectionEnabled = isPresent(templates);
|
|
736
916
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
737
|
-
|
|
738
|
-
|
|
917
|
+
API_REQUEST_FIELDS.forEach(function (key) {
|
|
918
|
+
var value = key === "customHeaders" ? formatCustomFields(template[key]) : template[key];
|
|
919
|
+
setFieldValue("".concat(name, ".").concat(key), value);
|
|
920
|
+
});
|
|
739
921
|
};
|
|
740
922
|
return /*#__PURE__*/jsxs("div", {
|
|
741
923
|
className: "w-full",
|
|
@@ -755,9 +937,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
755
937
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
756
938
|
type: "text",
|
|
757
939
|
onFocus: setFieldActive
|
|
758
|
-
}), /*#__PURE__*/jsx(
|
|
759
|
-
|
|
760
|
-
|
|
940
|
+
}), /*#__PURE__*/jsx(CustomHeaders, {
|
|
941
|
+
name: name,
|
|
942
|
+
onFocus: setFieldActive
|
|
943
|
+
}), /*#__PURE__*/jsx(JsonEditor, {
|
|
944
|
+
initialValue: dotPath("".concat(name, ".body"), values),
|
|
945
|
+
name: "".concat(name, ".body"),
|
|
946
|
+
variables: selectedField === null || selectedField === void 0 ? void 0 : selectedField.variables,
|
|
761
947
|
onFocus: setFieldActive
|
|
762
948
|
})]
|
|
763
949
|
});
|
|
@@ -947,17 +1133,17 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
947
1133
|
editorRef = _ref$editorRef === void 0 ? null : _ref$editorRef,
|
|
948
1134
|
defaults = _ref.defaults,
|
|
949
1135
|
otherProps = _objectWithoutProperties(_ref, _excluded$d);
|
|
950
|
-
var
|
|
951
|
-
|
|
952
|
-
editorData =
|
|
953
|
-
setEditorData =
|
|
1136
|
+
var _useStateWithDependen = useStateWithDependency(value, [name]),
|
|
1137
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
1138
|
+
editorData = _useStateWithDependen2[0],
|
|
1139
|
+
setEditorData = _useStateWithDependen2[1];
|
|
954
1140
|
var _useFormikContext = useFormikContext(),
|
|
955
1141
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
956
1142
|
var debouncedValue = useDebounce(editorData, 200);
|
|
957
1143
|
useEffect(function () {
|
|
958
1144
|
setFieldValue(name, editorData);
|
|
959
1145
|
}, [debouncedValue]);
|
|
960
|
-
return /*#__PURE__*/
|
|
1146
|
+
return /*#__PURE__*/createElement(FormikEditor, _objectSpread$n({
|
|
961
1147
|
addons: addons,
|
|
962
1148
|
autoFocus: autoFocus,
|
|
963
1149
|
defaults: defaults,
|
|
@@ -967,6 +1153,7 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
967
1153
|
hideSlashCommands: true,
|
|
968
1154
|
className: "w-full",
|
|
969
1155
|
"data-cy": "neeto-editor",
|
|
1156
|
+
key: name,
|
|
970
1157
|
ref: editorRef,
|
|
971
1158
|
onChange: setEditorData
|
|
972
1159
|
}, otherProps));
|
|
@@ -4332,7 +4519,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4332
4519
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4333
4520
|
})).required(t$1("neetoRules.validations.required.entity", {
|
|
4334
4521
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4335
|
-
}))
|
|
4522
|
+
})),
|
|
4523
|
+
body: yup.string().trim().required(t$1("neetoRules.validations.required.entity", {
|
|
4524
|
+
entity: t$1("neetoRules.labels.body")
|
|
4525
|
+
})).test("is-valid-json-and-not-empty", function (value, context) {
|
|
4526
|
+
if (!value) return true;
|
|
4527
|
+
try {
|
|
4528
|
+
var parsedValue = JSON.parse(value);
|
|
4529
|
+
if (isNotPresent(parsedValue)) {
|
|
4530
|
+
return context.createError({
|
|
4531
|
+
message: t$1("neetoRules.validations.required.entity", {
|
|
4532
|
+
entity: t$1("neetoRules.labels.body")
|
|
4533
|
+
})
|
|
4534
|
+
});
|
|
4535
|
+
}
|
|
4536
|
+
return true;
|
|
4537
|
+
} catch (_unused) {
|
|
4538
|
+
return context.createError({
|
|
4539
|
+
message: t$1("neetoRules.validations.invalidJsonBody")
|
|
4540
|
+
});
|
|
4541
|
+
}
|
|
4542
|
+
})
|
|
4336
4543
|
});
|
|
4337
4544
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4338
4545
|
return yup.object({
|
|
@@ -5669,7 +5876,7 @@ var Status = function Status() {
|
|
|
5669
5876
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5670
5877
|
setFieldValue("status.value", status);
|
|
5671
5878
|
};
|
|
5672
|
-
return /*#__PURE__*/jsx(Switch, {
|
|
5879
|
+
return /*#__PURE__*/jsx(Switch$1, {
|
|
5673
5880
|
checked: defaultValue === ENABLED,
|
|
5674
5881
|
label: t("neetoRules.labels.active"),
|
|
5675
5882
|
labelProps: {
|