@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
|
@@ -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,
|
|
8
|
+
import { findBy, noop, isNotEmpty, isPresent, hyphenate, renameKeys, nullSafe, 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19lcnJvci1ib3VuZGFyeS5zY3NzIiwiYXBwL2phdmFzY3JpcHQvc3JjL3N0eWxlc2hlZXRzL21haW4uc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19sYXlvdXQuc2NzcyIsImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19wYW5lLnNjc3MiLCJhcHAvamF2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zIHtcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgdG9wOiAxcmVtO1xuICAgIHJpZ2h0OiAxcmVtO1xuICAgIHotaW5kZXg6IDEwO1xuICB9XG59XG4iXX0= */";
|
|
67
70
|
n(css,{});
|
|
68
71
|
|
|
69
72
|
var useActiveField = function useActiveField(name) {
|
|
@@ -507,15 +510,20 @@ var DEFAULT_LONG_TEXT_ROWS = 8;
|
|
|
507
510
|
var Target$j = function Target(_ref) {
|
|
508
511
|
var _errors$actions, _touched$actions, _selectedField$separa;
|
|
509
512
|
var index = _ref.index,
|
|
513
|
+
name = _ref.name,
|
|
510
514
|
_ref$selectedField = _ref.selectedField,
|
|
511
515
|
selectedField = _ref$selectedField === void 0 ? {} : _ref$selectedField,
|
|
512
516
|
defaultLabel = _ref.defaultLabel,
|
|
513
517
|
defaultSeparator = _ref.defaultSeparator,
|
|
514
|
-
|
|
518
|
+
_ref$onClick = _ref.onClick,
|
|
519
|
+
_onClick = _ref$onClick === void 0 ? noop : _ref$onClick;
|
|
515
520
|
var _useFormikContext = useFormikContext(),
|
|
516
521
|
errors = _useFormikContext.errors,
|
|
517
522
|
touched = _useFormikContext.touched;
|
|
518
|
-
var
|
|
523
|
+
var _useActiveField = useActiveField(name),
|
|
524
|
+
isFieldActive = _useActiveField.isFieldActive,
|
|
525
|
+
setFieldActive = _useActiveField.setFieldActive;
|
|
526
|
+
var isFieldInvalid = errors.actions && 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]) && 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]);
|
|
519
527
|
var separator = (selectedField === null || selectedField === void 0 || (_selectedField$separa = selectedField.separator) === null || _selectedField$separa === void 0 ? void 0 : _selectedField$separa.toLowerCase()) || defaultSeparator;
|
|
520
528
|
var label = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.placeholder) || defaultLabel;
|
|
521
529
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
@@ -530,39 +538,60 @@ var Target$j = function Target(_ref) {
|
|
|
530
538
|
label: label.toLowerCase(),
|
|
531
539
|
style: "link",
|
|
532
540
|
className: classNames("neeto-ui-text-gray-800 neeto-ui-font-semibold underline", {
|
|
533
|
-
"neeto-ui-text-
|
|
541
|
+
"neeto-ui-text-accent-800": isFieldActive,
|
|
542
|
+
"neeto-ui-text-error-500": isFieldInvalid && !isFieldActive
|
|
534
543
|
}),
|
|
535
544
|
onClick: function onClick() {
|
|
536
|
-
|
|
545
|
+
_onClick();
|
|
546
|
+
setFieldActive();
|
|
537
547
|
}
|
|
538
548
|
})]
|
|
539
549
|
});
|
|
540
550
|
};
|
|
541
551
|
var LongTextField = function LongTextField(_ref2) {
|
|
542
552
|
var name = _ref2.name,
|
|
543
|
-
_ref2$value = _ref2.value,
|
|
544
|
-
value = _ref2$value === void 0 ? "" : _ref2$value,
|
|
545
553
|
_ref2$selectedField = _ref2.selectedField,
|
|
546
|
-
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField
|
|
554
|
+
selectedField = _ref2$selectedField === void 0 ? {} : _ref2$selectedField,
|
|
555
|
+
_ref2$shouldAutoFocus = _ref2.shouldAutoFocus,
|
|
556
|
+
shouldAutoFocus = _ref2$shouldAutoFocus === void 0 ? false : _ref2$shouldAutoFocus;
|
|
557
|
+
var _useActiveField2 = useActiveField(name, {
|
|
558
|
+
shouldAutoFocus: shouldAutoFocus
|
|
559
|
+
}),
|
|
560
|
+
ref = _useActiveField2.ref,
|
|
561
|
+
setFieldActive = _useActiveField2.setFieldActive;
|
|
547
562
|
var rows = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.rows) || DEFAULT_LONG_TEXT_ROWS;
|
|
548
563
|
return /*#__PURE__*/jsx(Textarea, {
|
|
549
564
|
name: name,
|
|
565
|
+
ref: ref,
|
|
550
566
|
rows: rows,
|
|
551
|
-
value: value,
|
|
552
567
|
required: true,
|
|
553
|
-
className: "w-full"
|
|
568
|
+
className: "w-full",
|
|
569
|
+
onFocus: setFieldActive
|
|
554
570
|
});
|
|
555
571
|
};
|
|
556
572
|
LongTextField.Target = Target$j;
|
|
557
573
|
|
|
558
|
-
var
|
|
574
|
+
var CUSTOM_HEADERS_INITIAL_VALUE = {
|
|
559
575
|
key: "",
|
|
560
576
|
value: ""
|
|
561
577
|
};
|
|
562
578
|
var SAMPLE_ENDPOINT = "https://example.com";
|
|
579
|
+
var JSON_LANGUAGE = "json";
|
|
580
|
+
var EDITOR_CONFIG = {
|
|
581
|
+
formatOnType: true,
|
|
582
|
+
formatOnPaste: true,
|
|
583
|
+
automaticLayout: true,
|
|
584
|
+
tabSize: 2,
|
|
585
|
+
minimap: {
|
|
586
|
+
enabled: false
|
|
587
|
+
},
|
|
588
|
+
scrollBeyondLastLine: false,
|
|
589
|
+
autoIndent: "full"
|
|
590
|
+
};
|
|
591
|
+
var API_REQUEST_FIELDS = ["endpoint", "body", "enableCustomHeaders", "customHeaders"];
|
|
563
592
|
|
|
564
593
|
var addOption = function addOption(arrayHelpers) {
|
|
565
|
-
return arrayHelpers.push(
|
|
594
|
+
return arrayHelpers.push(CUSTOM_HEADERS_INITIAL_VALUE);
|
|
566
595
|
};
|
|
567
596
|
var removeOption = function removeOption(_ref) {
|
|
568
597
|
var arrayHelpers = _ref.arrayHelpers,
|
|
@@ -577,8 +606,8 @@ var hasKeyOrValue = whereAny({
|
|
|
577
606
|
key: isNotEmpty,
|
|
578
607
|
value: isNotEmpty
|
|
579
608
|
});
|
|
580
|
-
var
|
|
581
|
-
return isPresent(
|
|
609
|
+
var formatCustomFields = function formatCustomFields(customFields) {
|
|
610
|
+
return isPresent(customFields) ? customFields : [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
582
611
|
};
|
|
583
612
|
|
|
584
613
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -587,30 +616,27 @@ var dotPath = useWith(path, [split(".")]);
|
|
|
587
616
|
var KeyValuePairsField = withT(function (_ref) {
|
|
588
617
|
var t = _ref.t,
|
|
589
618
|
name = _ref.name,
|
|
590
|
-
|
|
591
|
-
label = _ref$label === void 0 ? "" : _ref$label,
|
|
619
|
+
entity = _ref.entity,
|
|
592
620
|
onFocus = _ref.onFocus;
|
|
593
621
|
return /*#__PURE__*/jsx(FieldArray, {
|
|
594
622
|
name: name,
|
|
595
623
|
children: function children(arrayHelpers) {
|
|
596
|
-
var data = dotPath(name, arrayHelpers.form.values);
|
|
624
|
+
var data = dotPath(name, arrayHelpers.form.values) || [CUSTOM_HEADERS_INITIAL_VALUE];
|
|
597
625
|
var showDeleteButton = data.length > 1 || hasKeyOrValue(data[0]);
|
|
598
626
|
return /*#__PURE__*/jsxs("div", {
|
|
599
|
-
className: "space-y-3",
|
|
600
|
-
children: [
|
|
601
|
-
children: label
|
|
602
|
-
}), data.map(function (_, index) {
|
|
627
|
+
className: "flex flex-col space-y-3",
|
|
628
|
+
children: [data.map(function (_, index) {
|
|
603
629
|
return /*#__PURE__*/jsxs("div", {
|
|
604
630
|
className: "flex h-8 space-x-3",
|
|
605
631
|
children: [/*#__PURE__*/jsx(Input$1, {
|
|
606
632
|
onFocus: onFocus,
|
|
607
|
-
className: "w-
|
|
633
|
+
className: "w-1/3",
|
|
608
634
|
name: "".concat(name, ".").concat(index, ".key"),
|
|
609
635
|
placeholder: t("neetoRules.labels.key"),
|
|
610
636
|
type: "text"
|
|
611
637
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
612
638
|
onFocus: onFocus,
|
|
613
|
-
className: "w-3
|
|
639
|
+
className: "w-2/3",
|
|
614
640
|
name: "".concat(name, ".").concat(index, ".value"),
|
|
615
641
|
placeholder: t("neetoRules.labels.value"),
|
|
616
642
|
type: "text",
|
|
@@ -630,7 +656,10 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
630
656
|
}, index);
|
|
631
657
|
}), /*#__PURE__*/jsx(Button, {
|
|
632
658
|
onFocus: onFocus,
|
|
633
|
-
|
|
659
|
+
className: "w-30 ml-auto",
|
|
660
|
+
label: t("neetoRules.labels.addEntity", {
|
|
661
|
+
entity: entity
|
|
662
|
+
}),
|
|
634
663
|
style: "secondary",
|
|
635
664
|
onClick: function onClick() {
|
|
636
665
|
return addOption(arrayHelpers);
|
|
@@ -641,6 +670,167 @@ var KeyValuePairsField = withT(function (_ref) {
|
|
|
641
670
|
});
|
|
642
671
|
});
|
|
643
672
|
|
|
673
|
+
var CustomHeaders = function CustomHeaders(_ref) {
|
|
674
|
+
var name = _ref.name,
|
|
675
|
+
onFocus = _ref.onFocus;
|
|
676
|
+
var _useFormikContext = useFormikContext(),
|
|
677
|
+
values = _useFormikContext.values,
|
|
678
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
679
|
+
var _useTranslation = useTranslation(),
|
|
680
|
+
t = _useTranslation.t;
|
|
681
|
+
var switchName = "".concat(name, ".enableCustomHeaders");
|
|
682
|
+
var keyValuePairsFieldName = "".concat(name, ".customHeaders");
|
|
683
|
+
var isCustomHeadersEnabled = dotPath(switchName, values);
|
|
684
|
+
var handleChange = function handleChange(_ref2) {
|
|
685
|
+
var checked = _ref2.target.checked;
|
|
686
|
+
if (!checked) {
|
|
687
|
+
setFieldValue(keyValuePairsFieldName, [CUSTOM_HEADERS_INITIAL_VALUE]);
|
|
688
|
+
}
|
|
689
|
+
setFieldValue(switchName, checked);
|
|
690
|
+
};
|
|
691
|
+
var label = t("neetoRules.labels.includeHeaders");
|
|
692
|
+
return /*#__PURE__*/jsxs("div", {
|
|
693
|
+
className: "flex flex-col space-y-4 mb-4",
|
|
694
|
+
children: [/*#__PURE__*/jsx(Switch, {
|
|
695
|
+
label: label,
|
|
696
|
+
onFocus: onFocus,
|
|
697
|
+
"data-cy": "neeto-rules-api-fields-".concat(hyphenate(label), "-switch"),
|
|
698
|
+
name: switchName,
|
|
699
|
+
onChange: handleChange
|
|
700
|
+
}), isCustomHeadersEnabled && /*#__PURE__*/jsx(KeyValuePairsField, {
|
|
701
|
+
onFocus: onFocus,
|
|
702
|
+
entity: t("neetoRules.labels.headers"),
|
|
703
|
+
name: "".concat(name, ".customHeaders")
|
|
704
|
+
})]
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
var JsonEditor = function JsonEditor(_ref) {
|
|
709
|
+
var name = _ref.name,
|
|
710
|
+
onFocus = _ref.onFocus,
|
|
711
|
+
_ref$initialValue = _ref.initialValue,
|
|
712
|
+
initialValue = _ref$initialValue === void 0 ? "{}" : _ref$initialValue,
|
|
713
|
+
_ref$variables = _ref.variables,
|
|
714
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables;
|
|
715
|
+
var editorRef = useRef(null);
|
|
716
|
+
var completionProviderRef = useRef(null);
|
|
717
|
+
var _useField = useField(name),
|
|
718
|
+
_useField2 = _slicedToArray(_useField, 3);
|
|
719
|
+
_useField2[0];
|
|
720
|
+
var _useField2$ = _useField2[1],
|
|
721
|
+
touched = _useField2$.touched,
|
|
722
|
+
error = _useField2$.error,
|
|
723
|
+
_useField2$2 = _useField2[2],
|
|
724
|
+
setValue = _useField2$2.setValue,
|
|
725
|
+
setTouched = _useField2$2.setTouched;
|
|
726
|
+
var _useTranslation = useTranslation(),
|
|
727
|
+
t = _useTranslation.t;
|
|
728
|
+
var handleEditorDidMount = function handleEditorDidMount(editor, monaco) {
|
|
729
|
+
editorRef.current = editor;
|
|
730
|
+
completionProviderRef.current = monaco.languages.registerCompletionItemProvider(JSON_LANGUAGE, {
|
|
731
|
+
triggerCharacters: ["{"],
|
|
732
|
+
provideCompletionItems: function provideCompletionItems(model, position) {
|
|
733
|
+
var lineContent = model.getLineContent(position.lineNumber);
|
|
734
|
+
var beforeCursor = lineContent.slice(0, position.column - 1);
|
|
735
|
+
if (!beforeCursor.endsWith('"{')) {
|
|
736
|
+
return {
|
|
737
|
+
suggestions: []
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
var suggestions = variables.map(function (_ref2) {
|
|
741
|
+
var key = _ref2.key,
|
|
742
|
+
label = _ref2.label;
|
|
743
|
+
return {
|
|
744
|
+
label: label,
|
|
745
|
+
kind: monaco.languages.CompletionItemKind.Variable,
|
|
746
|
+
insertText: "{".concat(key, "}}"),
|
|
747
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
748
|
+
detail: t("neetoRules.apiFields.insertPlaceholder", {
|
|
749
|
+
label: label
|
|
750
|
+
})
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
return {
|
|
754
|
+
suggestions: suggestions
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
};
|
|
759
|
+
var insertVariable = function insertVariable(_ref3) {
|
|
760
|
+
var key = _ref3.key;
|
|
761
|
+
var editor = editorRef.current;
|
|
762
|
+
if (!editor) return;
|
|
763
|
+
var selection = editor.getSelection();
|
|
764
|
+
var range = {
|
|
765
|
+
startLineNumber: selection.startLineNumber,
|
|
766
|
+
startColumn: selection.startColumn,
|
|
767
|
+
endLineNumber: selection.endLineNumber,
|
|
768
|
+
endColumn: selection.endColumn
|
|
769
|
+
};
|
|
770
|
+
var text = "\"{{".concat(key, "}}\"");
|
|
771
|
+
editor.executeEdits("", [{
|
|
772
|
+
range: range,
|
|
773
|
+
text: text,
|
|
774
|
+
forceMoveMarkers: true
|
|
775
|
+
}]);
|
|
776
|
+
var position = editor.getPosition();
|
|
777
|
+
editor.setPosition({
|
|
778
|
+
lineNumber: position.lineNumber,
|
|
779
|
+
column: position.column + text.length
|
|
780
|
+
});
|
|
781
|
+
editor.focus();
|
|
782
|
+
};
|
|
783
|
+
var handleChange = function handleChange(value) {
|
|
784
|
+
setTouched(true);
|
|
785
|
+
setValue(value);
|
|
786
|
+
};
|
|
787
|
+
useEffect(function () {
|
|
788
|
+
var editor = editorRef.current;
|
|
789
|
+
if (!editor) return;
|
|
790
|
+
var currentValue = editor.getValue();
|
|
791
|
+
if (currentValue !== initialValue) {
|
|
792
|
+
editor.setValue(initialValue);
|
|
793
|
+
}
|
|
794
|
+
}, [initialValue]);
|
|
795
|
+
useEffect(function () {
|
|
796
|
+
return function () {
|
|
797
|
+
var _completionProviderRe;
|
|
798
|
+
(_completionProviderRe = completionProviderRef.current) === null || _completionProviderRe === void 0 || _completionProviderRe.dispose();
|
|
799
|
+
completionProviderRef.current = null;
|
|
800
|
+
};
|
|
801
|
+
}, []);
|
|
802
|
+
return /*#__PURE__*/jsxs("div", {
|
|
803
|
+
className: "space-y-2 mb-2",
|
|
804
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
805
|
+
required: true,
|
|
806
|
+
"data-cy": "api-field-body",
|
|
807
|
+
children: t("neetoRules.labels.body")
|
|
808
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
809
|
+
className: "neeto-rules-json-editor__wrapper",
|
|
810
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
811
|
+
className: "neeto-rules-json-editor__dynamic-variables",
|
|
812
|
+
children: /*#__PURE__*/jsx(DynamicVariables, {
|
|
813
|
+
variables: variables,
|
|
814
|
+
onVariableClick: insertVariable
|
|
815
|
+
})
|
|
816
|
+
}), /*#__PURE__*/jsx(Editor, {
|
|
817
|
+
onFocus: onFocus,
|
|
818
|
+
className: "neeto-rules-json-editor__editor",
|
|
819
|
+
defaultLanguage: JSON_LANGUAGE,
|
|
820
|
+
defaultValue: initialValue,
|
|
821
|
+
height: "100%",
|
|
822
|
+
options: EDITOR_CONFIG,
|
|
823
|
+
theme: "vs-dark",
|
|
824
|
+
onChange: handleChange,
|
|
825
|
+
onMount: handleEditorDidMount
|
|
826
|
+
}), error && touched && /*#__PURE__*/jsx("div", {
|
|
827
|
+
className: "neeto-ui-input__error",
|
|
828
|
+
children: error
|
|
829
|
+
})]
|
|
830
|
+
})]
|
|
831
|
+
});
|
|
832
|
+
};
|
|
833
|
+
|
|
644
834
|
var SelectTemplateField = function SelectTemplateField(_ref) {
|
|
645
835
|
var selectedField = _ref.selectedField,
|
|
646
836
|
templates = _ref.templates,
|
|
@@ -727,7 +917,8 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
727
917
|
var _useTranslation2 = useTranslation(),
|
|
728
918
|
t = _useTranslation2.t;
|
|
729
919
|
var _useFormikContext = useFormikContext(),
|
|
730
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
920
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
921
|
+
values = _useFormikContext.values;
|
|
731
922
|
var _useActiveField2 = useActiveField(name, {
|
|
732
923
|
shouldAutoFocus: shouldAutoFocus
|
|
733
924
|
}),
|
|
@@ -736,8 +927,10 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
736
927
|
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
737
928
|
var isTemplateSelectionEnabled = isPresent(templates);
|
|
738
929
|
var handleTemplateChange = function handleTemplateChange(template) {
|
|
739
|
-
|
|
740
|
-
|
|
930
|
+
API_REQUEST_FIELDS.forEach(function (key) {
|
|
931
|
+
var value = key === "customHeaders" ? formatCustomFields(template[key]) : template[key];
|
|
932
|
+
setFieldValue("".concat(name, ".").concat(key), value);
|
|
933
|
+
});
|
|
741
934
|
};
|
|
742
935
|
return /*#__PURE__*/jsxs("div", {
|
|
743
936
|
className: "w-full",
|
|
@@ -757,9 +950,13 @@ var ApiFields = function ApiFields(_ref2) {
|
|
|
757
950
|
ref: isTemplateSelectionEnabled ? null : ref,
|
|
758
951
|
type: "text",
|
|
759
952
|
onFocus: setFieldActive
|
|
760
|
-
}), /*#__PURE__*/jsx(
|
|
761
|
-
|
|
762
|
-
|
|
953
|
+
}), /*#__PURE__*/jsx(CustomHeaders, {
|
|
954
|
+
name: name,
|
|
955
|
+
onFocus: setFieldActive
|
|
956
|
+
}), /*#__PURE__*/jsx(JsonEditor, {
|
|
957
|
+
initialValue: dotPath("".concat(name, ".body"), values),
|
|
958
|
+
name: "".concat(name, ".body"),
|
|
959
|
+
variables: selectedField === null || selectedField === void 0 ? void 0 : selectedField.variables,
|
|
763
960
|
onFocus: setFieldActive
|
|
764
961
|
})]
|
|
765
962
|
});
|
|
@@ -2649,7 +2846,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2649
2846
|
});
|
|
2650
2847
|
}
|
|
2651
2848
|
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) {
|
|
2652
|
-
var _action$metadata6, _action$metadata7;
|
|
2653
2849
|
return isTarget ? /*#__PURE__*/jsx(LongTextField.Target, {
|
|
2654
2850
|
hasError: hasError,
|
|
2655
2851
|
index: index,
|
|
@@ -2657,7 +2853,6 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2657
2853
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2658
2854
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2659
2855
|
name: "".concat(name, ".value"),
|
|
2660
|
-
value: (_action$metadata6 = action.metadata) === null || _action$metadata6 === void 0 ? void 0 : _action$metadata6.value,
|
|
2661
2856
|
onClick: function onClick() {
|
|
2662
2857
|
return openPanel("large");
|
|
2663
2858
|
}
|
|
@@ -2667,8 +2862,7 @@ var ActionSubItem = function ActionSubItem(_ref) {
|
|
|
2667
2862
|
shouldAutoFocus: true,
|
|
2668
2863
|
defaultLabel: t("neetoRules.labels.body"),
|
|
2669
2864
|
defaultSeparator: t("neetoRules.common.as"),
|
|
2670
|
-
name: "".concat(name, ".value")
|
|
2671
|
-
value: (_action$metadata7 = action.metadata) === null || _action$metadata7 === void 0 ? void 0 : _action$metadata7.value
|
|
2865
|
+
name: "".concat(name, ".value")
|
|
2672
2866
|
});
|
|
2673
2867
|
}
|
|
2674
2868
|
if (selectedField !== null && selectedField !== void 0 && selectedField.component) {
|
|
@@ -3570,18 +3764,15 @@ var ValueField = function ValueField(_ref) {
|
|
|
3570
3764
|
});
|
|
3571
3765
|
}
|
|
3572
3766
|
if (fieldType === CONDITION_VALUE_TYPES.textarea) {
|
|
3573
|
-
var _condition$metadata, _condition$metadata2;
|
|
3574
3767
|
return isTarget ? /*#__PURE__*/jsx(LongTextField.Target, {
|
|
3575
3768
|
index: index,
|
|
3576
3769
|
onClick: onClick,
|
|
3577
3770
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3578
|
-
name: "".concat(name, ".value")
|
|
3579
|
-
value: (_condition$metadata = condition.metadata) === null || _condition$metadata === void 0 ? void 0 : _condition$metadata.value
|
|
3771
|
+
name: "".concat(name, ".value")
|
|
3580
3772
|
}) : /*#__PURE__*/jsx(LongTextField, {
|
|
3581
3773
|
index: index,
|
|
3582
3774
|
defaultLabel: t("neetoRules.labels.text"),
|
|
3583
|
-
name: "".concat(name, ".value")
|
|
3584
|
-
value: (_condition$metadata2 = condition.metadata) === null || _condition$metadata2 === void 0 ? void 0 : _condition$metadata2.value
|
|
3775
|
+
name: "".concat(name, ".value")
|
|
3585
3776
|
});
|
|
3586
3777
|
}
|
|
3587
3778
|
if (fieldType === CONDITION_VALUE_TYPES.radio) {
|
|
@@ -4335,7 +4526,27 @@ var getActionsSchema = function getActionsSchema(element, customData) {
|
|
|
4335
4526
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4336
4527
|
})).required(t$1("neetoRules.validations.required.entity", {
|
|
4337
4528
|
entity: t$1("neetoRules.labels.endpoint")
|
|
4338
|
-
}))
|
|
4529
|
+
})),
|
|
4530
|
+
body: yup.string().trim().required(t$1("neetoRules.validations.required.entity", {
|
|
4531
|
+
entity: t$1("neetoRules.labels.body")
|
|
4532
|
+
})).test("is-valid-json-and-not-empty", function (value, context) {
|
|
4533
|
+
if (!value) return true;
|
|
4534
|
+
try {
|
|
4535
|
+
var parsedValue = JSON.parse(value);
|
|
4536
|
+
if (isNotPresent(parsedValue)) {
|
|
4537
|
+
return context.createError({
|
|
4538
|
+
message: t$1("neetoRules.validations.required.entity", {
|
|
4539
|
+
entity: t$1("neetoRules.labels.body")
|
|
4540
|
+
})
|
|
4541
|
+
});
|
|
4542
|
+
}
|
|
4543
|
+
return true;
|
|
4544
|
+
} catch (_unused) {
|
|
4545
|
+
return context.createError({
|
|
4546
|
+
message: t$1("neetoRules.validations.invalidJsonBody")
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
})
|
|
4339
4550
|
});
|
|
4340
4551
|
} else if (ACTION_TYPES.multiSelect === (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type)) {
|
|
4341
4552
|
return yup.object({
|
|
@@ -5672,7 +5883,7 @@ var Status = function Status() {
|
|
|
5672
5883
|
var status = e.target.checked ? ENABLED : DISABLED;
|
|
5673
5884
|
setFieldValue("status.value", status);
|
|
5674
5885
|
};
|
|
5675
|
-
return /*#__PURE__*/jsx(Switch, {
|
|
5886
|
+
return /*#__PURE__*/jsx(Switch$1, {
|
|
5676
5887
|
checked: defaultValue === ENABLED,
|
|
5677
5888
|
label: t("neetoRules.labels.active"),
|
|
5678
5889
|
labelProps: {
|