@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
|
@@ -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) {
|
|
@@ -110,7 +113,7 @@ var useActiveField = function useActiveField(name) {
|
|
|
110
113
|
react.useEffect(function () {
|
|
111
114
|
if (!shouldAutoFocus || activeField) return;
|
|
112
115
|
setFieldActive();
|
|
113
|
-
}, []);
|
|
116
|
+
}, [name]);
|
|
114
117
|
react.useEffect(function () {
|
|
115
118
|
var shouldFocus = shouldFocusRef.current;
|
|
116
119
|
shouldFocusRef.current = true;
|
|
@@ -125,10 +128,12 @@ var useActiveField = function useActiveField(name) {
|
|
|
125
128
|
shouldFocusRef.current = !ref.current;
|
|
126
129
|
if (needsRerender) {
|
|
127
130
|
setPanelState(ramda.assocPath(["data", "activeField"], null));
|
|
131
|
+
requestAnimationFrame(function () {
|
|
132
|
+
return setPanelState(ramda.assocPath(["data", "activeField"], name));
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
setPanelState(ramda.assocPath(["data", "activeField"], name));
|
|
128
136
|
}
|
|
129
|
-
requestAnimationFrame(function () {
|
|
130
|
-
return setPanelState(ramda.assocPath(["data", "activeField"], name));
|
|
131
|
-
});
|
|
132
137
|
};
|
|
133
138
|
var resetActiveField = function resetActiveField() {
|
|
134
139
|
return setPanelState(ramda.assocPath(["data", "activeField"], null));
|
|
@@ -574,14 +579,27 @@ var LongTextField = function LongTextField(_ref2) {
|
|
|
574
579
|
};
|
|
575
580
|
LongTextField.Target = Target$j;
|
|
576
581
|
|
|
577
|
-
var
|
|
582
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
578
583
|
key: "",
|
|
579
584
|
value: ""
|
|
580
585
|
};
|
|
581
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"];
|
|
582
600
|
|
|
583
601
|
var addOption = function addOption(arrayHelpers) {
|
|
584
|
-
return arrayHelpers.push(
|
|
602
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
585
603
|
};
|
|
586
604
|
var removeOption = function removeOption(_ref) {
|
|
587
605
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -596,8 +614,8 @@ var hasKeyOrValue = ramda.whereAny({
|
|
|
596
614
|
key: neetoCist.isNotEmpty,
|
|
597
615
|
value: neetoCist.isNotEmpty
|
|
598
616
|
});
|
|
599
|
-
var
|
|
600
|
-
return neetoCist.isPresent(
|
|
617
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
618
|
+
return neetoCist.isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
601
619
|
};
|
|
602
620
|
|
|
603
621
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -606,30 +624,27 @@ var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
|
|
|
606
624
|
var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
607
625
|
var t = _ref.t,
|
|
608
626
|
name = _ref.name,
|
|
609
|
-
|
|
610
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
627
|
+
entity = _ref.entity,
|
|
611
628
|
onFocus = _ref.onFocus;
|
|
612
629
|
return /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
|
|
613
630
|
name: name,
|
|
614
631
|
children: function children(arrayHelpers) {
|
|
615
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
632
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
616
633
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
617
634
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
618
|
-
className: "space-y-3",
|
|
619
|
-
children: [
|
|
620
|
-
children: label
|
|
621
|
-
}), data.map(function (_, index) {
|
|
635
|
+
className: "flex flex-col space-y-3",
|
|
636
|
+
children: [data.map(function (_, index) {
|
|
622
637
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
623
638
|
className: "flex h-8 space-x-3",
|
|
624
639
|
children: [/*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
625
640
|
onFocus: onFocus,
|
|
626
|
-
className: "w-
|
|
641
|
+
className: "w-1/3",
|
|
627
642
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
628
643
|
placeholder: t("neetoRules.labels.key"),
|
|
629
644
|
type: "text"
|
|
630
645
|
}), /*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
631
646
|
onFocus: onFocus,
|
|
632
|
-
className: "w-3
|
|
647
|
+
className: "w-2/3",
|
|
633
648
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
634
649
|
placeholder: t("neetoRules.labels.value"),
|
|
635
650
|
type: "text",
|
|
@@ -649,7 +664,10 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
649
664
|
}, index);
|
|
650
665
|
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
651
666
|
onFocus: onFocus,
|
|
652
|
-
|
|
667
|
+
className: "w-30 ml-auto",
|
|
668
|
+
label: t("neetoRules.labels.addEntity", {
|
|
669
|
+
entity: entity
|
|
670
|
+
}),
|
|
653
671
|
style: "secondary",
|
|
654
672
|
onClick: function onClick() {
|
|
655
673
|
return addOption(arrayHelpers);
|
|
@@ -660,6 +678,167 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
660
678
|
});
|
|
661
679
|
});
|
|
662
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
|
+
|
|
663
842
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
664
843
|
var selectedField = _ref.selectedField,
|
|
665
844
|
templates = _ref.templates,
|
|
@@ -746,7 +925,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
746
925
|
var _useTranslation2 = reactI18next.useTranslation(),
|
|
747
926
|
t = _useTranslation2.t;
|
|
748
927
|
var _useFormikContext = formik.useFormikContext(),
|
|
749
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
928
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
929
|
+
values = _useFormikContext.values;
|
|
750
930
|
var _useActiveField2 = useActiveField(name, {
|
|
751
931
|
shouldAutoFocus: shouldAutoFocus
|
|
752
932
|
}),
|
|
@@ -755,8 +935,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
755
935
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
756
936
|
var isTemplateSelectionEnabled = neetoCist.isPresent(templates);
|
|
757
937
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
758
|
-
|
|
759
|
-
|
|
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
|
+
});
|
|
760
942
|
};
|
|
761
943
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
762
944
|
className: "w-full",
|
|
@@ -776,9 +958,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
776
958
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
777
959
|
type: "text",
|
|
778
960
|
onFocus: setFieldActive
|
|
779
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
780
|
-
|
|
781
|
-
|
|
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,
|
|
782
968
|
onFocus: setFieldActive
|
|
783
969
|
})]
|
|
784
970
|
});
|
|
@@ -968,17 +1154,17 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
968
1154
|
editorRef = _ref$editorRef === void 0 ? null : _ref$editorRef,
|
|
969
1155
|
defaults = _ref.defaults,
|
|
970
1156
|
otherProps = _objectWithoutProperties(_ref, _excluded$d);
|
|
971
|
-
var
|
|
972
|
-
|
|
973
|
-
editorData =
|
|
974
|
-
setEditorData =
|
|
1157
|
+
var _useStateWithDependen = reactUtils.useStateWithDependency(value, [name]),
|
|
1158
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
1159
|
+
editorData = _useStateWithDependen2[0],
|
|
1160
|
+
setEditorData = _useStateWithDependen2[1];
|
|
975
1161
|
var _useFormikContext = formik.useFormikContext(),
|
|
976
1162
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
977
1163
|
var debouncedValue = reactUtils.useDebounce(editorData, 200);
|
|
978
1164
|
react.useEffect(function () {
|
|
979
1165
|
setFieldValue(name, editorData);
|
|
980
1166
|
}, [debouncedValue]);
|
|
981
|
-
return /*#__PURE__*/
|
|
1167
|
+
return /*#__PURE__*/react.createElement(FormikEditor, _objectSpread$n({
|
|
982
1168
|
addons: addons,
|
|
983
1169
|
autoFocus: autoFocus,
|
|
984
1170
|
defaults: defaults,
|
|
@@ -988,6 +1174,7 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
988
1174
|
hideSlashCommands: true,
|
|
989
1175
|
className: "w-full",
|
|
990
1176
|
"data-cy": "neeto-editor",
|
|
1177
|
+
key: name,
|
|
991
1178
|
ref: editorRef,
|
|
992
1179
|
onChange: setEditorData
|
|
993
1180
|
}, otherProps));
|
|
@@ -4353,7 +4540,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4353
4540
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4354
4541
|
})).required(i18next.t("neetoRules.validations.required.entity", {
|
|
4355
4542
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4356
|
-
}))
|
|
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
|
+
})
|
|
4357
4564
|
});
|
|
4358
4565
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4359
4566
|
return yup__namespace.object({
|
|
@@ -5690,7 +5897,7 @@ var Status = function Status() {
|
|
|
5690
5897
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5691
5898
|
setFieldValue("status.value", status);
|
|
5692
5899
|
};
|
|
5693
|
-
return /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
5900
|
+
return /*#__PURE__*/jsxRuntime.jsx(Switch$1, {
|
|
5694
5901
|
checked: defaultValue === ENABLED,
|
|
5695
5902
|
label: t("neetoRules.labels.active"),
|
|
5696
5903
|
labelProps: {
|