@bigbinary/neeto-rules-frontend 2.5.15-beta-4 → 2.5.15-beta-6
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 +254 -43
- package/dist/NeetoRulesForm.js.map +1 -1
- package/dist/cjs/NeetoRulesForm.js +253 -42
- 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 +9 -7
|
@@ -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) {
|
|
@@ -528,15 +531,20 @@ var DEFAULT_LONG_TEXT_ROWS = 8;
|
|
|
528
531
|
var Target$j = function Target(_ref) {
|
|
529
532
|
var _errors$actions, _touched$actions, _selectedField$separa;
|
|
530
533
|
var index = _ref.index,
|
|
534
|
+
name = _ref.name,
|
|
531
535
|
_ref$selectedField = _ref.selectedField,
|
|
532
536
|
selectedField = _ref$selectedField === void 0 ? {} : _ref$selectedField,
|
|
533
537
|
defaultLabel = _ref.defaultLabel,
|
|
534
538
|
defaultSeparator = _ref.defaultSeparator,
|
|
535
|
-
|
|
539
|
+
_ref$onClick = _ref.onClick,
|
|
540
|
+
_onClick = _ref$onClick === void 0 ? neetoCist.noop : _ref$onClick;
|
|
536
541
|
var _useFormikContext = formik.useFormikContext(),
|
|
537
542
|
errors = _useFormikContext.errors,
|
|
538
543
|
touched = _useFormikContext.touched;
|
|
539
|
-
var
|
|
544
|
+
var _useActiveField = useActiveField(name),
|
|
545
|
+
isFieldActive = _useActiveField.isFieldActive,
|
|
546
|
+
setFieldActive = _useActiveField.setFieldActive;
|
|
547
|
+
var isFieldInvalid = errors.actions && ramda.isNotNil((_errors$actions = errors.actions) === null || _errors$actions === void 0 || (_errors$actions = _errors$actions.value) === null || _errors$actions === void 0 ? void 0 : _errors$actions[index]) && ramda.isNotNil((_touched$actions = touched.actions) === null || _touched$actions === void 0 || (_touched$actions = _touched$actions.value) === null || _touched$actions === void 0 ? void 0 : _touched$actions[index]);
|
|
540
548
|
var separator = (selectedField === null || selectedField === void 0 || (_selectedField$separa = selectedField.separator) === null || _selectedField$separa === void 0 ? void 0 : _selectedField$separa.toLowerCase()) || defaultSeparator;
|
|
541
549
|
var label = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.placeholder) || defaultLabel;
|
|
542
550
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -551,39 +559,60 @@ var Target$j = function Target(_ref) {
|
|
|
551
559
|
label: label.toLowerCase(),
|
|
552
560
|
style: "link",
|
|
553
561
|
className: classNames("neeto-ui-text-gray-800 neeto-ui-font-semibold underline", {
|
|
554
|
-
"neeto-ui-text-
|
|
562
|
+
"neeto-ui-text-accent-800": isFieldActive,
|
|
563
|
+
"neeto-ui-text-error-500": isFieldInvalid && !isFieldActive
|
|
555
564
|
}),
|
|
556
565
|
onClick: function onClick() {
|
|
557
|
-
|
|
566
|
+
_onClick();
|
|
567
|
+
setFieldActive();
|
|
558
568
|
}
|
|
559
569
|
})]
|
|
560
570
|
});
|
|
561
571
|
};
|
|
562
572
|
var LongTextField = function LongTextField(_ref2) {
|
|
563
573
|
var name = _ref2.name,
|
|
564
|
-
_ref2$value = _ref2.value,
|
|
565
|
-
value = _ref2$value === void 0 ? "" : _ref2$value,
|
|
566
574
|
_ref2$selectedField = _ref2.selectedField,
|
|
567
|
-
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField
|
|
575
|
+
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField,
|
|
576
|
+
_ref2$shouldAutoFocus = _ref2.shouldAutoFocus,
|
|
577
|
+
shouldAutoFocus = _ref2$shouldAutoFocus === void 0 ? false : _ref2$shouldAutoFocus;
|
|
578
|
+
var _useActiveField2 = useActiveField(name, {
|
|
579
|
+
shouldAutoFocus: shouldAutoFocus
|
|
580
|
+
}),
|
|
581
|
+
ref = _useActiveField2.ref,
|
|
582
|
+
setFieldActive = _useActiveField2.setFieldActive;
|
|
568
583
|
var rows = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.rows) || DEFAULT_LONG_TEXT_ROWS;
|
|
569
584
|
return /*#__PURE__*/jsxRuntime.jsx(Textarea, {
|
|
570
585
|
name: name,
|
|
586
|
+
ref: ref,
|
|
571
587
|
rows: rows,
|
|
572
|
-
value: value,
|
|
573
588
|
required: true,
|
|
574
|
-
className: "w-full"
|
|
589
|
+
className: "w-full",
|
|
590
|
+
onFocus: setFieldActive
|
|
575
591
|
});
|
|
576
592
|
};
|
|
577
593
|
LongTextField.Target = Target$j;
|
|
578
594
|
|
|
579
|
-
var
|
|
595
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
580
596
|
key: "",
|
|
581
597
|
value: ""
|
|
582
598
|
};
|
|
583
599
|
var SAMPLE_ENDPOINT = "https://example.com";
|
|
600
|
+
var JSON_LANGUAGE = "json";
|
|
601
|
+
var EDITOR_CONFIG = {
|
|
602
|
+
formatOnType: true,
|
|
603
|
+
formatOnPaste: true,
|
|
604
|
+
automaticLayout: true,
|
|
605
|
+
tabSize: 2,
|
|
606
|
+
minimap: {
|
|
607
|
+
enabled: false
|
|
608
|
+
},
|
|
609
|
+
scrollBeyondLastLine: false,
|
|
610
|
+
autoIndent: "full"
|
|
611
|
+
};
|
|
612
|
+
var API_REQUEST_FIELDS = ["endpoint", "body", "enableCustomHeaders", "customHeaders"];
|
|
584
613
|
|
|
585
614
|
var addOption = function addOption(arrayHelpers) {
|
|
586
|
-
return arrayHelpers.push(
|
|
615
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
587
616
|
};
|
|
588
617
|
var removeOption = function removeOption(_ref) {
|
|
589
618
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -598,8 +627,8 @@ var hasKeyOrValue = ramda.whereAny({
|
|
|
598
627
|
key: neetoCist.isNotEmpty,
|
|
599
628
|
value: neetoCist.isNotEmpty
|
|
600
629
|
});
|
|
601
|
-
var
|
|
602
|
-
return neetoCist.isPresent(
|
|
630
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
631
|
+
return neetoCist.isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
603
632
|
};
|
|
604
633
|
|
|
605
634
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -608,30 +637,27 @@ var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
|
|
|
608
637
|
var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
609
638
|
var t = _ref.t,
|
|
610
639
|
name = _ref.name,
|
|
611
|
-
|
|
612
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
640
|
+
entity = _ref.entity,
|
|
613
641
|
onFocus = _ref.onFocus;
|
|
614
642
|
return /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
|
|
615
643
|
name: name,
|
|
616
644
|
children: function children(arrayHelpers) {
|
|
617
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
645
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
618
646
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
619
647
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
620
|
-
className: "space-y-3",
|
|
621
|
-
children: [
|
|
622
|
-
children: label
|
|
623
|
-
}), data.map(function (_, index) {
|
|
648
|
+
className: "flex flex-col space-y-3",
|
|
649
|
+
children: [data.map(function (_, index) {
|
|
624
650
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
625
651
|
className: "flex h-8 space-x-3",
|
|
626
652
|
children: [/*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
627
653
|
onFocus: onFocus,
|
|
628
|
-
className: "w-
|
|
654
|
+
className: "w-1/3",
|
|
629
655
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
630
656
|
placeholder: t("neetoRules.labels.key"),
|
|
631
657
|
type: "text"
|
|
632
658
|
}), /*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
633
659
|
onFocus: onFocus,
|
|
634
|
-
className: "w-3
|
|
660
|
+
className: "w-2/3",
|
|
635
661
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
636
662
|
placeholder: t("neetoRules.labels.value"),
|
|
637
663
|
type: "text",
|
|
@@ -651,7 +677,10 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
651
677
|
}, index);
|
|
652
678
|
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
653
679
|
onFocus: onFocus,
|
|
654
|
-
|
|
680
|
+
className: "w-30 ml-auto",
|
|
681
|
+
label: t("neetoRules.labels.addEntity", {
|
|
682
|
+
entity: entity
|
|
683
|
+
}),
|
|
655
684
|
style: "secondary",
|
|
656
685
|
onClick: function onClick() {
|
|
657
686
|
return addOption(arrayHelpers);
|
|
@@ -662,6 +691,167 @@ var KeyValuePairsField = reactUtils.withT(function (_ref) {
|
|
|
662
691
|
});
|
|
663
692
|
});
|
|
664
693
|
|
|
694
|
+
var CustomHeaders = function CustomHeaders(_ref) {
|
|
695
|
+
var name = _ref.name,
|
|
696
|
+
onFocus = _ref.onFocus;
|
|
697
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
698
|
+
values = _useFormikContext.values,
|
|
699
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
700
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
701
|
+
t = _useTranslation.t;
|
|
702
|
+
var switchName = "".concat(name, ".enableCustomHeaders");
|
|
703
|
+
var keyValuePairsFieldName = "".concat(name, ".customHeaders");
|
|
704
|
+
var isCustomHeadersEnabled = dotPath(switchName, values);
|
|
705
|
+
var handleChange = function handleChange(_ref2) {
|
|
706
|
+
var checked = _ref2.target.checked;
|
|
707
|
+
if (!checked) {
|
|
708
|
+
setFieldValue(keyValuePairsFieldName, [CUSTOM_HEADERS_INITIAL_VALUE]);
|
|
709
|
+
}
|
|
710
|
+
setFieldValue(switchName, checked);
|
|
711
|
+
};
|
|
712
|
+
var label = t("neetoRules.labels.includeHeaders");
|
|
713
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
714
|
+
className: "flex flex-col space-y-4 mb-4",
|
|
715
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
716
|
+
label: label,
|
|
717
|
+
onFocus: onFocus,
|
|
718
|
+
"data-cy": "neeto-rules-api-fields-".concat(neetoCist.hyphenate(label), "-switch"),
|
|
719
|
+
name: switchName,
|
|
720
|
+
onChange: handleChange
|
|
721
|
+
}), isCustomHeadersEnabled && /*#__PURE__*/jsxRuntime.jsx(KeyValuePairsField, {
|
|
722
|
+
onFocus: onFocus,
|
|
723
|
+
entity: t("neetoRules.labels.headers"),
|
|
724
|
+
name: "".concat(name, ".customHeaders")
|
|
725
|
+
})]
|
|
726
|
+
});
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
var JsonEditor = function JsonEditor(_ref) {
|
|
730
|
+
var name = _ref.name,
|
|
731
|
+
onFocus = _ref.onFocus,
|
|
732
|
+
_ref$initialValue = _ref.initialValue,
|
|
733
|
+
initialValue = _ref$initialValue === void 0 ? "{}" : _ref$initialValue,
|
|
734
|
+
_ref$variables = _ref.variables,
|
|
735
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables;
|
|
736
|
+
var editorRef = react.useRef(null);
|
|
737
|
+
var completionProviderRef = react.useRef(null);
|
|
738
|
+
var _useField = formik.useField(name),
|
|
739
|
+
_useField2 = _slicedToArray(_useField, 3);
|
|
740
|
+
_useField2[0];
|
|
741
|
+
var _useField2$ = _useField2[1],
|
|
742
|
+
touched = _useField2$.touched,
|
|
743
|
+
error = _useField2$.error,
|
|
744
|
+
_useField2$2 = _useField2[2],
|
|
745
|
+
setValue = _useField2$2.setValue,
|
|
746
|
+
setTouched = _useField2$2.setTouched;
|
|
747
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
748
|
+
t = _useTranslation.t;
|
|
749
|
+
var handleEditorDidMount = function handleEditorDidMount(editor, monaco) {
|
|
750
|
+
editorRef.current = editor;
|
|
751
|
+
completionProviderRef.current = monaco.languages.registerCompletionItemProvider(JSON_LANGUAGE, {
|
|
752
|
+
triggerCharacters: ["{"],
|
|
753
|
+
provideCompletionItems: function provideCompletionItems(model, position) {
|
|
754
|
+
var lineContent = model.getLineContent(position.lineNumber);
|
|
755
|
+
var beforeCursor = lineContent.slice(0, position.column - 1);
|
|
756
|
+
if (!beforeCursor.endsWith('"{')) {
|
|
757
|
+
return {
|
|
758
|
+
suggestions: []
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
var suggestions = variables.map(function (_ref2) {
|
|
762
|
+
var key = _ref2.key,
|
|
763
|
+
label = _ref2.label;
|
|
764
|
+
return {
|
|
765
|
+
label: label,
|
|
766
|
+
kind: monaco.languages.CompletionItemKind.Variable,
|
|
767
|
+
insertText: "{".concat(key, "}}"),
|
|
768
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
769
|
+
detail: t("neetoRules.apiFields.insertPlaceholder", {
|
|
770
|
+
label: label
|
|
771
|
+
})
|
|
772
|
+
};
|
|
773
|
+
});
|
|
774
|
+
return {
|
|
775
|
+
suggestions: suggestions
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
};
|
|
780
|
+
var insertVariable = function insertVariable(_ref3) {
|
|
781
|
+
var key = _ref3.key;
|
|
782
|
+
var editor = editorRef.current;
|
|
783
|
+
if (!editor) return;
|
|
784
|
+
var selection = editor.getSelection();
|
|
785
|
+
var range = {
|
|
786
|
+
startLineNumber: selection.startLineNumber,
|
|
787
|
+
startColumn: selection.startColumn,
|
|
788
|
+
endLineNumber: selection.endLineNumber,
|
|
789
|
+
endColumn: selection.endColumn
|
|
790
|
+
};
|
|
791
|
+
var text = "\"{{".concat(key, "}}\"");
|
|
792
|
+
editor.executeEdits("", [{
|
|
793
|
+
range: range,
|
|
794
|
+
text: text,
|
|
795
|
+
forceMoveMarkers: true
|
|
796
|
+
}]);
|
|
797
|
+
var position = editor.getPosition();
|
|
798
|
+
editor.setPosition({
|
|
799
|
+
lineNumber: position.lineNumber,
|
|
800
|
+
column: position.column + text.length
|
|
801
|
+
});
|
|
802
|
+
editor.focus();
|
|
803
|
+
};
|
|
804
|
+
var handleChange = function handleChange(value) {
|
|
805
|
+
setTouched(true);
|
|
806
|
+
setValue(value);
|
|
807
|
+
};
|
|
808
|
+
react.useEffect(function () {
|
|
809
|
+
var editor = editorRef.current;
|
|
810
|
+
if (!editor) return;
|
|
811
|
+
var currentValue = editor.getValue();
|
|
812
|
+
if (currentValue !== initialValue) {
|
|
813
|
+
editor.setValue(initialValue);
|
|
814
|
+
}
|
|
815
|
+
}, [initialValue]);
|
|
816
|
+
react.useEffect(function () {
|
|
817
|
+
return function () {
|
|
818
|
+
var _completionProviderRe;
|
|
819
|
+
(_completionProviderRe = completionProviderRef.current) === null || _completionProviderRe === void 0 || _completionProviderRe.dispose();
|
|
820
|
+
completionProviderRef.current = null;
|
|
821
|
+
};
|
|
822
|
+
}, []);
|
|
823
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
824
|
+
className: "space-y-2 mb-2",
|
|
825
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
826
|
+
required: true,
|
|
827
|
+
"data-cy": "api-field-body",
|
|
828
|
+
children: t("neetoRules.labels.body")
|
|
829
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
830
|
+
className: "neeto-rules-json-editor__wrapper",
|
|
831
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
832
|
+
className: "neeto-rules-json-editor__dynamic-variables",
|
|
833
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DynamicVariables, {
|
|
834
|
+
variables: variables,
|
|
835
|
+
onVariableClick: insertVariable
|
|
836
|
+
})
|
|
837
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Editor, {
|
|
838
|
+
onFocus: onFocus,
|
|
839
|
+
className: "neeto-rules-json-editor__editor",
|
|
840
|
+
defaultLanguage: JSON_LANGUAGE,
|
|
841
|
+
defaultValue: initialValue,
|
|
842
|
+
height: "100%",
|
|
843
|
+
options: EDITOR_CONFIG,
|
|
844
|
+
theme: "vs-dark",
|
|
845
|
+
onChange: handleChange,
|
|
846
|
+
onMount: handleEditorDidMount
|
|
847
|
+
}), error && touched && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
848
|
+
className: "neeto-ui-input__error",
|
|
849
|
+
children: error
|
|
850
|
+
})]
|
|
851
|
+
})]
|
|
852
|
+
});
|
|
853
|
+
};
|
|
854
|
+
|
|
665
855
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
666
856
|
var selectedField = _ref.selectedField,
|
|
667
857
|
templates = _ref.templates,
|
|
@@ -748,7 +938,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
748
938
|
var _useTranslation2 = reactI18next.useTranslation(),
|
|
749
939
|
t = _useTranslation2.t;
|
|
750
940
|
var _useFormikContext = formik.useFormikContext(),
|
|
751
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
941
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
942
|
+
values = _useFormikContext.values;
|
|
752
943
|
var _useActiveField2 = useActiveField(name, {
|
|
753
944
|
shouldAutoFocus: shouldAutoFocus
|
|
754
945
|
}),
|
|
@@ -757,8 +948,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
757
948
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
758
949
|
var isTemplateSelectionEnabled = neetoCist.isPresent(templates);
|
|
759
950
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
760
|
-
|
|
761
|
-
|
|
951
|
+
API_REQUEST_FIELDS.forEach(function (key) {
|
|
952
|
+
var value = key === "customHeaders" ? formatCustomFields(template[key]) : template[key];
|
|
953
|
+
setFieldValue("".concat(name, ".").concat(key), value);
|
|
954
|
+
});
|
|
762
955
|
};
|
|
763
956
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
764
957
|
className: "w-full",
|
|
@@ -778,9 +971,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
778
971
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
779
972
|
type: "text",
|
|
780
973
|
onFocus: setFieldActive
|
|
781
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
782
|
-
|
|
783
|
-
|
|
974
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CustomHeaders, {
|
|
975
|
+
name: name,
|
|
976
|
+
onFocus: setFieldActive
|
|
977
|
+
}), /*#__PURE__*/jsxRuntime.jsx(JsonEditor, {
|
|
978
|
+
initialValue: dotPath("".concat(name, ".body"), values),
|
|
979
|
+
name: "".concat(name, ".body"),
|
|
980
|
+
variables: selectedField === null || selectedField === void 0 ? void 0 : selectedField.variables,
|
|
784
981
|
onFocus: setFieldActive
|
|
785
982
|
})]
|
|
786
983
|
});
|
|
@@ -2670,7 +2867,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2670
2867
|
});
|
|
2671
2868
|
}
|
|
2672
2869
|
if ((selectedField === null || selectedField === void 0 ? void 0 : selectedField.type) === ACTION_TYPES.longText || (selectedField === null || selectedField === void 0 ? void 0 : selectedField.type) === ACTION_TYPES.textarea) {
|
|
2673
|
-
var _action$metadata6, _action$metadata7;
|
|
2674
2870
|
return isTarget ? /*#__PURE__*/jsxRuntime.jsx(LongTextField.Target, {
|
|
2675
2871
|
hasError: hasError,
|
|
2676
2872
|
index: index,
|
|
@@ -2678,7 +2874,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2678
2874
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2679
2875
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2680
2876
|
name: "".concat(name, ".value"),
|
|
2681
|
-
value: (_action$metadata6 = action.metadata) === null || _action$metadata6 === void 0 ? void 0 : _action$metadata6.value,
|
|
2682
2877
|
onClick: function onClick() {
|
|
2683
2878
|
return openPanel("large");
|
|
2684
2879
|
}
|
|
@@ -2688,8 +2883,7 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2688
2883
|
shouldAutoFocus: true,
|
|
2689
2884
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2690
2885
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2691
|
-
name: "".concat(name, ".value")
|
|
2692
|
-
value: (_action$metadata7 = action.metadata) === null || _action$metadata7 === void 0 ? void 0 : _action$metadata7.value
|
|
2886
|
+
name: "".concat(name, ".value")
|
|
2693
2887
|
});
|
|
2694
2888
|
}
|
|
2695
2889
|
if (selectedField !== null && selectedField !== void 0 && selectedField.component) {
|
|
@@ -3591,18 +3785,15 @@ var ValueField = function ValueField(_ref) {
|
|
|
3591
3785
|
});
|
|
3592
3786
|
}
|
|
3593
3787
|
if (fieldType === constants.CONDITION_VALUE_TYPES.textarea) {
|
|
3594
|
-
var _condition$metadata, _condition$metadata2;
|
|
3595
3788
|
return isTarget ? /*#__PURE__*/jsxRuntime.jsx(LongTextField.Target, {
|
|
3596
3789
|
index: index,
|
|
3597
3790
|
onClick: onClick,
|
|
3598
3791
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3599
|
-
name: "".concat(name, ".value")
|
|
3600
|
-
value: (_condition$metadata = condition.metadata) === null || _condition$metadata === void 0 ? void 0 : _condition$metadata.value
|
|
3792
|
+
name: "".concat(name, ".value")
|
|
3601
3793
|
}) : /*#__PURE__*/jsxRuntime.jsx(LongTextField, {
|
|
3602
3794
|
index: index,
|
|
3603
3795
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3604
|
-
name: "".concat(name, ".value")
|
|
3605
|
-
value: (_condition$metadata2 = condition.metadata) === null || _condition$metadata2 === void 0 ? void 0 : _condition$metadata2.value
|
|
3796
|
+
name: "".concat(name, ".value")
|
|
3606
3797
|
});
|
|
3607
3798
|
}
|
|
3608
3799
|
if (fieldType === constants.CONDITION_VALUE_TYPES.radio) {
|
|
@@ -4356,7 +4547,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4356
4547
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4357
4548
|
})).required(i18next.t("neetoRules.validations.required.entity", {
|
|
4358
4549
|
entity: i18next.t("neetoRules.labels.endpoint")
|
|
4359
|
-
}))
|
|
4550
|
+
})),
|
|
4551
|
+
body: yup__namespace.string().trim().required(i18next.t("neetoRules.validations.required.entity", {
|
|
4552
|
+
entity: i18next.t("neetoRules.labels.body")
|
|
4553
|
+
})).test("is-valid-json-and-not-empty", function (value, context) {
|
|
4554
|
+
if (!value) return true;
|
|
4555
|
+
try {
|
|
4556
|
+
var parsedValue = JSON.parse(value);
|
|
4557
|
+
if (neetoCist.isNotPresent(parsedValue)) {
|
|
4558
|
+
return context.createError({
|
|
4559
|
+
message: i18next.t("neetoRules.validations.required.entity", {
|
|
4560
|
+
entity: i18next.t("neetoRules.labels.body")
|
|
4561
|
+
})
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
return true;
|
|
4565
|
+
} catch (_unused) {
|
|
4566
|
+
return context.createError({
|
|
4567
|
+
message: i18next.t("neetoRules.validations.invalidJsonBody")
|
|
4568
|
+
});
|
|
4569
|
+
}
|
|
4570
|
+
})
|
|
4360
4571
|
});
|
|
4361
4572
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4362
4573
|
return yup__namespace.object({
|
|
@@ -5693,7 +5904,7 @@ var Status = function Status() {
|
|
|
5693
5904
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5694
5905
|
setFieldValue("status.value", status);
|
|
5695
5906
|
};
|
|
5696
|
-
return /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
5907
|
+
return /*#__PURE__*/jsxRuntime.jsx(Switch$1, {
|
|
5697
5908
|
checked: defaultValue === ENABLED,
|
|
5698
5909
|
label: t("neetoRules.labels.active"),
|
|
5699
5910
|
labelProps: {
|