@bigbinary/neeto-rules-frontend 2.7.21 → 2.7.23
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 +1 -0
- package/dist/.ready +1 -1
- package/dist/NeetoRulesBuilder.js +2 -2
- package/dist/NeetoRulesForm.js +2 -2
- package/dist/cjs/NeetoRulesBuilder.js +2 -2
- package/dist/cjs/NeetoRulesForm.js +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/v2/NeetoRulesBuilder.js +366 -175
- package/dist/cjs/v2/NeetoRulesBuilder.js.map +1 -1
- package/dist/cjs/v2/NeetoRulesForm.js +2 -2
- package/dist/cjs/v2/index.js +3 -2
- package/dist/cjs/v2/index.js.map +1 -1
- package/dist/{index-49edM85x.js → index-25TjDISc.js} +2 -2
- package/dist/{index-49edM85x.js.map → index-25TjDISc.js.map} +1 -1
- package/dist/{index-CcbW7H2S.js → index-CvpoP63h.js} +3 -3
- package/dist/{index-CcbW7H2S.js.map → index-CvpoP63h.js.map} +1 -1
- package/dist/{index-BZYwFjcS.js → index-D76EZ1AZ.js} +2 -2
- package/dist/{index-BZYwFjcS.js.map → index-D76EZ1AZ.js.map} +1 -1
- package/dist/{index-Fukq1VSN.js → index-puRtNWZV.js} +3 -2
- package/dist/{index-Fukq1VSN.js.map → index-puRtNWZV.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/keyboardShortcuts-CRInJJOU.js +96 -0
- package/dist/{keyboardShortcuts-DtnjcivY.js.map → keyboardShortcuts-CRInJJOU.js.map} +1 -1
- package/dist/keyboardShortcuts-DwgF8Mcu.js +92 -0
- package/dist/{keyboardShortcuts-_OrtgF0A.js.map → keyboardShortcuts-DwgF8Mcu.js.map} +1 -1
- package/dist/v2/NeetoRulesBuilder.js +373 -182
- package/dist/v2/NeetoRulesBuilder.js.map +1 -1
- package/dist/v2/NeetoRulesForm.js +2 -2
- package/dist/v2/index.js +3 -2
- package/dist/v2/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/keyboardShortcuts-DtnjcivY.js +0 -96
- package/dist/keyboardShortcuts-_OrtgF0A.js +0 -92
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
3
|
-
import { f as flatten, S as SHORTCUTS } from '../keyboardShortcuts-
|
|
3
|
+
import { f as flatten, S as SHORTCUTS } from '../keyboardShortcuts-DwgF8Mcu.js';
|
|
4
4
|
import { useShallow } from 'zustand/shallow';
|
|
5
|
-
import { useState, useRef, useEffect, createElement, Fragment as Fragment$1, useCallback, useMemo } from 'react';
|
|
6
|
-
import { Button, Input, Checkbox, Typography, RadioGroup, Textarea, DatePicker,
|
|
7
|
-
import { Input as Input$1, Select, ActionBlock } from '@bigbinary/neeto-atoms/formik';
|
|
5
|
+
import { useState, useRef, useEffect, createElement, Fragment as Fragment$1, useCallback, useMemo, isValidElement } from 'react';
|
|
6
|
+
import { Button, Select, Input, Checkbox, Typography, RadioGroup, Textarea, DatePicker, Popover, Tooltip, MultiEmailInput, Spinner } from '@bigbinary/neeto-atoms';
|
|
7
|
+
import { Input as Input$1, Select as Select$1, ActionBlock } from '@bigbinary/neeto-atoms/formik';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { useFormikContext, getIn, useField, Formik, Form as Form$1 } from 'formik';
|
|
10
10
|
import { isNotEmpty, toLabelAndValue, removeBy, isNot, noop } from '@bigbinary/neeto-cist';
|
|
11
11
|
import Container from '@bigbinary/neeto-molecules/v2/Container';
|
|
12
12
|
import Header from '@bigbinary/neeto-molecules/v2/Header';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
-
import { E as EditorAction, L as ListField, o as Panel,
|
|
14
|
+
import { r as ApiFields, E as EditorAction, L as ListField, o as Panel, s as ErrorCallout, t as SmsFields, M as MIN_DELAY_VALUE, v as MAX_DELAY_VALUE, w as PhoneNumberField, l as formatData, u as usePollRuleName, T as TouchErrors, n as ScrollToErrorField, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE, m as buildPayload } from '../index-CvpoP63h.js';
|
|
15
15
|
import { u as useCustomDataStore } from '../useCustomDataStore-CEbhXugO.js';
|
|
16
16
|
import { u as useUtilityStore } from '../useUtilityStore-BVCulMEC.js';
|
|
17
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -30,6 +30,7 @@ import { dayjs } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
|
30
30
|
import { D as DATE_FORMAT } from '../utils-DeqHhpwQ.js';
|
|
31
31
|
import Up from '@bigbinary/neeto-icons/Up';
|
|
32
32
|
import Down from '@bigbinary/neeto-icons/Down';
|
|
33
|
+
import Info from '@bigbinary/neeto-icons/Info';
|
|
33
34
|
import '@babel/runtime/helpers/typeof';
|
|
34
35
|
import '../useAutomationRulesApi-C9I3wUZ8.js';
|
|
35
36
|
import '@tanstack/react-query';
|
|
@@ -463,6 +464,18 @@ var actionParts = function actionParts(_ref11) {
|
|
|
463
464
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
464
465
|
};
|
|
465
466
|
};
|
|
467
|
+
|
|
468
|
+
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
469
|
+
// only support a subset. Lookups deliberately keep using the full list so a
|
|
470
|
+
// field already on the rule still resolves after the offer narrows.
|
|
471
|
+
var offeredConditionFields = function offeredConditionFields(_ref12) {
|
|
472
|
+
var _ref13, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
473
|
+
var schema = _ref12.schema,
|
|
474
|
+
rule = _ref12.rule;
|
|
475
|
+
return (_ref13 = (_schema$conditions$fi = schema === null || schema === void 0 || (_schema$conditions3 = schema.conditions) === null || _schema$conditions3 === void 0 || (_schema$conditions3$f = _schema$conditions3.fieldsFor) === null || _schema$conditions3$f === void 0 ? void 0 : _schema$conditions3$f.call(_schema$conditions3, {
|
|
476
|
+
rule: rule
|
|
477
|
+
})) !== null && _schema$conditions$fi !== void 0 ? _schema$conditions$fi : schema === null || schema === void 0 || (_schema$conditions4 = schema.conditions) === null || _schema$conditions4 === void 0 ? void 0 : _schema$conditions4.fields) !== null && _ref13 !== void 0 ? _ref13 : [];
|
|
478
|
+
};
|
|
466
479
|
var hasTrigger = function hasTrigger(rule) {
|
|
467
480
|
return !isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
468
481
|
};
|
|
@@ -471,31 +484,54 @@ var hasAction = function hasAction(rule) {
|
|
|
471
484
|
return action === null || action === void 0 ? void 0 : action.name;
|
|
472
485
|
});
|
|
473
486
|
};
|
|
474
|
-
var
|
|
475
|
-
|
|
487
|
+
var isTriggerEnabled = function isTriggerEnabled(schema) {
|
|
488
|
+
var _schema$triggers2;
|
|
489
|
+
return (schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.enabled) !== false;
|
|
490
|
+
};
|
|
491
|
+
var isTriggerSatisfied = function isTriggerSatisfied(_ref14) {
|
|
492
|
+
var rule = _ref14.rule,
|
|
493
|
+
schema = _ref14.schema;
|
|
494
|
+
return !isTriggerEnabled(schema) || hasTrigger(rule);
|
|
495
|
+
};
|
|
496
|
+
var hasRequiredConditions = function hasRequiredConditions(_ref15) {
|
|
497
|
+
var _schema$conditions5;
|
|
498
|
+
var rule = _ref15.rule,
|
|
499
|
+
schema = _ref15.schema;
|
|
500
|
+
return (schema === null || schema === void 0 || (_schema$conditions5 = schema.conditions) === null || _schema$conditions5 === void 0 ? void 0 : _schema$conditions5.allowEmpty) === false ? isNotEmpty((rule === null || rule === void 0 ? void 0 : rule.conditions) || []) : true;
|
|
501
|
+
};
|
|
502
|
+
var isRuleComplete = function isRuleComplete(_ref16) {
|
|
503
|
+
var rule = _ref16.rule,
|
|
504
|
+
schema = _ref16.schema;
|
|
505
|
+
return isTriggerSatisfied({
|
|
506
|
+
rule: rule,
|
|
507
|
+
schema: schema
|
|
508
|
+
}) && hasRequiredConditions({
|
|
509
|
+
rule: rule,
|
|
510
|
+
schema: schema
|
|
511
|
+
}) && hasAction(rule);
|
|
476
512
|
};
|
|
477
|
-
var scopeOptionFor = function scopeOptionFor(
|
|
513
|
+
var scopeOptionFor = function scopeOptionFor(_ref17) {
|
|
478
514
|
var _item$value, _schema$scope;
|
|
479
|
-
var schema =
|
|
480
|
-
item =
|
|
515
|
+
var schema = _ref17.schema,
|
|
516
|
+
item = _ref17.item;
|
|
481
517
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
482
518
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
483
519
|
var _candidate$value2;
|
|
484
520
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
485
521
|
});
|
|
486
522
|
};
|
|
487
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
488
|
-
var
|
|
489
|
-
var schema =
|
|
490
|
-
item =
|
|
491
|
-
return (
|
|
523
|
+
var scopePhoneFields = function scopePhoneFields(_ref18) {
|
|
524
|
+
var _ref19, _item$phoneFields, _scopeOptionFor;
|
|
525
|
+
var schema = _ref18.schema,
|
|
526
|
+
item = _ref18.item;
|
|
527
|
+
return (_ref19 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
492
528
|
schema: schema,
|
|
493
529
|
item: item
|
|
494
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
530
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref19 !== void 0 ? _ref19 : null;
|
|
495
531
|
};
|
|
496
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
497
|
-
var schema =
|
|
498
|
-
item =
|
|
532
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref20) {
|
|
533
|
+
var schema = _ref20.schema,
|
|
534
|
+
item = _ref20.item;
|
|
499
535
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
500
536
|
var phoneFields = scopePhoneFields({
|
|
501
537
|
schema: schema,
|
|
@@ -503,14 +539,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
|
|
|
503
539
|
});
|
|
504
540
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
505
541
|
};
|
|
506
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
542
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref21) {
|
|
507
543
|
var _scope$requiresPhone;
|
|
508
|
-
var rule =
|
|
509
|
-
schema =
|
|
544
|
+
var rule = _ref21.rule,
|
|
545
|
+
schema = _ref21.schema;
|
|
510
546
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
511
547
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
512
548
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
513
|
-
var
|
|
549
|
+
var _ref22, _item$hasPhoneField;
|
|
514
550
|
var option = scopeOptionFor({
|
|
515
551
|
schema: schema,
|
|
516
552
|
item: item
|
|
@@ -519,15 +555,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
|
|
|
519
555
|
schema: schema,
|
|
520
556
|
item: item
|
|
521
557
|
});
|
|
522
|
-
var hasPhoneField = (
|
|
558
|
+
var hasPhoneField = (_ref22 = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField) !== null && _ref22 !== void 0 ? _ref22 : phoneFields ? phoneFields.length > 0 : undefined;
|
|
523
559
|
if (hasPhoneField === false) indexes.push(index);
|
|
524
560
|
return indexes;
|
|
525
561
|
}, []);
|
|
526
562
|
};
|
|
527
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
563
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref23) {
|
|
528
564
|
var _scope$requiresPhone2;
|
|
529
|
-
var rule =
|
|
530
|
-
schema =
|
|
565
|
+
var rule = _ref23.rule,
|
|
566
|
+
schema = _ref23.schema;
|
|
531
567
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
532
568
|
if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
|
|
533
569
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
@@ -564,9 +600,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
564
600
|
unit: "minutes"
|
|
565
601
|
};
|
|
566
602
|
};
|
|
567
|
-
var partsToMinutes = function partsToMinutes(
|
|
568
|
-
var value =
|
|
569
|
-
unit =
|
|
603
|
+
var partsToMinutes = function partsToMinutes(_ref24) {
|
|
604
|
+
var value = _ref24.value,
|
|
605
|
+
unit = _ref24.unit;
|
|
570
606
|
return (
|
|
571
607
|
// eslint-disable-next-line security/detect-object-injection
|
|
572
608
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -576,8 +612,8 @@ var leadTimeExceedsMax = function leadTimeExceedsMax(minutes) {
|
|
|
576
612
|
return minutesToParts(minutes).value > MAX_LEAD_TIME_VALUE;
|
|
577
613
|
};
|
|
578
614
|
var leadTimeValidationSchema = function leadTimeValidationSchema(schema) {
|
|
579
|
-
var _schema$
|
|
580
|
-
var fieldKey = schema === null || schema === void 0 || (_schema$
|
|
615
|
+
var _schema$triggers3;
|
|
616
|
+
var fieldKey = schema === null || schema === void 0 || (_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 || (_schema$triggers3 = _schema$triggers3.leadTime) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey;
|
|
581
617
|
if (!fieldKey) return yup.object();
|
|
582
618
|
return yup.object().shape(_defineProperty({}, fieldKey, yup.object().shape({
|
|
583
619
|
// yup 0.32 can only concat schemas of the same type, and the host's
|
|
@@ -621,25 +657,25 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
|
621
657
|
};
|
|
622
658
|
|
|
623
659
|
// eslint-disable-next-line security/detect-object-injection
|
|
624
|
-
var valueAt = function valueAt(
|
|
660
|
+
var valueAt = function valueAt(_ref25) {
|
|
625
661
|
var _values$key;
|
|
626
|
-
var values =
|
|
627
|
-
key =
|
|
662
|
+
var values = _ref25.values,
|
|
663
|
+
key = _ref25.key;
|
|
628
664
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
629
665
|
};
|
|
630
666
|
var asArray = function asArray(maybeArray) {
|
|
631
667
|
return Array.isArray(maybeArray) ? maybeArray : [];
|
|
632
668
|
};
|
|
633
669
|
var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
634
|
-
var _schema$
|
|
670
|
+
var _schema$triggers4, _schema$actor2, _schema$conditions6, _schema$actions3, _schema$delay, _schema$triggers5, _schema$scope2;
|
|
635
671
|
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
636
672
|
return {
|
|
637
|
-
triggers: ((_schema$
|
|
673
|
+
triggers: ((_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey) || "events",
|
|
638
674
|
performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
|
|
639
|
-
conditions: ((_schema$
|
|
675
|
+
conditions: ((_schema$conditions6 = schema.conditions) === null || _schema$conditions6 === void 0 ? void 0 : _schema$conditions6.fieldKey) || "conditions",
|
|
640
676
|
actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
|
|
641
677
|
delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
|
|
642
|
-
leadTime: (_schema$
|
|
678
|
+
leadTime: (_schema$triggers5 = schema.triggers) === null || _schema$triggers5 === void 0 || (_schema$triggers5 = _schema$triggers5.leadTime) === null || _schema$triggers5 === void 0 ? void 0 : _schema$triggers5.fieldKey,
|
|
643
679
|
scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
|
|
644
680
|
status: "status",
|
|
645
681
|
name: "name"
|
|
@@ -647,11 +683,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
647
683
|
};
|
|
648
684
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
649
685
|
var _valueAt, _conditions$;
|
|
650
|
-
var
|
|
651
|
-
|
|
652
|
-
values =
|
|
653
|
-
|
|
654
|
-
schema =
|
|
686
|
+
var _ref26 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
687
|
+
_ref26$values = _ref26.values,
|
|
688
|
+
values = _ref26$values === void 0 ? {} : _ref26$values,
|
|
689
|
+
_ref26$schema = _ref26.schema,
|
|
690
|
+
schema = _ref26$schema === void 0 ? {} : _ref26$schema;
|
|
655
691
|
var keys = fieldKeysFromSchema(schema);
|
|
656
692
|
var conditions = asArray(valueAt({
|
|
657
693
|
values: values,
|
|
@@ -695,42 +731,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
695
731
|
}))
|
|
696
732
|
};
|
|
697
733
|
};
|
|
698
|
-
var setTriggers = function setTriggers(
|
|
699
|
-
var schema =
|
|
700
|
-
triggers =
|
|
734
|
+
var setTriggers = function setTriggers(_ref27) {
|
|
735
|
+
var schema = _ref27.schema,
|
|
736
|
+
triggers = _ref27.triggers;
|
|
701
737
|
return {
|
|
702
738
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
703
739
|
value: triggers
|
|
704
740
|
};
|
|
705
741
|
};
|
|
706
|
-
var setPerformer = function setPerformer(
|
|
707
|
-
var schema =
|
|
708
|
-
performer =
|
|
742
|
+
var setPerformer = function setPerformer(_ref28) {
|
|
743
|
+
var schema = _ref28.schema,
|
|
744
|
+
performer = _ref28.performer;
|
|
709
745
|
return {
|
|
710
746
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
711
747
|
value: performer
|
|
712
748
|
};
|
|
713
749
|
};
|
|
714
|
-
var setActions = function setActions(
|
|
715
|
-
var schema =
|
|
716
|
-
actions =
|
|
750
|
+
var setActions = function setActions(_ref29) {
|
|
751
|
+
var schema = _ref29.schema,
|
|
752
|
+
actions = _ref29.actions;
|
|
717
753
|
return {
|
|
718
754
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
719
755
|
value: actions
|
|
720
756
|
};
|
|
721
757
|
};
|
|
722
|
-
var setConditions = function setConditions(
|
|
723
|
-
var schema =
|
|
724
|
-
conditions =
|
|
758
|
+
var setConditions = function setConditions(_ref30) {
|
|
759
|
+
var schema = _ref30.schema,
|
|
760
|
+
conditions = _ref30.conditions;
|
|
725
761
|
return {
|
|
726
762
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
727
763
|
value: conditions
|
|
728
764
|
};
|
|
729
765
|
};
|
|
730
|
-
var setConditionMode = function setConditionMode(
|
|
731
|
-
var schema =
|
|
732
|
-
conditions =
|
|
733
|
-
joinType =
|
|
766
|
+
var setConditionMode = function setConditionMode(_ref31) {
|
|
767
|
+
var schema = _ref31.schema,
|
|
768
|
+
conditions = _ref31.conditions,
|
|
769
|
+
joinType = _ref31.joinType;
|
|
734
770
|
return setConditions({
|
|
735
771
|
schema: schema,
|
|
736
772
|
conditions: conditions.map(function (condition) {
|
|
@@ -738,34 +774,34 @@ var setConditionMode = function setConditionMode(_ref26) {
|
|
|
738
774
|
})
|
|
739
775
|
});
|
|
740
776
|
};
|
|
741
|
-
var setDelay = function setDelay(
|
|
742
|
-
var schema =
|
|
743
|
-
delay =
|
|
777
|
+
var setDelay = function setDelay(_ref32) {
|
|
778
|
+
var schema = _ref32.schema,
|
|
779
|
+
delay = _ref32.delay;
|
|
744
780
|
return {
|
|
745
781
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
746
782
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
747
783
|
};
|
|
748
784
|
};
|
|
749
|
-
var setActive = function setActive(
|
|
750
|
-
var schema =
|
|
751
|
-
active =
|
|
785
|
+
var setActive = function setActive(_ref33) {
|
|
786
|
+
var schema = _ref33.schema,
|
|
787
|
+
active = _ref33.active;
|
|
752
788
|
return {
|
|
753
789
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
754
790
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
755
791
|
};
|
|
756
792
|
};
|
|
757
|
-
var setScope = function setScope(
|
|
758
|
-
var schema =
|
|
759
|
-
scope =
|
|
793
|
+
var setScope = function setScope(_ref34) {
|
|
794
|
+
var schema = _ref34.schema,
|
|
795
|
+
scope = _ref34.scope;
|
|
760
796
|
return {
|
|
761
797
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
762
798
|
value: scope
|
|
763
799
|
};
|
|
764
800
|
};
|
|
765
|
-
var removeArrayItem = function removeArrayItem(
|
|
766
|
-
var values =
|
|
767
|
-
fieldKey =
|
|
768
|
-
index =
|
|
801
|
+
var removeArrayItem = function removeArrayItem(_ref35) {
|
|
802
|
+
var values = _ref35.values,
|
|
803
|
+
fieldKey = _ref35.fieldKey,
|
|
804
|
+
index = _ref35.index;
|
|
769
805
|
var list = asArray(valueAt({
|
|
770
806
|
values: values,
|
|
771
807
|
key: fieldKey
|
|
@@ -792,9 +828,9 @@ var removeArrayItem = function removeArrayItem(_ref30) {
|
|
|
792
828
|
}
|
|
793
829
|
return result;
|
|
794
830
|
};
|
|
795
|
-
var clearArrayItems = function clearArrayItems(
|
|
796
|
-
var values =
|
|
797
|
-
fieldKey =
|
|
831
|
+
var clearArrayItems = function clearArrayItems(_ref36) {
|
|
832
|
+
var values = _ref36.values,
|
|
833
|
+
fieldKey = _ref36.fieldKey;
|
|
798
834
|
var list = asArray(valueAt({
|
|
799
835
|
values: values,
|
|
800
836
|
key: fieldKey
|
|
@@ -870,13 +906,13 @@ var ConditionRow = function ConditionRow(_ref) {
|
|
|
870
906
|
className: "mb-sentence",
|
|
871
907
|
children: [isFirst ? /*#__PURE__*/jsx("span", {
|
|
872
908
|
className: "mb-fixed",
|
|
873
|
-
children: t("neetoRules.operators.and")
|
|
909
|
+
children: isTriggerEnabled(schema) ? t("neetoRules.operators.and") : t("neetoRules.common.when")
|
|
874
910
|
}) : /*#__PURE__*/jsx(Token, {
|
|
875
911
|
active: isActive({
|
|
876
912
|
type: BUILDER_ANCHORS.COND_CONNECTOR,
|
|
877
913
|
index: index
|
|
878
914
|
}),
|
|
879
|
-
className: "mb-tok-
|
|
915
|
+
className: "mb-tok-connector",
|
|
880
916
|
dataTestid: "cond-connector-".concat(index),
|
|
881
917
|
onClick: handleToken && function () {
|
|
882
918
|
return handleToken({
|
|
@@ -1099,8 +1135,8 @@ var MetaBlock = function MetaBlock(_ref) {
|
|
|
1099
1135
|
className: "mb-meta-label",
|
|
1100
1136
|
children: t("neetoRules.builder.automationName")
|
|
1101
1137
|
}), /*#__PURE__*/jsxs("div", {
|
|
1102
|
-
ref: nameRef,
|
|
1103
1138
|
"data-testid": "rule-name-edit",
|
|
1139
|
+
ref: nameRef,
|
|
1104
1140
|
role: handleEditName ? "button" : undefined,
|
|
1105
1141
|
tabIndex: handleEditName ? 0 : undefined,
|
|
1106
1142
|
className: classNames("mb-meta-input-wrap", {
|
|
@@ -1373,7 +1409,10 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1373
1409
|
paramKind = _actionParts.paramKind,
|
|
1374
1410
|
valueNoun = _actionParts.valueNoun,
|
|
1375
1411
|
valueNounPlural = _actionParts.valueNounPlural;
|
|
1376
|
-
|
|
1412
|
+
|
|
1413
|
+
// A separator-less action still needs a value slot when the host declares a
|
|
1414
|
+
// placeholder for it, otherwise its chosen value never reaches the canvas.
|
|
1415
|
+
var hasParamTail = paramKind === PARAM_KIND.ENUM_SINGLE || paramKind === PARAM_KIND.ENUM_MULTI || !!configValuePlaceholder || !!configValue;
|
|
1377
1416
|
var multiPlaceholder = valueNounPlural ? t("neetoRules.builder.selectNoun", {
|
|
1378
1417
|
noun: valueNounPlural
|
|
1379
1418
|
}) : t("neetoRules.form.selectValues");
|
|
@@ -1391,12 +1430,66 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1391
1430
|
index: index
|
|
1392
1431
|
});
|
|
1393
1432
|
var configLabel = mediumLabel || sentencify(option === null || option === void 0 ? void 0 : option.placeholder);
|
|
1433
|
+
// A host may declare two separators: the first introduces the recipient
|
|
1434
|
+
// ("whose email is"), the second the configured value ("with the following").
|
|
1435
|
+
var _ref2 = Array.isArray(separator) ? separator : [null, separator],
|
|
1436
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
1437
|
+
recipientSeparator = _ref3[0],
|
|
1438
|
+
configSeparator = _ref3[1];
|
|
1394
1439
|
var isConfigured = isNotEmpty(action === null || action === void 0 ? void 0 : action.metadata);
|
|
1395
1440
|
// A host that shows no value label still needs the token to read as filled.
|
|
1396
1441
|
var configState = configValue || isConfigured ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED;
|
|
1397
1442
|
var _useClearingHover = useClearingHover(),
|
|
1398
1443
|
clearing = _useClearingHover.clearing,
|
|
1399
1444
|
clearingHoverProps = _useClearingHover.clearingHoverProps;
|
|
1445
|
+
var configToken = configSeparator ? /*#__PURE__*/jsxs(Fragment$1, {
|
|
1446
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1447
|
+
className: "mb-fixed",
|
|
1448
|
+
children: configSeparator
|
|
1449
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1450
|
+
active: isActive({
|
|
1451
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1452
|
+
index: index
|
|
1453
|
+
}),
|
|
1454
|
+
dataTestid: "action-config-value-".concat(index),
|
|
1455
|
+
state: configState,
|
|
1456
|
+
invalid: isInvalid({
|
|
1457
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1458
|
+
index: index
|
|
1459
|
+
}),
|
|
1460
|
+
onClick: handleToken && function () {
|
|
1461
|
+
return handleToken({
|
|
1462
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1463
|
+
index: index
|
|
1464
|
+
});
|
|
1465
|
+
},
|
|
1466
|
+
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1467
|
+
})]
|
|
1468
|
+
}, "config") : null;
|
|
1469
|
+
var recipientToken = needsRecipient ? /*#__PURE__*/jsxs(Fragment$1, {
|
|
1470
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1471
|
+
className: "mb-fixed",
|
|
1472
|
+
children: recipientSeparator || t("neetoRules.common.to")
|
|
1473
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1474
|
+
dataTestid: "action-recipient-".concat(index),
|
|
1475
|
+
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1476
|
+
active: isActive({
|
|
1477
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1478
|
+
index: index
|
|
1479
|
+
}),
|
|
1480
|
+
invalid: isInvalid({
|
|
1481
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1482
|
+
index: index
|
|
1483
|
+
}),
|
|
1484
|
+
onClick: handleToken && function () {
|
|
1485
|
+
return handleToken({
|
|
1486
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1487
|
+
index: index
|
|
1488
|
+
});
|
|
1489
|
+
},
|
|
1490
|
+
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1491
|
+
})]
|
|
1492
|
+
}, "recipient") : null;
|
|
1400
1493
|
return /*#__PURE__*/jsxs("div", {
|
|
1401
1494
|
className: classNames("mb-row mb-row-draggable", {
|
|
1402
1495
|
clearing: clearing
|
|
@@ -1406,7 +1499,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1406
1499
|
children: [/*#__PURE__*/jsx("span", {
|
|
1407
1500
|
className: "mb-fixed",
|
|
1408
1501
|
children: connector
|
|
1409
|
-
}),
|
|
1502
|
+
}), configSeparator ? /*#__PURE__*/jsxs(Token, {
|
|
1410
1503
|
active: isVerbActive,
|
|
1411
1504
|
className: "mb-tok-medium",
|
|
1412
1505
|
dataTestid: "action-verb-".concat(index),
|
|
@@ -1447,7 +1540,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1447
1540
|
index: index
|
|
1448
1541
|
});
|
|
1449
1542
|
},
|
|
1450
|
-
children: configValue || paramPlaceholder
|
|
1543
|
+
children: configValue || sentencify(configValuePlaceholder) || paramPlaceholder
|
|
1451
1544
|
}) : configLabel && /*#__PURE__*/jsxs(Token, {
|
|
1452
1545
|
className: "mb-tok-medium",
|
|
1453
1546
|
dataTestid: "action-config-".concat(index),
|
|
@@ -1470,53 +1563,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1470
1563
|
size: 14
|
|
1471
1564
|
}), configLabel]
|
|
1472
1565
|
})]
|
|
1473
|
-
}),
|
|
1474
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
1475
|
-
className: "mb-fixed",
|
|
1476
|
-
children: separator
|
|
1477
|
-
}), /*#__PURE__*/jsx(Token, {
|
|
1478
|
-
active: isActive({
|
|
1479
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1480
|
-
index: index
|
|
1481
|
-
}),
|
|
1482
|
-
dataTestid: "action-config-value-".concat(index),
|
|
1483
|
-
state: configState,
|
|
1484
|
-
invalid: isInvalid({
|
|
1485
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1486
|
-
index: index
|
|
1487
|
-
}),
|
|
1488
|
-
onClick: handleToken && function () {
|
|
1489
|
-
return handleToken({
|
|
1490
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1491
|
-
index: index
|
|
1492
|
-
});
|
|
1493
|
-
},
|
|
1494
|
-
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1495
|
-
})]
|
|
1496
|
-
}), needsRecipient && /*#__PURE__*/jsxs(Fragment, {
|
|
1497
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
1498
|
-
className: "mb-fixed",
|
|
1499
|
-
children: t("neetoRules.common.to")
|
|
1500
|
-
}), /*#__PURE__*/jsx(Token, {
|
|
1501
|
-
dataTestid: "action-recipient-".concat(index),
|
|
1502
|
-
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1503
|
-
active: isActive({
|
|
1504
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1505
|
-
index: index
|
|
1506
|
-
}),
|
|
1507
|
-
invalid: isInvalid({
|
|
1508
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1509
|
-
index: index
|
|
1510
|
-
}),
|
|
1511
|
-
onClick: handleToken && function () {
|
|
1512
|
-
return handleToken({
|
|
1513
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1514
|
-
index: index
|
|
1515
|
-
});
|
|
1516
|
-
},
|
|
1517
|
-
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1518
|
-
})]
|
|
1519
|
-
})]
|
|
1566
|
+
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken]]
|
|
1520
1567
|
}), /*#__PURE__*/jsxs("div", {
|
|
1521
1568
|
className: "mb-row-actions",
|
|
1522
1569
|
children: [handleAddAction && /*#__PURE__*/jsx(Button, {
|
|
@@ -1572,7 +1619,10 @@ var ThenBlock = function ThenBlock(_ref) {
|
|
|
1572
1619
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
1573
1620
|
});
|
|
1574
1621
|
if (isEmpty(named)) {
|
|
1575
|
-
var isTriggerSet =
|
|
1622
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
1623
|
+
rule: rule,
|
|
1624
|
+
schema: schema
|
|
1625
|
+
});
|
|
1576
1626
|
return /*#__PURE__*/jsx("div", {
|
|
1577
1627
|
className: "mb-row",
|
|
1578
1628
|
children: /*#__PURE__*/jsx("div", {
|
|
@@ -1664,6 +1714,21 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1664
1714
|
var _schema$triggers;
|
|
1665
1715
|
return ((schema === null || schema === void 0 || (_schema$triggers = schema.triggers) === null || _schema$triggers === void 0 || (_schema$triggers = _schema$triggers.leadTime) === null || _schema$triggers === void 0 ? void 0 : _schema$triggers.appliesTo) || []).includes(name);
|
|
1666
1716
|
};
|
|
1717
|
+
if (!isTriggerEnabled(schema)) {
|
|
1718
|
+
if (!isEmpty(rule.conditions)) return null;
|
|
1719
|
+
return /*#__PURE__*/jsx("div", {
|
|
1720
|
+
className: "mb-row",
|
|
1721
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1722
|
+
className: "mb-sentence",
|
|
1723
|
+
children: /*#__PURE__*/jsx(Token, {
|
|
1724
|
+
dataTestid: "condition-add",
|
|
1725
|
+
state: TOKEN_STATE.PLACEHOLDER_NEXT,
|
|
1726
|
+
onClick: handleAddCondition || undefined,
|
|
1727
|
+
children: t("neetoRules.builder.whenThisIsTrue")
|
|
1728
|
+
})
|
|
1729
|
+
})
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1667
1732
|
if (isEmpty(triggers)) {
|
|
1668
1733
|
return /*#__PURE__*/jsx("div", {
|
|
1669
1734
|
className: "mb-row",
|
|
@@ -2216,7 +2281,7 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2216
2281
|
});
|
|
2217
2282
|
};
|
|
2218
2283
|
var descriptorFor = function descriptorFor(_ref15) {
|
|
2219
|
-
var _schema$actor2
|
|
2284
|
+
var _schema$actor2;
|
|
2220
2285
|
var anchor = _ref15.anchor,
|
|
2221
2286
|
schema = _ref15.schema,
|
|
2222
2287
|
rule = _ref15.rule,
|
|
@@ -2262,7 +2327,10 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2262
2327
|
title: t("neetoRules.builder.panes.addCondition"),
|
|
2263
2328
|
subtitle: t("neetoRules.builder.panes.condFieldSubtitle"),
|
|
2264
2329
|
cascade: true,
|
|
2265
|
-
options: (
|
|
2330
|
+
options: offeredConditionFields({
|
|
2331
|
+
schema: schema,
|
|
2332
|
+
rule: rule
|
|
2333
|
+
}).map(function (field) {
|
|
2266
2334
|
return {
|
|
2267
2335
|
label: field.paneLabel || field.label,
|
|
2268
2336
|
value: optionValue(field),
|
|
@@ -2276,7 +2344,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2276
2344
|
};
|
|
2277
2345
|
case BUILDER_ANCHORS.COND_OP_TOGGLE:
|
|
2278
2346
|
{
|
|
2279
|
-
var _schema$
|
|
2347
|
+
var _schema$conditions2;
|
|
2280
2348
|
var field = findField({
|
|
2281
2349
|
schema: schema,
|
|
2282
2350
|
value: conditionAt({
|
|
@@ -2284,7 +2352,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2284
2352
|
index: index
|
|
2285
2353
|
}).field
|
|
2286
2354
|
});
|
|
2287
|
-
var labels = ((_schema$
|
|
2355
|
+
var labels = ((_schema$conditions2 = schema.conditions) === null || _schema$conditions2 === void 0 ? void 0 : _schema$conditions2.operatorLabels) || {};
|
|
2288
2356
|
var verbs = (field === null || field === void 0 ? void 0 : field.allowMatching) || [];
|
|
2289
2357
|
var fieldLabel = (field === null || field === void 0 ? void 0 : field.paneLabel) || (field === null || field === void 0 ? void 0 : field.label) || "";
|
|
2290
2358
|
var isContains = isNotEmpty(verbs) && verbs.every(isContainsVerb);
|
|
@@ -2348,13 +2416,18 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2348
2416
|
subtitle: isSwap ? t("neetoRules.builder.panes.actionSwapSubtitle") : t("neetoRules.builder.panes.actionAddSubtitle"),
|
|
2349
2417
|
cascade: true,
|
|
2350
2418
|
options: sourceOptions.map(function (option) {
|
|
2419
|
+
var _option$disabled;
|
|
2351
2420
|
var value = optionValue(option);
|
|
2352
2421
|
var meta = channelMetaFor(value);
|
|
2353
2422
|
return {
|
|
2354
2423
|
label: isSwap ? meta.channelLabel || option.label : option.label,
|
|
2355
2424
|
value: value,
|
|
2356
2425
|
category: option.category,
|
|
2357
|
-
|
|
2426
|
+
// Hosts mark unavailable actions with isDisabled; without carrying
|
|
2427
|
+
// the reason across, the picker disables them with no explanation.
|
|
2428
|
+
disabled: !!((_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : option.isDisabled),
|
|
2429
|
+
disabledReason: option.disabledReason,
|
|
2430
|
+
disabledPopover: option.disabledPopover,
|
|
2358
2431
|
icon: (isSwap ? meta.icon : option.icon) || option.icon
|
|
2359
2432
|
};
|
|
2360
2433
|
}),
|
|
@@ -2402,7 +2475,10 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2402
2475
|
selectedValues: [recipientOf({
|
|
2403
2476
|
schema: schema,
|
|
2404
2477
|
action: action
|
|
2405
|
-
})]
|
|
2478
|
+
})],
|
|
2479
|
+
// Confirming a recipient always offers Continue; whether that chains
|
|
2480
|
+
// onward or just closes is decided by continueTargetFor.
|
|
2481
|
+
cascade: true
|
|
2406
2482
|
};
|
|
2407
2483
|
}
|
|
2408
2484
|
case BUILDER_ANCHORS.SCOPE:
|
|
@@ -2419,14 +2495,16 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2419
2495
|
subtitle: sc.paneSubtitle || t("neetoRules.builder.panes.scopeSubtitle"),
|
|
2420
2496
|
multi: true,
|
|
2421
2497
|
options: (sc.options || []).map(function (option) {
|
|
2498
|
+
var _option$disabled2;
|
|
2422
2499
|
var value = optionValue(option);
|
|
2423
2500
|
var blockedNoPhone = requiresPhone && option.hasPhoneField === false;
|
|
2424
2501
|
var isSelected = selected.includes(value);
|
|
2425
2502
|
return {
|
|
2426
2503
|
label: option.label,
|
|
2427
2504
|
value: value,
|
|
2428
|
-
disabled: (!!option.disabled || blockedNoPhone) && !isSelected,
|
|
2429
|
-
disabledReason: blockedNoPhone
|
|
2505
|
+
disabled: (!!((_option$disabled2 = option.disabled) !== null && _option$disabled2 !== void 0 ? _option$disabled2 : option.isDisabled) || blockedNoPhone) && !isSelected,
|
|
2506
|
+
disabledReason: blockedNoPhone ? sc.disabledReason : option.disabledReason,
|
|
2507
|
+
disabledPopover: option.disabledPopover,
|
|
2430
2508
|
disabledTooltip: blockedNoPhone && sc.disabledTooltip
|
|
2431
2509
|
};
|
|
2432
2510
|
}),
|
|
@@ -2583,7 +2661,8 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2583
2661
|
var anchor = _ref17.anchor,
|
|
2584
2662
|
schema = _ref17.schema,
|
|
2585
2663
|
rule = _ref17.rule,
|
|
2586
|
-
index = _ref17.index
|
|
2664
|
+
index = _ref17.index,
|
|
2665
|
+
configPending = _ref17.configPending;
|
|
2587
2666
|
switch (anchor) {
|
|
2588
2667
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2589
2668
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2639,6 +2718,9 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2639
2718
|
}
|
|
2640
2719
|
};
|
|
2641
2720
|
}
|
|
2721
|
+
|
|
2722
|
+
// Reached here only because the action has no config yet — its name is
|
|
2723
|
+
// still unresolved — so the recipient pane owes us that step afterwards.
|
|
2642
2724
|
return channelMetaOf({
|
|
2643
2725
|
schema: schema,
|
|
2644
2726
|
action: action
|
|
@@ -2646,12 +2728,30 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2646
2728
|
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
2647
2729
|
data: {
|
|
2648
2730
|
index: index,
|
|
2649
|
-
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
2731
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
2732
|
+
configPending: true
|
|
2650
2733
|
}
|
|
2651
2734
|
} : null;
|
|
2652
2735
|
}
|
|
2653
2736
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2654
|
-
|
|
2737
|
+
{
|
|
2738
|
+
// Only chain onward when config was skipped on the way in; arriving from
|
|
2739
|
+
// the config pane or from the token means this is the last step.
|
|
2740
|
+
var _action = actionAt({
|
|
2741
|
+
rule: rule,
|
|
2742
|
+
index: index
|
|
2743
|
+
});
|
|
2744
|
+
return configPending && actionHasConfig({
|
|
2745
|
+
schema: schema,
|
|
2746
|
+
action: _action
|
|
2747
|
+
}) ? {
|
|
2748
|
+
type: BUILDER_PANEL_TYPES.ACTION_CONFIG,
|
|
2749
|
+
data: {
|
|
2750
|
+
index: index,
|
|
2751
|
+
anchor: BUILDER_ANCHORS.ACTION_CONFIG
|
|
2752
|
+
}
|
|
2753
|
+
} : null;
|
|
2754
|
+
}
|
|
2655
2755
|
default:
|
|
2656
2756
|
return null;
|
|
2657
2757
|
}
|
|
@@ -2767,7 +2867,7 @@ var applyPreview = function applyPreview(_ref19) {
|
|
|
2767
2867
|
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2768
2868
|
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2769
2869
|
var Canvas = function Canvas(_ref) {
|
|
2770
|
-
var _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2870
|
+
var _schema$actor2, _ref6, _actorOptions$0$value, _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2771
2871
|
var schema = _ref.schema;
|
|
2772
2872
|
var _useTranslation = useTranslation(),
|
|
2773
2873
|
t = _useTranslation.t;
|
|
@@ -2822,7 +2922,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
2822
2922
|
useEffect(function () {
|
|
2823
2923
|
if (submitCount <= lastSubmitCount.current) return undefined;
|
|
2824
2924
|
lastSubmitCount.current = submitCount;
|
|
2825
|
-
if (isEmpty(flatErrors) && isRuleComplete(
|
|
2925
|
+
if (isEmpty(flatErrors) && isRuleComplete({
|
|
2926
|
+
rule: rule,
|
|
2927
|
+
schema: schema
|
|
2928
|
+
}) && isEmpty(invalidScopeIndexes({
|
|
2826
2929
|
rule: rule,
|
|
2827
2930
|
schema: schema
|
|
2828
2931
|
})) && isEmpty(invalidScopePhoneFieldIndexes({
|
|
@@ -2986,7 +3089,15 @@ var Canvas = function Canvas(_ref) {
|
|
|
2986
3089
|
});
|
|
2987
3090
|
setDelay(null);
|
|
2988
3091
|
};
|
|
2989
|
-
|
|
3092
|
+
|
|
3093
|
+
// An actor with a single choice is not a choice; leaving it unset only makes
|
|
3094
|
+
// the user open a one-option pane to say the obvious.
|
|
3095
|
+
var actorOptions = schema !== null && schema !== void 0 && (_schema$actor2 = schema.actor) !== null && _schema$actor2 !== void 0 && _schema$actor2.enabled ? schema.actor.options || [] : [];
|
|
3096
|
+
var soleActorOption = actorOptions.length === 1 ? (_ref6 = (_actorOptions$0$value = actorOptions[0].value) !== null && _actorOptions$0$value !== void 0 ? _actorOptions$0$value : actorOptions[0].id) !== null && _ref6 !== void 0 ? _ref6 : actorOptions[0] : null;
|
|
3097
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
3098
|
+
rule: rule,
|
|
3099
|
+
schema: schema
|
|
3100
|
+
});
|
|
2990
3101
|
var hasAction = rule.actions.some(function (action) {
|
|
2991
3102
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
2992
3103
|
});
|
|
@@ -3000,13 +3111,21 @@ var Canvas = function Canvas(_ref) {
|
|
|
3000
3111
|
return i !== index;
|
|
3001
3112
|
}));
|
|
3002
3113
|
};
|
|
3003
|
-
var conditionFields = (
|
|
3114
|
+
var conditionFields = offeredConditionFields({
|
|
3115
|
+
schema: schema,
|
|
3116
|
+
rule: rule
|
|
3117
|
+
});
|
|
3004
3118
|
var canAddCondition = isNotEmpty(conditionFields);
|
|
3119
|
+
var canRemoveCondition = (schema === null || schema === void 0 || (_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.allowEmpty) !== false || displayRule.conditions.length > 1;
|
|
3005
3120
|
var leadTimeAppliesTo = (schema === null || schema === void 0 || (_schema$triggers = schema.triggers) === null || _schema$triggers === void 0 || (_schema$triggers = _schema$triggers.leadTime) === null || _schema$triggers === void 0 ? void 0 : _schema$triggers.appliesTo) || [];
|
|
3006
3121
|
var hasLeadTimeTrigger = rule.triggers.some(function (trigger) {
|
|
3007
3122
|
return leadTimeAppliesTo.includes(trigger.name);
|
|
3008
3123
|
});
|
|
3009
3124
|
var isDelayEnabled = (schema === null || schema === void 0 || (_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.enabled) && !hasLeadTimeTrigger;
|
|
3125
|
+
useEffect(function () {
|
|
3126
|
+
if (soleActorOption && !rule.performer) setPerformer(soleActorOption);
|
|
3127
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3128
|
+
}, [soleActorOption, rule.performer]);
|
|
3010
3129
|
useEffect(function () {
|
|
3011
3130
|
if (hasLeadTimeTrigger && rule.delay) setDelay(null);
|
|
3012
3131
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3023,10 +3142,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
3023
3142
|
});
|
|
3024
3143
|
};
|
|
3025
3144
|
var handleClearTrigger = function handleClearTrigger() {
|
|
3026
|
-
var _schema$
|
|
3145
|
+
var _schema$actor3;
|
|
3027
3146
|
clearTriggers();
|
|
3028
3147
|
// Hosts without an actor pane can never re-set it, and null fails its validation.
|
|
3029
|
-
if ((_schema$
|
|
3148
|
+
if ((_schema$actor3 = schema.actor) !== null && _schema$actor3 !== void 0 && _schema$actor3.enabled) setPerformer(soleActorOption);
|
|
3030
3149
|
clearConditions();
|
|
3031
3150
|
setDelay(null);
|
|
3032
3151
|
clearActions();
|
|
@@ -3054,7 +3173,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3054
3173
|
className: "neeto-rules-builder nrb-atoms",
|
|
3055
3174
|
children: /*#__PURE__*/jsxs("div", {
|
|
3056
3175
|
className: "mb-canvas neeto-rules-main-card",
|
|
3057
|
-
children: [/*#__PURE__*/jsx(WhenBlock, {
|
|
3176
|
+
children: [renderSlot("beforeWhen"), /*#__PURE__*/jsx(WhenBlock, {
|
|
3058
3177
|
isActive: isActive,
|
|
3059
3178
|
isInvalid: isInvalid,
|
|
3060
3179
|
schema: schema,
|
|
@@ -3072,11 +3191,11 @@ var Canvas = function Canvas(_ref) {
|
|
|
3072
3191
|
schema: schema,
|
|
3073
3192
|
key: (_condition$id = condition.id) !== null && _condition$id !== void 0 ? _condition$id : index,
|
|
3074
3193
|
rule: displayRule,
|
|
3075
|
-
onRemove: function onRemove() {
|
|
3076
|
-
return handleRemoveCondition(index);
|
|
3077
|
-
},
|
|
3078
3194
|
onToken: openPane,
|
|
3079
|
-
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition
|
|
3195
|
+
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition,
|
|
3196
|
+
onRemove: canRemoveCondition && function () {
|
|
3197
|
+
return handleRemoveCondition(index);
|
|
3198
|
+
}
|
|
3080
3199
|
});
|
|
3081
3200
|
}), renderSlot("afterConditions"), /*#__PURE__*/jsx(Connector, {
|
|
3082
3201
|
active: isTriggerSet
|
|
@@ -3148,6 +3267,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3148
3267
|
|
|
3149
3268
|
var ACTION_CONFIG_TYPES = {
|
|
3150
3269
|
emailChannel: "emailChannel",
|
|
3270
|
+
sendToApi: "sendToApi",
|
|
3151
3271
|
multiSelect: "multiSelect",
|
|
3152
3272
|
dropdown: "dropdown",
|
|
3153
3273
|
note: "note",
|
|
@@ -3174,7 +3294,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3174
3294
|
option = _ref.option,
|
|
3175
3295
|
action = _ref.action,
|
|
3176
3296
|
_ref$searchTerm = _ref.searchTerm,
|
|
3177
|
-
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm
|
|
3297
|
+
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm,
|
|
3298
|
+
_ref$hasRecipientFiel = _ref.hasRecipientField,
|
|
3299
|
+
hasRecipientField = _ref$hasRecipientFiel === void 0 ? false : _ref$hasRecipientFiel;
|
|
3178
3300
|
var _useTranslation = useTranslation(),
|
|
3179
3301
|
t = _useTranslation.t;
|
|
3180
3302
|
var _useFormikContext = useFormikContext(),
|
|
@@ -3216,19 +3338,42 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3216
3338
|
"data-testid": "pane-no-matches",
|
|
3217
3339
|
children: t("neetoRules.builder.noMatches")
|
|
3218
3340
|
});
|
|
3341
|
+
if (type === ACTION_CONFIG_TYPES.sendToApi) {
|
|
3342
|
+
return /*#__PURE__*/jsx(ApiFields, {
|
|
3343
|
+
name: name,
|
|
3344
|
+
selectedField: option
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3219
3347
|
if (type === ACTION_CONFIG_TYPES.emailChannel) {
|
|
3220
|
-
var _getIn, _action$metadata;
|
|
3348
|
+
var _getIn, _getIn2, _action$metadata;
|
|
3221
3349
|
var subjectPath = "".concat(name, ".subject");
|
|
3222
3350
|
var bodyPath = "".concat(name, ".body");
|
|
3351
|
+
// Hosts whose email action picks its recipient from a list keep that
|
|
3352
|
+
// choice in the same pane as the message.
|
|
3353
|
+
var hasRecipientList = isNotEmpty(options) && !hasRecipientField;
|
|
3223
3354
|
return /*#__PURE__*/jsxs("div", {
|
|
3224
3355
|
className: "flex flex-col gap-4",
|
|
3225
|
-
children: [
|
|
3356
|
+
children: [hasRecipientList && /*#__PURE__*/jsx(Select, {
|
|
3357
|
+
options: options,
|
|
3358
|
+
required: true,
|
|
3359
|
+
error: fieldError(valuePath),
|
|
3360
|
+
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3361
|
+
size: "large",
|
|
3362
|
+
value: (_getIn = getIn(values, valuePath)) !== null && _getIn !== void 0 ? _getIn : undefined,
|
|
3363
|
+
label: (option === null || option === void 0 ? void 0 : option.recipientLabel) || t("neetoRules.builder.config.recipient"),
|
|
3364
|
+
onBlur: function onBlur() {
|
|
3365
|
+
return setFieldTouched(valuePath, true);
|
|
3366
|
+
},
|
|
3367
|
+
onChange: function onChange(value) {
|
|
3368
|
+
return setFieldValue(valuePath, value);
|
|
3369
|
+
}
|
|
3370
|
+
}), !(option !== null && option !== void 0 && option.hideSubject) && /*#__PURE__*/jsx(Input, {
|
|
3226
3371
|
required: true,
|
|
3227
3372
|
error: fieldError(subjectPath),
|
|
3228
3373
|
label: t("neetoRules.builder.config.subject"),
|
|
3229
3374
|
placeholder: t("neetoRules.builder.config.subjectPlaceholder"),
|
|
3230
3375
|
size: "large",
|
|
3231
|
-
value: (
|
|
3376
|
+
value: (_getIn2 = getIn(values, subjectPath)) !== null && _getIn2 !== void 0 ? _getIn2 : "",
|
|
3232
3377
|
onBlur: function onBlur() {
|
|
3233
3378
|
return setFieldTouched(subjectPath, true);
|
|
3234
3379
|
},
|
|
@@ -3280,9 +3425,6 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3280
3425
|
error: fieldError(valuePath),
|
|
3281
3426
|
orientation: "vertical",
|
|
3282
3427
|
value: String(_current !== null && _current !== void 0 ? _current : ""),
|
|
3283
|
-
onBlur: function onBlur() {
|
|
3284
|
-
return setFieldTouched(valuePath, true);
|
|
3285
|
-
},
|
|
3286
3428
|
onValueChange: function onValueChange(value) {
|
|
3287
3429
|
var picked = options.find(function (item) {
|
|
3288
3430
|
return String(item.value) === value;
|
|
@@ -3320,14 +3462,14 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3320
3462
|
});
|
|
3321
3463
|
}
|
|
3322
3464
|
if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
|
|
3323
|
-
var
|
|
3465
|
+
var _getIn3, _getIn4;
|
|
3324
3466
|
return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsx(Input, {
|
|
3325
3467
|
required: true,
|
|
3326
3468
|
error: fieldError(valuePath),
|
|
3327
3469
|
label: t("neetoRules.builder.config.value"),
|
|
3328
3470
|
size: "large",
|
|
3329
3471
|
type: "number",
|
|
3330
|
-
value: (
|
|
3472
|
+
value: (_getIn3 = getIn(values, valuePath)) !== null && _getIn3 !== void 0 ? _getIn3 : "",
|
|
3331
3473
|
onBlur: function onBlur() {
|
|
3332
3474
|
return setFieldTouched(valuePath, true);
|
|
3333
3475
|
},
|
|
@@ -3340,7 +3482,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3340
3482
|
label: t("neetoRules.builder.config.message"),
|
|
3341
3483
|
rows: 5,
|
|
3342
3484
|
size: "large",
|
|
3343
|
-
value: (
|
|
3485
|
+
value: (_getIn4 = getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
|
|
3344
3486
|
onBlur: function onBlur() {
|
|
3345
3487
|
return setFieldTouched(valuePath, true);
|
|
3346
3488
|
},
|
|
@@ -3350,7 +3492,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3350
3492
|
});
|
|
3351
3493
|
}
|
|
3352
3494
|
if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
|
|
3353
|
-
var
|
|
3495
|
+
var _getIn5;
|
|
3354
3496
|
return /*#__PURE__*/jsxs("div", {
|
|
3355
3497
|
className: "flex flex-col gap-2",
|
|
3356
3498
|
children: [/*#__PURE__*/jsx(Input, {
|
|
@@ -3359,7 +3501,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3359
3501
|
label: t("neetoRules.builder.config.value"),
|
|
3360
3502
|
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3361
3503
|
size: "large",
|
|
3362
|
-
value: (
|
|
3504
|
+
value: (_getIn5 = getIn(values, valuePath)) !== null && _getIn5 !== void 0 ? _getIn5 : "",
|
|
3363
3505
|
onBlur: function onBlur() {
|
|
3364
3506
|
return setFieldTouched(valuePath, true);
|
|
3365
3507
|
},
|
|
@@ -3470,7 +3612,7 @@ var usePaneValidation = function usePaneValidation(prefix) {
|
|
|
3470
3612
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
3471
3613
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3472
3614
|
var ConfigPane = function ConfigPane(_ref) {
|
|
3473
|
-
var _schema$actions, _schema$actions$optio, _schema$actions2, _schema$actions2$opti, _schema$actions3, _schema$
|
|
3615
|
+
var _schema$actions, _schema$actions$optio, _schema$actions2, _schema$actions2$opti, _action$recipient, _schema$actions3, _schema$actions3$acti, _concat$find, _schema$actions4, _schema$actions5, _schema$actions6, _schema$actions7, _schema$actions7$opti, _hostRenderConfig;
|
|
3474
3616
|
var schema = _ref.schema,
|
|
3475
3617
|
index = _ref.index;
|
|
3476
3618
|
var _useTranslation = useTranslation(),
|
|
@@ -3505,14 +3647,24 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3505
3647
|
configSubtitle = _actionParts.configSubtitle;
|
|
3506
3648
|
var name = "".concat(base, ".metadata");
|
|
3507
3649
|
var flatOption = ((_schema$actions = schema.actions) === null || _schema$actions === void 0 || (_schema$actions$optio = _schema$actions.optionForName) === null || _schema$actions$optio === void 0 ? void 0 : _schema$actions$optio.call(_schema$actions, action.name)) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$opti = _schema$actions2.optionForChannel) === null || _schema$actions2$opti === void 0 ? void 0 : _schema$actions2$opti.call(_schema$actions2, channel)) || option;
|
|
3650
|
+
|
|
3651
|
+
// When the chosen recipient declares its own field, the recipient pane
|
|
3652
|
+
// renders it; showing the same picker here too would just duplicate it.
|
|
3653
|
+
var recipientValue = (_action$recipient = action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$acti = _schema$actions3.actionForName) === null || _schema$actions3$acti === void 0 || (_schema$actions3$acti = _schema$actions3$acti.call(_schema$actions3, action.name)) === null || _schema$actions3$acti === void 0 ? void 0 : _schema$actions3$acti.recipient;
|
|
3654
|
+
var hasRecipientField = !!((_concat$find = (((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 ? void 0 : _schema$actions4.recipients) || []).concat((((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 ? void 0 : _schema$actions5.options) || []).flatMap(function (o) {
|
|
3655
|
+
return o.recipients || [];
|
|
3656
|
+
})).find(function (item) {
|
|
3657
|
+
var _item$value;
|
|
3658
|
+
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipientValue;
|
|
3659
|
+
})) !== null && _concat$find !== void 0 && _concat$find.field);
|
|
3508
3660
|
var isSms = SMS_TYPES.includes(flatOption === null || flatOption === void 0 ? void 0 : flatOption.type);
|
|
3509
3661
|
var disabledReason = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.isDisabled) && flatOption.disabledReason;
|
|
3510
|
-
var hostRenderConfig = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.renderConfig) || (flatOption === null || flatOption === void 0 ? void 0 : flatOption.component) || ((_schema$
|
|
3662
|
+
var hostRenderConfig = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.renderConfig) || (flatOption === null || flatOption === void 0 ? void 0 : flatOption.component) || ((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.renderConfig);
|
|
3511
3663
|
var showSearch = normalizeOptions(flatOption === null || flatOption === void 0 ? void 0 : flatOption.dropdownOptions).length >= PANE_SEARCH_THRESHOLD;
|
|
3512
3664
|
var shouldAdvanceToRecipient = !!needsRecipient;
|
|
3513
3665
|
var _usePaneValidation = usePaneValidation(name),
|
|
3514
3666
|
validate = _usePaneValidation.validate;
|
|
3515
|
-
var channelRepName = (_schema$
|
|
3667
|
+
var channelRepName = (_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 || (_schema$actions7$opti = _schema$actions7.optionForChannel) === null || _schema$actions7$opti === void 0 || (_schema$actions7$opti = _schema$actions7$opti.call(_schema$actions7, channel)) === null || _schema$actions7$opti === void 0 ? void 0 : _schema$actions7$opti.value;
|
|
3516
3668
|
var unnamedOnOpen = useRef(!action.name);
|
|
3517
3669
|
useEffect(function () {
|
|
3518
3670
|
if (!unnamedOnOpen.current || !channelRepName) return undefined;
|
|
@@ -3631,6 +3783,7 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3631
3783
|
searchTerm: searchTerm
|
|
3632
3784
|
})) !== null && _hostRenderConfig !== void 0 ? _hostRenderConfig : /*#__PURE__*/jsx(ActionConfigFields, {
|
|
3633
3785
|
action: action,
|
|
3786
|
+
hasRecipientField: hasRecipientField,
|
|
3634
3787
|
name: name,
|
|
3635
3788
|
searchTerm: searchTerm,
|
|
3636
3789
|
option: flatOption
|
|
@@ -3723,7 +3876,7 @@ var DelayPane = function DelayPane(_ref) {
|
|
|
3723
3876
|
placeholder: t("neetoRules.placeholders.enterDelay"),
|
|
3724
3877
|
size: "large",
|
|
3725
3878
|
type: "number"
|
|
3726
|
-
}), /*#__PURE__*/jsx(Select, {
|
|
3879
|
+
}), /*#__PURE__*/jsx(Select$1, {
|
|
3727
3880
|
dataTestid: "delay-unit",
|
|
3728
3881
|
defaultValue: value === null || value === void 0 ? void 0 : value.unit,
|
|
3729
3882
|
name: "".concat(name, ".value.unit"),
|
|
@@ -3910,7 +4063,7 @@ var LeadTimePane = function LeadTimePane(_ref) {
|
|
|
3910
4063
|
})
|
|
3911
4064
|
}), /*#__PURE__*/jsx("div", {
|
|
3912
4065
|
className: "w-32 shrink-0",
|
|
3913
|
-
children: /*#__PURE__*/jsx(Select
|
|
4066
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
3914
4067
|
dataTestid: "lead-time-unit",
|
|
3915
4068
|
isSearchable: false,
|
|
3916
4069
|
options: LEAD_TIME_UNITS,
|
|
@@ -3969,7 +4122,9 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
3969
4122
|
anchor = _ref.anchor,
|
|
3970
4123
|
index = _ref.index,
|
|
3971
4124
|
_ref$belowContent = _ref.belowContent,
|
|
3972
|
-
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent
|
|
4125
|
+
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent,
|
|
4126
|
+
_ref$configPending = _ref.configPending,
|
|
4127
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
3973
4128
|
var _useTranslation = useTranslation(),
|
|
3974
4129
|
t = _useTranslation.t;
|
|
3975
4130
|
var _useFormikContext = useFormikContext(),
|
|
@@ -4075,7 +4230,8 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4075
4230
|
anchor: anchor,
|
|
4076
4231
|
schema: schema,
|
|
4077
4232
|
rule: rule,
|
|
4078
|
-
index: index
|
|
4233
|
+
index: index,
|
|
4234
|
+
configPending: configPending
|
|
4079
4235
|
});
|
|
4080
4236
|
if (target) openType({
|
|
4081
4237
|
type: target.type,
|
|
@@ -4089,21 +4245,53 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4089
4245
|
});
|
|
4090
4246
|
var optionLabel = function optionLabel(option) {
|
|
4091
4247
|
var Icon = option.icon;
|
|
4092
|
-
|
|
4248
|
+
// Short text sits inline as a pill; anything needing more room is a
|
|
4249
|
+
// standard popover behind an info icon.
|
|
4250
|
+
var reason = typeof option.disabledReason === "function" ? option.disabledReason() : option.disabledReason;
|
|
4251
|
+
var isTextReason = typeof reason === "string";
|
|
4252
|
+
// Only a node can be rendered as popover content; a host handing back a
|
|
4253
|
+
// plain object would otherwise crash the pane.
|
|
4254
|
+
var isNodeReason = /*#__PURE__*/isValidElement(reason) || Array.isArray(reason);
|
|
4255
|
+
var popover = option.disabledPopover || (isNodeReason ? {
|
|
4256
|
+
description: reason
|
|
4257
|
+
} : null);
|
|
4258
|
+
if (!Icon && !isTextReason && !popover) return option.label;
|
|
4093
4259
|
return /*#__PURE__*/jsxs("span", {
|
|
4094
4260
|
className: "mb-pane-option",
|
|
4095
4261
|
children: [Icon && /*#__PURE__*/jsx(Icon, {
|
|
4096
4262
|
size: 20
|
|
4097
|
-
}), option.label,
|
|
4263
|
+
}), option.label, popover && /*#__PURE__*/jsxs(Popover, {
|
|
4264
|
+
position: "top",
|
|
4265
|
+
trigger: /*#__PURE__*/jsx("span", {
|
|
4266
|
+
className: "mb-pane-info",
|
|
4267
|
+
onClick: function onClick(event) {
|
|
4268
|
+
return event.preventDefault();
|
|
4269
|
+
},
|
|
4270
|
+
children: /*#__PURE__*/jsx(Info, {
|
|
4271
|
+
size: 14
|
|
4272
|
+
})
|
|
4273
|
+
}),
|
|
4274
|
+
children: [popover.title && /*#__PURE__*/jsx(Popover.Title, {
|
|
4275
|
+
children: popover.title
|
|
4276
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
4277
|
+
color: "muted",
|
|
4278
|
+
variant: "body2",
|
|
4279
|
+
children: popover.description
|
|
4280
|
+
}), popover.helpLinkProps && /*#__PURE__*/jsx(Button, _objectSpread$2(_objectSpread$2({}, popover.helpLinkProps), {}, {
|
|
4281
|
+
className: "h-auto self-start p-0",
|
|
4282
|
+
size: "sm",
|
|
4283
|
+
variant: "link"
|
|
4284
|
+
}))]
|
|
4285
|
+
}), !popover && reason && isTextReason && (option.disabledTooltip ? /*#__PURE__*/jsx(Tooltip, {
|
|
4098
4286
|
content: option.disabledTooltip,
|
|
4099
4287
|
position: "top",
|
|
4100
4288
|
children: /*#__PURE__*/jsx("span", {
|
|
4101
4289
|
className: "mb-pane-warn",
|
|
4102
|
-
children:
|
|
4290
|
+
children: reason
|
|
4103
4291
|
})
|
|
4104
4292
|
}) : /*#__PURE__*/jsx("span", {
|
|
4105
4293
|
className: "mb-pane-warn",
|
|
4106
|
-
children:
|
|
4294
|
+
children: reason
|
|
4107
4295
|
}))]
|
|
4108
4296
|
});
|
|
4109
4297
|
};
|
|
@@ -4254,7 +4442,7 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4254
4442
|
var path = "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.value);
|
|
4255
4443
|
var current = getIn(values, path);
|
|
4256
4444
|
var options = normalizeOptions(dropdownOptions);
|
|
4257
|
-
return /*#__PURE__*/jsx(Select
|
|
4445
|
+
return /*#__PURE__*/jsx(Select, {
|
|
4258
4446
|
options: options,
|
|
4259
4447
|
placeholder: placeholder,
|
|
4260
4448
|
required: true,
|
|
@@ -4274,7 +4462,9 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4274
4462
|
var RecipientPane = function RecipientPane(_ref) {
|
|
4275
4463
|
var _schema$actions, _schema$actions$actio, _action$recipient, _schema$actions2, _schema$actions2$acti, _schema$actions3, _schema$actions3$rend, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions5$opti, _schema$actions6, _schema$actions7, _schema$actions$rende, _schema$actions8, _schema$actions8$rend, _action$metadata, _schema$actions9;
|
|
4276
4464
|
var schema = _ref.schema,
|
|
4277
|
-
index = _ref.index
|
|
4465
|
+
index = _ref.index,
|
|
4466
|
+
_ref$configPending = _ref.configPending,
|
|
4467
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
4278
4468
|
var _useTranslation = useTranslation(),
|
|
4279
4469
|
t = _useTranslation.t;
|
|
4280
4470
|
var _useRuleModel = useRuleModel(schema),
|
|
@@ -4349,6 +4539,7 @@ var RecipientPane = function RecipientPane(_ref) {
|
|
|
4349
4539
|
if (!editor) {
|
|
4350
4540
|
return /*#__PURE__*/jsx(OptionsPane, {
|
|
4351
4541
|
belowContent: belowContent,
|
|
4542
|
+
configPending: configPending,
|
|
4352
4543
|
index: index,
|
|
4353
4544
|
schema: schema,
|
|
4354
4545
|
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
@@ -4448,7 +4639,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4448
4639
|
}
|
|
4449
4640
|
if (type === CONDITION_VALUE_TYPES.multiSelectCreate) {
|
|
4450
4641
|
var _current = getIn(values, valuesPath) || [];
|
|
4451
|
-
return /*#__PURE__*/jsx(Select
|
|
4642
|
+
return /*#__PURE__*/jsx(Select, {
|
|
4452
4643
|
autoFocus: true,
|
|
4453
4644
|
isCreatable: true,
|
|
4454
4645
|
isMulti: true,
|
|
@@ -4474,9 +4665,6 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4474
4665
|
error: fieldError(valuePath),
|
|
4475
4666
|
orientation: "vertical",
|
|
4476
4667
|
value: String(_current2 !== null && _current2 !== void 0 ? _current2 : ""),
|
|
4477
|
-
onBlur: function onBlur() {
|
|
4478
|
-
return setFieldTouched(valuePath, true);
|
|
4479
|
-
},
|
|
4480
4668
|
onValueChange: function onValueChange(value) {
|
|
4481
4669
|
return setFieldValue(valuePath, value);
|
|
4482
4670
|
},
|
|
@@ -4701,7 +4889,10 @@ var Form = function Form(_ref) {
|
|
|
4701
4889
|
values: values,
|
|
4702
4890
|
schema: schema
|
|
4703
4891
|
});
|
|
4704
|
-
if (!isRuleComplete(
|
|
4892
|
+
if (!isRuleComplete({
|
|
4893
|
+
rule: rule,
|
|
4894
|
+
schema: schema
|
|
4895
|
+
}) || invalidScopeIndexes({
|
|
4705
4896
|
rule: rule,
|
|
4706
4897
|
schema: schema
|
|
4707
4898
|
}).length || invalidScopePhoneFieldIndexes({
|