@bigbinary/neeto-rules-frontend 2.5.15-beta-4 → 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 +229 -25
- package/dist/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/NeetoRulesForm.js +228 -24
- 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
|
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
5
5
|
import { shallow } from 'zustand/shallow';
|
|
6
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19lcnJvci1ib3VuZGFyeS5zY3NzIiwiYXBwL2phdmFzY3JpcHQvc3JjL3N0eWxlc2hlZXRzL21haW4uc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19sYXlvdXQuc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21w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fVxuXG4gICZfX2R5bmFtaWMtdmFyaWFibGVzIHtcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgdG9wOiAxcmVtO1xuICAgIHJpZ2h0OiAxcmVtO1xuICAgIHotaW5kZXg6IDEwO1xuICB9XG59XG4iXX0= */";
|
|
67
70
|
n(css,{});
|
|
68
71
|
|
|
69
72
|
var useActiveField = function useActiveField(name) {
|
|
@@ -555,14 +558,27 @@ var LongTextField = function LongTextField(_ref2) {
|
|
|
555
558
|
};
|
|
556
559
|
LongTextField.Target = Target$j;
|
|
557
560
|
|
|
558
|
-
var
|
|
561
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
559
562
|
key: "",
|
|
560
563
|
value: ""
|
|
561
564
|
};
|
|
562
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"];
|
|
563
579
|
|
|
564
580
|
var addOption = function addOption(arrayHelpers) {
|
|
565
|
-
return arrayHelpers.push(
|
|
581
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
566
582
|
};
|
|
567
583
|
var removeOption = function removeOption(_ref) {
|
|
568
584
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -577,8 +593,8 @@ var hasKeyOrValue = whereAny({
|
|
|
577
593
|
key: isNotEmpty,
|
|
578
594
|
value: isNotEmpty
|
|
579
595
|
});
|
|
580
|
-
var
|
|
581
|
-
return isPresent(
|
|
596
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
597
|
+
return isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
582
598
|
};
|
|
583
599
|
|
|
584
600
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -587,30 +603,27 @@ var dotPath = useWith(path, [split(".")]);
|
|
|
587
603
|
var KeyValuePairsField = withT(function (_ref) {
|
|
588
604
|
var t = _ref.t,
|
|
589
605
|
name = _ref.name,
|
|
590
|
-
|
|
591
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
606
|
+
entity = _ref.entity,
|
|
592
607
|
onFocus = _ref.onFocus;
|
|
593
608
|
return /*#__PURE__*/jsx(FieldArray, {
|
|
594
609
|
name: name,
|
|
595
610
|
children: function children(arrayHelpers) {
|
|
596
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
611
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
597
612
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
598
613
|
return /*#__PURE__*/jsxs("div", {
|
|
599
|
-
className: "space-y-3",
|
|
600
|
-
children: [
|
|
601
|
-
children: label
|
|
602
|
-
}), data.map(function (_, index) {
|
|
614
|
+
className: "flex flex-col space-y-3",
|
|
615
|
+
children: [data.map(function (_, index) {
|
|
603
616
|
return /*#__PURE__*/jsxs("div", {
|
|
604
617
|
className: "flex h-8 space-x-3",
|
|
605
618
|
children: [/*#__PURE__*/jsx(Input$1, {
|
|
606
619
|
onFocus: onFocus,
|
|
607
|
-
className: "w-
|
|
620
|
+
className: "w-1/3",
|
|
608
621
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
609
622
|
placeholder: t("neetoRules.labels.key"),
|
|
610
623
|
type: "text"
|
|
611
624
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
612
625
|
onFocus: onFocus,
|
|
613
|
-
className: "w-3
|
|
626
|
+
className: "w-2/3",
|
|
614
627
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
615
628
|
placeholder: t("neetoRules.labels.value"),
|
|
616
629
|
type: "text",
|
|
@@ -630,7 +643,10 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
630
643
|
}, index);
|
|
631
644
|
}), /*#__PURE__*/jsx(Button, {
|
|
632
645
|
onFocus: onFocus,
|
|
633
|
-
|
|
646
|
+
className: "w-30 ml-auto",
|
|
647
|
+
label: t("neetoRules.labels.addEntity", {
|
|
648
|
+
entity: entity
|
|
649
|
+
}),
|
|
634
650
|
style: "secondary",
|
|
635
651
|
onClick: function onClick() {
|
|
636
652
|
return addOption(arrayHelpers);
|
|
@@ -641,6 +657,167 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
641
657
|
});
|
|
642
658
|
});
|
|
643
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
|
+
|
|
644
821
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
645
822
|
var selectedField = _ref.selectedField,
|
|
646
823
|
templates = _ref.templates,
|
|
@@ -727,7 +904,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
727
904
|
var _useTranslation2 = useTranslation(),
|
|
728
905
|
t = _useTranslation2.t;
|
|
729
906
|
var _useFormikContext = useFormikContext(),
|
|
730
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
907
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
908
|
+
values = _useFormikContext.values;
|
|
731
909
|
var _useActiveField2 = useActiveField(name, {
|
|
732
910
|
shouldAutoFocus: shouldAutoFocus
|
|
733
911
|
}),
|
|
@@ -736,8 +914,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
736
914
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
737
915
|
var isTemplateSelectionEnabled = isPresent(templates);
|
|
738
916
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
739
|
-
|
|
740
|
-
|
|
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
|
+
});
|
|
741
921
|
};
|
|
742
922
|
return /*#__PURE__*/jsxs("div", {
|
|
743
923
|
className: "w-full",
|
|
@@ -757,9 +937,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
757
937
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
758
938
|
type: "text",
|
|
759
939
|
onFocus: setFieldActive
|
|
760
|
-
}), /*#__PURE__*/jsx(
|
|
761
|
-
|
|
762
|
-
|
|
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,
|
|
763
947
|
onFocus: setFieldActive
|
|
764
948
|
})]
|
|
765
949
|
});
|
|
@@ -4335,7 +4519,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4335
4519
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4336
4520
|
})).required(t$1("neetoRules.validations.required.entity", {
|
|
4337
4521
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4338
|
-
}))
|
|
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
|
+
})
|
|
4339
4543
|
});
|
|
4340
4544
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4341
4545
|
return yup.object({
|
|
@@ -5672,7 +5876,7 @@ var Status = function Status() {
|
|
|
5672
5876
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5673
5877
|
setFieldValue("status.value", status);
|
|
5674
5878
|
};
|
|
5675
|
-
return /*#__PURE__*/jsx(Switch, {
|
|
5879
|
+
return /*#__PURE__*/jsx(Switch$1, {
|
|
5676
5880
|
checked: defaultValue === ENABLED,
|
|
5677
5881
|
label: t("neetoRules.labels.active"),
|
|
5678
5882
|
labelProps: {
|