@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
|
@@ -26,7 +26,10 @@ var i18next = require('i18next');
|
|
|
26
26
|
var Left = require('@bigbinary/neeto-icons/Left');
|
|
27
27
|
var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
28
28
|
var Input$1 = require('@bigbinary/neetoui/formik/Input');
|
|
29
|
+
var Switch = require('@bigbinary/neetoui/formik/Switch');
|
|
29
30
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
31
|
+
var Editor = require('@monaco-editor/react');
|
|
32
|
+
var DynamicVariables = require('@bigbinary/neeto-molecules/DynamicVariables');
|
|
30
33
|
var Label = require('@bigbinary/neetoui/Label');
|
|
31
34
|
var Select = require('@bigbinary/neetoui/Select');
|
|
32
35
|
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
@@ -58,7 +61,7 @@ var Container = require('@bigbinary/neeto-molecules/Container');
|
|
|
58
61
|
var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
|
|
59
62
|
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
60
63
|
var Help = require('@bigbinary/neeto-icons/Help');
|
|
61
|
-
var Switch = require('@bigbinary/neetoui/Switch');
|
|
64
|
+
var Switch$1 = require('@bigbinary/neetoui/Switch');
|
|
62
65
|
var useCustomDataStore = require('../useCustomDataStore-BEG8I__n.js');
|
|
63
66
|
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
64
67
|
require('zustand');
|
|
@@ -84,7 +87,7 @@ var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
|
|
|
84
87
|
|
|
85
88
|
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}}
|
|
86
89
|
|
|
87
|
-
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,
|
|
90
|
+
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19lcnJvci1ib3VuZGFyeS5zY3NzIiwiYXBwL2phdmFzY3JpcHQvc3JjL3N0eWxlc2hlZXRzL21haW4uc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19sYXlvdXQuc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19wYW5lLnNjc3MiLCJhcHAvamF2YXNjcmlwdC9zcmMvc3R5bGVzaGVldHMvY29tcG9uZW50cy9fanNvbi1lZGl0b3Iuc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw4QkFJRSxrQkFBQSxDQUdBLDhDQUFBLENBREEsd0NBQUEsQ0FIQSxZQUFBLENBRUEsUUFBQSxDQUhBLG9CQUFBLENBREEscUJDT0YsQ0RDRSxnQ0FDRSxtQ0NDSixDQ1hBLHFDQUNFLHVCRGNGLENDWEEsK0NBQ0UsZURjRixDRW5CQSx3QkFFRSxXQUFBLENBREEsYUZ1QkYsQ0VwQkUsK0JBQ0UsV0ZzQkosQ0VwQkksMEJBSEYsK0JBSUksV0Z1QkosQ0FDRixDRXBCRSwrQkFDRSxXRnNCSixDRXBCSSw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cnVsZXMtbWFpbi1jYXJkIC5uZWV0by11aS1idG4udW5kZXJsaW5lIHtcbiAgdGV4dC1hbGlnbjogbGVmdDtcbn0iLCIubmVldG8tcnVsZXMtc2lkZS1wYW5lbCB7XG4gIGZsZXgtc2hyaW5rOiAwO1xuICBmbGV4LWdyb3c6IDA7XG5cbiAgJi0tc21hbGwge1xuICAgIHdpZHRoOiAzMjBweDtcblxuICAgIEBtZWRpYSAobWluLXdpZHRoOiAxMDI0cHgpIHtcbiAgICAgIHdpZHRoOiAzODBweDtcbiAgICB9XG4gIH1cblxuICAmLS1sYXJnZSB7XG4gICAgd2lkdGg6IDM4MHB4O1xuXG4gICAgQG1lZGlhIChtaW4td2lkdGg6IDEwMjRweCkge1xuICAgICAgd2lkdGg6IDQ4MHB4O1xuICAgIH1cbiAgfVxufSIsIi5uZWV0by1ydWxlcy1qc29uLWVkaXRvciB7XG4gICZfX3dyYXBwZXIge1xuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgICBoZWlnaHQ6IDM1dmg7XG4gIH1cblxuICAmX19lZGl0b3Ige1xuICAgIGhlaWdodDogMTAwJTtcbiAgfVxuXG4gICZfX2R5bmFtaWMtdmFyaWFibGVzIHtcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgdG9wOiAxcmVtO1xuICAgIHJpZ2h0OiAxcmVtO1xuICAgIHotaW5kZXg6IDEwO1xuICB9XG59XG4iXX0= */";
|
|
88
91
|
n(css,{});
|
|
89
92
|
|
|
90
93
|
var useActiveField = function useActiveField(name) {
|
|
@@ -576,14 +579,27 @@ var LongTextField = function LongTextField(_ref2) {
|
|
|
576
579
|
};
|
|
577
580
|
LongTextField.Target = Target$j;
|
|
578
581
|
|
|
579
|
-
var
|
|
582
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
580
583
|
key: "",
|
|
581
584
|
value: ""
|
|
582
585
|
};
|
|
583
586
|
var SAMPLE_ENDPOINT = "https://example.com";
|
|
587
|
+
var JSON_LANGUAGE = "json";
|
|
588
|
+
var EDITOR_CONFIG = {
|
|
589
|
+
formatOnType: true,
|
|
590
|
+
formatOnPaste: true,
|
|
591
|
+
automaticLayout: true,
|
|
592
|
+
tabSize: 2,
|
|
593
|
+
minimap: {
|
|
594
|
+
enabled: false
|
|
595
|
+
},
|
|
596
|
+
scrollBeyondLastLine: false,
|
|
597
|
+
autoIndent: "full"
|
|
598
|
+
};
|
|
599
|
+
var API_REQUEST_FIELDS = ["endpoint", "body", "enableCustomHeaders", "customHeaders"];
|
|
584
600
|
|
|
585
601
|
var addOption = function addOption(arrayHelpers) {
|
|
586
|
-
return arrayHelpers.push(
|
|
602
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
587
603
|
};
|
|
588
604
|
var removeOption = function removeOption(_ref) {
|
|
589
605
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -598,8 +614,8 @@ var hasKeyOrValue = ramda.whereAny({
|
|
|
598
614
|
key: neetoCist.isNotEmpty,
|
|
599
615
|
value: neetoCist.isNotEmpty
|
|
600
616
|
});
|
|
601
|
-
var
|
|
602
|
-
return neetoCist.isPresent(
|
|
617
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
618
|
+
return neetoCist.isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
603
619
|
};
|
|
604
620
|
|
|
605
621
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -608,30 +624,27 @@ var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
|
|
|
608
624
|
var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
609
625
|
var t = _ref.t,
|
|
610
626
|
name = _ref.name,
|
|
611
|
-
|
|
612
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
627
|
+
entity = _ref.entity,
|
|
613
628
|
onFocus = _ref.onFocus;
|
|
614
629
|
return /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
|
|
615
630
|
name: name,
|
|
616
631
|
children: function children(arrayHelpers) {
|
|
617
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
632
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
618
633
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
619
634
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
620
|
-
className: "space-y-3",
|
|
621
|
-
children: [
|
|
622
|
-
children: label
|
|
623
|
-
}), data.map(function (_, index) {
|
|
635
|
+
className: "flex flex-col space-y-3",
|
|
636
|
+
children: [data.map(function (_, index) {
|
|
624
637
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
625
638
|
className: "flex h-8 space-x-3",
|
|
626
639
|
children: [/*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
627
640
|
onFocus: onFocus,
|
|
628
|
-
className: "w-
|
|
641
|
+
className: "w-1/3",
|
|
629
642
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
630
643
|
placeholder: t("neetoRules.labels.key"),
|
|
631
644
|
type: "text"
|
|
632
645
|
}), /*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
633
646
|
onFocus: onFocus,
|
|
634
|
-
className: "w-3
|
|
647
|
+
className: "w-2/3",
|
|
635
648
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
636
649
|
placeholder: t("neetoRules.labels.value"),
|
|
637
650
|
type: "text",
|
|
@@ -651,7 +664,10 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
651
664
|
}, index);
|
|
652
665
|
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
653
666
|
onFocus: onFocus,
|
|
654
|
-
|
|
667
|
+
className: "w-30 ml-auto",
|
|
668
|
+
label: t("neetoRules.labels.addEntity", {
|
|
669
|
+
entity: entity
|
|
670
|
+
}),
|
|
655
671
|
style: "secondary",
|
|
656
672
|
onClick: function onClick() {
|
|
657
673
|
return addOption(arrayHelpers);
|
|
@@ -662,6 +678,167 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
662
678
|
});
|
|
663
679
|
});
|
|
664
680
|
|
|
681
|
+
var CustomHeaders = function CustomHeaders(_ref) {
|
|
682
|
+
var name = _ref.name,
|
|
683
|
+
onFocus = _ref.onFocus;
|
|
684
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
685
|
+
values = _useFormikContext.values,
|
|
686
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
687
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
688
|
+
t = _useTranslation.t;
|
|
689
|
+
var switchName = "".concat(name, ".enableCustomHeaders");
|
|
690
|
+
var keyValuePairsFieldName = "".concat(name, ".customHeaders");
|
|
691
|
+
var isCustomHeadersEnabled = dotPath(switchName, values);
|
|
692
|
+
var handleChange = function handleChange(_ref2) {
|
|
693
|
+
var checked = _ref2.target.checked;
|
|
694
|
+
if (!checked) {
|
|
695
|
+
setFieldValue(keyValuePairsFieldName, [CUSTOM_HEADERS_INITIAL_VALUE]);
|
|
696
|
+
}
|
|
697
|
+
setFieldValue(switchName, checked);
|
|
698
|
+
};
|
|
699
|
+
var label = t("neetoRules.labels.includeHeaders");
|
|
700
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
701
|
+
className: "flex flex-col space-y-4 mb-4",
|
|
702
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
703
|
+
label: label,
|
|
704
|
+
onFocus: onFocus,
|
|
705
|
+
"data-cy": "neeto-rules-api-fields-".concat(neetoCist.hyphenate(label), "-switch"),
|
|
706
|
+
name: switchName,
|
|
707
|
+
onChange: handleChange
|
|
708
|
+
}), isCustomHeadersEnabled && /*#__PURE__*/jsxRuntime.jsx(KeyValuePairsField, {
|
|
709
|
+
onFocus: onFocus,
|
|
710
|
+
entity: t("neetoRules.labels.headers"),
|
|
711
|
+
name: "".concat(name, ".customHeaders")
|
|
712
|
+
})]
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
var JsonEditor = function JsonEditor(_ref) {
|
|
717
|
+
var name = _ref.name,
|
|
718
|
+
onFocus = _ref.onFocus,
|
|
719
|
+
_ref$initialValue = _ref.initialValue,
|
|
720
|
+
initialValue = _ref$initialValue === void 0 ? "{}" : _ref$initialValue,
|
|
721
|
+
_ref$variables = _ref.variables,
|
|
722
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables;
|
|
723
|
+
var editorRef = react.useRef(null);
|
|
724
|
+
var completionProviderRef = react.useRef(null);
|
|
725
|
+
var _useField = formik.useField(name),
|
|
726
|
+
_useField2 = _slicedToArray(_useField, 3);
|
|
727
|
+
_useField2[0];
|
|
728
|
+
var _useField2$ = _useField2[1],
|
|
729
|
+
touched = _useField2$.touched,
|
|
730
|
+
error = _useField2$.error,
|
|
731
|
+
_useField2$2 = _useField2[2],
|
|
732
|
+
setValue = _useField2$2.setValue,
|
|
733
|
+
setTouched = _useField2$2.setTouched;
|
|
734
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
735
|
+
t = _useTranslation.t;
|
|
736
|
+
var handleEditorDidMount = function handleEditorDidMount(editor, monaco) {
|
|
737
|
+
editorRef.current = editor;
|
|
738
|
+
completionProviderRef.current = monaco.languages.registerCompletionItemProvider(JSON_LANGUAGE, {
|
|
739
|
+
triggerCharacters: ["{"],
|
|
740
|
+
provideCompletionItems: function provideCompletionItems(model, position) {
|
|
741
|
+
var lineContent = model.getLineContent(position.lineNumber);
|
|
742
|
+
var beforeCursor = lineContent.slice(0, position.column - 1);
|
|
743
|
+
if (!beforeCursor.endsWith('"{')) {
|
|
744
|
+
return {
|
|
745
|
+
suggestions: []
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
var suggestions = variables.map(function (_ref2) {
|
|
749
|
+
var key = _ref2.key,
|
|
750
|
+
label = _ref2.label;
|
|
751
|
+
return {
|
|
752
|
+
label: label,
|
|
753
|
+
kind: monaco.languages.CompletionItemKind.Variable,
|
|
754
|
+
insertText: "{".concat(key, "}}"),
|
|
755
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
756
|
+
detail: t("neetoRules.apiFields.insertPlaceholder", {
|
|
757
|
+
label: label
|
|
758
|
+
})
|
|
759
|
+
};
|
|
760
|
+
});
|
|
761
|
+
return {
|
|
762
|
+
suggestions: suggestions
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
var insertVariable = function insertVariable(_ref3) {
|
|
768
|
+
var key = _ref3.key;
|
|
769
|
+
var editor = editorRef.current;
|
|
770
|
+
if (!editor) return;
|
|
771
|
+
var selection = editor.getSelection();
|
|
772
|
+
var range = {
|
|
773
|
+
startLineNumber: selection.startLineNumber,
|
|
774
|
+
startColumn: selection.startColumn,
|
|
775
|
+
endLineNumber: selection.endLineNumber,
|
|
776
|
+
endColumn: selection.endColumn
|
|
777
|
+
};
|
|
778
|
+
var text = "\"{{".concat(key, "}}\"");
|
|
779
|
+
editor.executeEdits("", [{
|
|
780
|
+
range: range,
|
|
781
|
+
text: text,
|
|
782
|
+
forceMoveMarkers: true
|
|
783
|
+
}]);
|
|
784
|
+
var position = editor.getPosition();
|
|
785
|
+
editor.setPosition({
|
|
786
|
+
lineNumber: position.lineNumber,
|
|
787
|
+
column: position.column + text.length
|
|
788
|
+
});
|
|
789
|
+
editor.focus();
|
|
790
|
+
};
|
|
791
|
+
var handleChange = function handleChange(value) {
|
|
792
|
+
setTouched(true);
|
|
793
|
+
setValue(value);
|
|
794
|
+
};
|
|
795
|
+
react.useEffect(function () {
|
|
796
|
+
var editor = editorRef.current;
|
|
797
|
+
if (!editor) return;
|
|
798
|
+
var currentValue = editor.getValue();
|
|
799
|
+
if (currentValue !== initialValue) {
|
|
800
|
+
editor.setValue(initialValue);
|
|
801
|
+
}
|
|
802
|
+
}, [initialValue]);
|
|
803
|
+
react.useEffect(function () {
|
|
804
|
+
return function () {
|
|
805
|
+
var _completionProviderRe;
|
|
806
|
+
(_completionProviderRe = completionProviderRef.current) === null || _completionProviderRe === void 0 || _completionProviderRe.dispose();
|
|
807
|
+
completionProviderRef.current = null;
|
|
808
|
+
};
|
|
809
|
+
}, []);
|
|
810
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
811
|
+
className: "space-y-2 mb-2",
|
|
812
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
813
|
+
required: true,
|
|
814
|
+
"data-cy": "api-field-body",
|
|
815
|
+
children: t("neetoRules.labels.body")
|
|
816
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
817
|
+
className: "neeto-rules-json-editor__wrapper",
|
|
818
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
819
|
+
className: "neeto-rules-json-editor__dynamic-variables",
|
|
820
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DynamicVariables, {
|
|
821
|
+
variables: variables,
|
|
822
|
+
onVariableClick: insertVariable
|
|
823
|
+
})
|
|
824
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Editor, {
|
|
825
|
+
onFocus: onFocus,
|
|
826
|
+
className: "neeto-rules-json-editor__editor",
|
|
827
|
+
defaultLanguage: JSON_LANGUAGE,
|
|
828
|
+
defaultValue: initialValue,
|
|
829
|
+
height: "100%",
|
|
830
|
+
options: EDITOR_CONFIG,
|
|
831
|
+
theme: "vs-dark",
|
|
832
|
+
onChange: handleChange,
|
|
833
|
+
onMount: handleEditorDidMount
|
|
834
|
+
}), error && touched && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
835
|
+
className: "neeto-ui-input__error",
|
|
836
|
+
children: error
|
|
837
|
+
})]
|
|
838
|
+
})]
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
|
|
665
842
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
666
843
|
var selectedField = _ref.selectedField,
|
|
667
844
|
templates = _ref.templates,
|
|
@@ -748,7 +925,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
748
925
|
var _useTranslation2 = reactI18next.useTranslation(),
|
|
749
926
|
t = _useTranslation2.t;
|
|
750
927
|
var _useFormikContext = formik.useFormikContext(),
|
|
751
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
928
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
929
|
+
values = _useFormikContext.values;
|
|
752
930
|
var _useActiveField2 = useActiveField(name, {
|
|
753
931
|
shouldAutoFocus: shouldAutoFocus
|
|
754
932
|
}),
|
|
@@ -757,8 +935,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
757
935
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
758
936
|
var isTemplateSelectionEnabled = neetoCist.isPresent(templates);
|
|
759
937
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
760
|
-
|
|
761
|
-
|
|
938
|
+
API_REQUEST_FIELDS.forEach(function (key) {
|
|
939
|
+
var value = key === "customHeaders" ? formatCustomFields(template[key]) : template[key];
|
|
940
|
+
setFieldValue("".concat(name, ".").concat(key), value);
|
|
941
|
+
});
|
|
762
942
|
};
|
|
763
943
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
764
944
|
className: "w-full",
|
|
@@ -778,9 +958,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
778
958
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
779
959
|
type: "text",
|
|
780
960
|
onFocus: setFieldActive
|
|
781
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
782
|
-
|
|
783
|
-
|
|
961
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CustomHeaders, {
|
|
962
|
+
name: name,
|
|
963
|
+
onFocus: setFieldActive
|
|
964
|
+
}), /*#__PURE__*/jsxRuntime.jsx(JsonEditor, {
|
|
965
|
+
initialValue: dotPath("".concat(name, ".body"), values),
|
|
966
|
+
name: "".concat(name, ".body"),
|
|
967
|
+
variables: selectedField === null || selectedField === void 0 ? void 0 : selectedField.variables,
|
|
784
968
|
onFocus: setFieldActive
|
|
785
969
|
})]
|
|
786
970
|
});
|
|
@@ -4356,7 +4540,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4356
4540
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4357
4541
|
})).required(i18next.t("neetoRules.validations.required.entity", {
|
|
4358
4542
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4359
|
-
}))
|
|
4543
|
+
})),
|
|
4544
|
+
body: yup__namespace.string().trim().required(i18next.t("neetoRules.validations.required.entity", {
|
|
4545
|
+
entity: i18next.t("neetoRules.labels.body")
|
|
4546
|
+
})).test("is-valid-json-and-not-empty", function (value, context) {
|
|
4547
|
+
if (!value) return true;
|
|
4548
|
+
try {
|
|
4549
|
+
var parsedValue = JSON.parse(value);
|
|
4550
|
+
if (neetoCist.isNotPresent(parsedValue)) {
|
|
4551
|
+
return context.createError({
|
|
4552
|
+
message: i18next.t("neetoRules.validations.required.entity", {
|
|
4553
|
+
entity: i18next.t("neetoRules.labels.body")
|
|
4554
|
+
})
|
|
4555
|
+
});
|
|
4556
|
+
}
|
|
4557
|
+
return true;
|
|
4558
|
+
} catch (_unused) {
|
|
4559
|
+
return context.createError({
|
|
4560
|
+
message: i18next.t("neetoRules.validations.invalidJsonBody")
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
})
|
|
4360
4564
|
});
|
|
4361
4565
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4362
4566
|
return yup__namespace.object({
|
|
@@ -5693,7 +5897,7 @@ var Status = function Status() {
|
|
|
5693
5897
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5694
5898
|
setFieldValue("status.value", status);
|
|
5695
5899
|
};
|
|
5696
|
-
return /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
5900
|
+
return /*#__PURE__*/jsxRuntime.jsx(Switch$1, {
|
|
5697
5901
|
checked: defaultValue === ENABLED,
|
|
5698
5902
|
label: t("neetoRules.labels.active"),
|
|
5699
5903
|
labelProps: {
|