@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _objectDestructuringEmpty = require('@babel/runtime/helpers/objectDestructuringEmpty');
|
|
5
|
-
var keyboardShortcuts = require('../../keyboardShortcuts-
|
|
5
|
+
var keyboardShortcuts = require('../../keyboardShortcuts-CRInJJOU.js');
|
|
6
6
|
var shallow = require('zustand/shallow');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
@@ -13,7 +13,7 @@ var neetoCist = require('@bigbinary/neeto-cist');
|
|
|
13
13
|
var Container = require('@bigbinary/neeto-molecules/v2/Container');
|
|
14
14
|
var Header = require('@bigbinary/neeto-molecules/v2/Header');
|
|
15
15
|
var reactI18next = require('react-i18next');
|
|
16
|
-
var index = require('../../index-
|
|
16
|
+
var index = require('../../index-puRtNWZV.js');
|
|
17
17
|
var useCustomDataStore = require('../../useCustomDataStore-DPmWkEhs.js');
|
|
18
18
|
var useUtilityStore = require('../../useUtilityStore-gtPhFvpI.js');
|
|
19
19
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
@@ -32,6 +32,7 @@ var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
|
|
|
32
32
|
var utils$1 = require('../../utils-B3roKiff.js');
|
|
33
33
|
var Up = require('@bigbinary/neeto-icons/Up');
|
|
34
34
|
var Down = require('@bigbinary/neeto-icons/Down');
|
|
35
|
+
var Info = require('@bigbinary/neeto-icons/Info');
|
|
35
36
|
require('@babel/runtime/helpers/typeof');
|
|
36
37
|
require('../../useAutomationRulesApi-C1T2E1AN.js');
|
|
37
38
|
require('@tanstack/react-query');
|
|
@@ -484,6 +485,18 @@ var actionParts = function actionParts(_ref11) {
|
|
|
484
485
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
485
486
|
};
|
|
486
487
|
};
|
|
488
|
+
|
|
489
|
+
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
490
|
+
// only support a subset. Lookups deliberately keep using the full list so a
|
|
491
|
+
// field already on the rule still resolves after the offer narrows.
|
|
492
|
+
var offeredConditionFields = function offeredConditionFields(_ref12) {
|
|
493
|
+
var _ref13, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
494
|
+
var schema = _ref12.schema,
|
|
495
|
+
rule = _ref12.rule;
|
|
496
|
+
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, {
|
|
497
|
+
rule: rule
|
|
498
|
+
})) !== 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 : [];
|
|
499
|
+
};
|
|
487
500
|
var hasTrigger = function hasTrigger(rule) {
|
|
488
501
|
return !ramda.isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
489
502
|
};
|
|
@@ -492,31 +505,54 @@ var hasAction = function hasAction(rule) {
|
|
|
492
505
|
return action === null || action === void 0 ? void 0 : action.name;
|
|
493
506
|
});
|
|
494
507
|
};
|
|
495
|
-
var
|
|
496
|
-
|
|
508
|
+
var isTriggerEnabled = function isTriggerEnabled(schema) {
|
|
509
|
+
var _schema$triggers2;
|
|
510
|
+
return (schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.enabled) !== false;
|
|
511
|
+
};
|
|
512
|
+
var isTriggerSatisfied = function isTriggerSatisfied(_ref14) {
|
|
513
|
+
var rule = _ref14.rule,
|
|
514
|
+
schema = _ref14.schema;
|
|
515
|
+
return !isTriggerEnabled(schema) || hasTrigger(rule);
|
|
516
|
+
};
|
|
517
|
+
var hasRequiredConditions = function hasRequiredConditions(_ref15) {
|
|
518
|
+
var _schema$conditions5;
|
|
519
|
+
var rule = _ref15.rule,
|
|
520
|
+
schema = _ref15.schema;
|
|
521
|
+
return (schema === null || schema === void 0 || (_schema$conditions5 = schema.conditions) === null || _schema$conditions5 === void 0 ? void 0 : _schema$conditions5.allowEmpty) === false ? neetoCist.isNotEmpty((rule === null || rule === void 0 ? void 0 : rule.conditions) || []) : true;
|
|
522
|
+
};
|
|
523
|
+
var isRuleComplete = function isRuleComplete(_ref16) {
|
|
524
|
+
var rule = _ref16.rule,
|
|
525
|
+
schema = _ref16.schema;
|
|
526
|
+
return isTriggerSatisfied({
|
|
527
|
+
rule: rule,
|
|
528
|
+
schema: schema
|
|
529
|
+
}) && hasRequiredConditions({
|
|
530
|
+
rule: rule,
|
|
531
|
+
schema: schema
|
|
532
|
+
}) && hasAction(rule);
|
|
497
533
|
};
|
|
498
|
-
var scopeOptionFor = function scopeOptionFor(
|
|
534
|
+
var scopeOptionFor = function scopeOptionFor(_ref17) {
|
|
499
535
|
var _item$value, _schema$scope;
|
|
500
|
-
var schema =
|
|
501
|
-
item =
|
|
536
|
+
var schema = _ref17.schema,
|
|
537
|
+
item = _ref17.item;
|
|
502
538
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
503
539
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
504
540
|
var _candidate$value2;
|
|
505
541
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
506
542
|
});
|
|
507
543
|
};
|
|
508
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
509
|
-
var
|
|
510
|
-
var schema =
|
|
511
|
-
item =
|
|
512
|
-
return (
|
|
544
|
+
var scopePhoneFields = function scopePhoneFields(_ref18) {
|
|
545
|
+
var _ref19, _item$phoneFields, _scopeOptionFor;
|
|
546
|
+
var schema = _ref18.schema,
|
|
547
|
+
item = _ref18.item;
|
|
548
|
+
return (_ref19 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
513
549
|
schema: schema,
|
|
514
550
|
item: item
|
|
515
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
551
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref19 !== void 0 ? _ref19 : null;
|
|
516
552
|
};
|
|
517
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
518
|
-
var schema =
|
|
519
|
-
item =
|
|
553
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref20) {
|
|
554
|
+
var schema = _ref20.schema,
|
|
555
|
+
item = _ref20.item;
|
|
520
556
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
521
557
|
var phoneFields = scopePhoneFields({
|
|
522
558
|
schema: schema,
|
|
@@ -524,14 +560,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
|
|
|
524
560
|
});
|
|
525
561
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
526
562
|
};
|
|
527
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
563
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref21) {
|
|
528
564
|
var _scope$requiresPhone;
|
|
529
|
-
var rule =
|
|
530
|
-
schema =
|
|
565
|
+
var rule = _ref21.rule,
|
|
566
|
+
schema = _ref21.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$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.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) {
|
|
534
|
-
var
|
|
570
|
+
var _ref22, _item$hasPhoneField;
|
|
535
571
|
var option = scopeOptionFor({
|
|
536
572
|
schema: schema,
|
|
537
573
|
item: item
|
|
@@ -540,15 +576,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
|
|
|
540
576
|
schema: schema,
|
|
541
577
|
item: item
|
|
542
578
|
});
|
|
543
|
-
var hasPhoneField = (
|
|
579
|
+
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;
|
|
544
580
|
if (hasPhoneField === false) indexes.push(index);
|
|
545
581
|
return indexes;
|
|
546
582
|
}, []);
|
|
547
583
|
};
|
|
548
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
584
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref23) {
|
|
549
585
|
var _scope$requiresPhone2;
|
|
550
|
-
var rule =
|
|
551
|
-
schema =
|
|
586
|
+
var rule = _ref23.rule,
|
|
587
|
+
schema = _ref23.schema;
|
|
552
588
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
553
589
|
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 [];
|
|
554
590
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
@@ -585,9 +621,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
585
621
|
unit: "minutes"
|
|
586
622
|
};
|
|
587
623
|
};
|
|
588
|
-
var partsToMinutes = function partsToMinutes(
|
|
589
|
-
var value =
|
|
590
|
-
unit =
|
|
624
|
+
var partsToMinutes = function partsToMinutes(_ref24) {
|
|
625
|
+
var value = _ref24.value,
|
|
626
|
+
unit = _ref24.unit;
|
|
591
627
|
return (
|
|
592
628
|
// eslint-disable-next-line security/detect-object-injection
|
|
593
629
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -597,8 +633,8 @@ var leadTimeExceedsMax = function leadTimeExceedsMax(minutes) {
|
|
|
597
633
|
return minutesToParts(minutes).value > MAX_LEAD_TIME_VALUE;
|
|
598
634
|
};
|
|
599
635
|
var leadTimeValidationSchema = function leadTimeValidationSchema(schema) {
|
|
600
|
-
var _schema$
|
|
601
|
-
var fieldKey = schema === null || schema === void 0 || (_schema$
|
|
636
|
+
var _schema$triggers3;
|
|
637
|
+
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;
|
|
602
638
|
if (!fieldKey) return yup__namespace.object();
|
|
603
639
|
return yup__namespace.object().shape(_defineProperty({}, fieldKey, yup__namespace.object().shape({
|
|
604
640
|
// yup 0.32 can only concat schemas of the same type, and the host's
|
|
@@ -642,25 +678,25 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
|
642
678
|
};
|
|
643
679
|
|
|
644
680
|
// eslint-disable-next-line security/detect-object-injection
|
|
645
|
-
var valueAt = function valueAt(
|
|
681
|
+
var valueAt = function valueAt(_ref25) {
|
|
646
682
|
var _values$key;
|
|
647
|
-
var values =
|
|
648
|
-
key =
|
|
683
|
+
var values = _ref25.values,
|
|
684
|
+
key = _ref25.key;
|
|
649
685
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
650
686
|
};
|
|
651
687
|
var asArray = function asArray(maybeArray) {
|
|
652
688
|
return Array.isArray(maybeArray) ? maybeArray : [];
|
|
653
689
|
};
|
|
654
690
|
var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
655
|
-
var _schema$
|
|
691
|
+
var _schema$triggers4, _schema$actor2, _schema$conditions6, _schema$actions3, _schema$delay, _schema$triggers5, _schema$scope2;
|
|
656
692
|
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
657
693
|
return {
|
|
658
|
-
triggers: ((_schema$
|
|
694
|
+
triggers: ((_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey) || "events",
|
|
659
695
|
performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
|
|
660
|
-
conditions: ((_schema$
|
|
696
|
+
conditions: ((_schema$conditions6 = schema.conditions) === null || _schema$conditions6 === void 0 ? void 0 : _schema$conditions6.fieldKey) || "conditions",
|
|
661
697
|
actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
|
|
662
698
|
delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
|
|
663
|
-
leadTime: (_schema$
|
|
699
|
+
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,
|
|
664
700
|
scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
|
|
665
701
|
status: "status",
|
|
666
702
|
name: "name"
|
|
@@ -668,11 +704,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
668
704
|
};
|
|
669
705
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
670
706
|
var _valueAt, _conditions$;
|
|
671
|
-
var
|
|
672
|
-
|
|
673
|
-
values =
|
|
674
|
-
|
|
675
|
-
schema =
|
|
707
|
+
var _ref26 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
708
|
+
_ref26$values = _ref26.values,
|
|
709
|
+
values = _ref26$values === void 0 ? {} : _ref26$values,
|
|
710
|
+
_ref26$schema = _ref26.schema,
|
|
711
|
+
schema = _ref26$schema === void 0 ? {} : _ref26$schema;
|
|
676
712
|
var keys = fieldKeysFromSchema(schema);
|
|
677
713
|
var conditions = asArray(valueAt({
|
|
678
714
|
values: values,
|
|
@@ -716,42 +752,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
716
752
|
}))
|
|
717
753
|
};
|
|
718
754
|
};
|
|
719
|
-
var setTriggers = function setTriggers(
|
|
720
|
-
var schema =
|
|
721
|
-
triggers =
|
|
755
|
+
var setTriggers = function setTriggers(_ref27) {
|
|
756
|
+
var schema = _ref27.schema,
|
|
757
|
+
triggers = _ref27.triggers;
|
|
722
758
|
return {
|
|
723
759
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
724
760
|
value: triggers
|
|
725
761
|
};
|
|
726
762
|
};
|
|
727
|
-
var setPerformer = function setPerformer(
|
|
728
|
-
var schema =
|
|
729
|
-
performer =
|
|
763
|
+
var setPerformer = function setPerformer(_ref28) {
|
|
764
|
+
var schema = _ref28.schema,
|
|
765
|
+
performer = _ref28.performer;
|
|
730
766
|
return {
|
|
731
767
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
732
768
|
value: performer
|
|
733
769
|
};
|
|
734
770
|
};
|
|
735
|
-
var setActions = function setActions(
|
|
736
|
-
var schema =
|
|
737
|
-
actions =
|
|
771
|
+
var setActions = function setActions(_ref29) {
|
|
772
|
+
var schema = _ref29.schema,
|
|
773
|
+
actions = _ref29.actions;
|
|
738
774
|
return {
|
|
739
775
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
740
776
|
value: actions
|
|
741
777
|
};
|
|
742
778
|
};
|
|
743
|
-
var setConditions = function setConditions(
|
|
744
|
-
var schema =
|
|
745
|
-
conditions =
|
|
779
|
+
var setConditions = function setConditions(_ref30) {
|
|
780
|
+
var schema = _ref30.schema,
|
|
781
|
+
conditions = _ref30.conditions;
|
|
746
782
|
return {
|
|
747
783
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
748
784
|
value: conditions
|
|
749
785
|
};
|
|
750
786
|
};
|
|
751
|
-
var setConditionMode = function setConditionMode(
|
|
752
|
-
var schema =
|
|
753
|
-
conditions =
|
|
754
|
-
joinType =
|
|
787
|
+
var setConditionMode = function setConditionMode(_ref31) {
|
|
788
|
+
var schema = _ref31.schema,
|
|
789
|
+
conditions = _ref31.conditions,
|
|
790
|
+
joinType = _ref31.joinType;
|
|
755
791
|
return setConditions({
|
|
756
792
|
schema: schema,
|
|
757
793
|
conditions: conditions.map(function (condition) {
|
|
@@ -759,34 +795,34 @@ var setConditionMode = function setConditionMode(_ref26) {
|
|
|
759
795
|
})
|
|
760
796
|
});
|
|
761
797
|
};
|
|
762
|
-
var setDelay = function setDelay(
|
|
763
|
-
var schema =
|
|
764
|
-
delay =
|
|
798
|
+
var setDelay = function setDelay(_ref32) {
|
|
799
|
+
var schema = _ref32.schema,
|
|
800
|
+
delay = _ref32.delay;
|
|
765
801
|
return {
|
|
766
802
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
767
803
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
768
804
|
};
|
|
769
805
|
};
|
|
770
|
-
var setActive = function setActive(
|
|
771
|
-
var schema =
|
|
772
|
-
active =
|
|
806
|
+
var setActive = function setActive(_ref33) {
|
|
807
|
+
var schema = _ref33.schema,
|
|
808
|
+
active = _ref33.active;
|
|
773
809
|
return {
|
|
774
810
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
775
811
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
776
812
|
};
|
|
777
813
|
};
|
|
778
|
-
var setScope = function setScope(
|
|
779
|
-
var schema =
|
|
780
|
-
scope =
|
|
814
|
+
var setScope = function setScope(_ref34) {
|
|
815
|
+
var schema = _ref34.schema,
|
|
816
|
+
scope = _ref34.scope;
|
|
781
817
|
return {
|
|
782
818
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
783
819
|
value: scope
|
|
784
820
|
};
|
|
785
821
|
};
|
|
786
|
-
var removeArrayItem = function removeArrayItem(
|
|
787
|
-
var values =
|
|
788
|
-
fieldKey =
|
|
789
|
-
index =
|
|
822
|
+
var removeArrayItem = function removeArrayItem(_ref35) {
|
|
823
|
+
var values = _ref35.values,
|
|
824
|
+
fieldKey = _ref35.fieldKey,
|
|
825
|
+
index = _ref35.index;
|
|
790
826
|
var list = asArray(valueAt({
|
|
791
827
|
values: values,
|
|
792
828
|
key: fieldKey
|
|
@@ -813,9 +849,9 @@ var removeArrayItem = function removeArrayItem(_ref30) {
|
|
|
813
849
|
}
|
|
814
850
|
return result;
|
|
815
851
|
};
|
|
816
|
-
var clearArrayItems = function clearArrayItems(
|
|
817
|
-
var values =
|
|
818
|
-
fieldKey =
|
|
852
|
+
var clearArrayItems = function clearArrayItems(_ref36) {
|
|
853
|
+
var values = _ref36.values,
|
|
854
|
+
fieldKey = _ref36.fieldKey;
|
|
819
855
|
var list = asArray(valueAt({
|
|
820
856
|
values: values,
|
|
821
857
|
key: fieldKey
|
|
@@ -891,13 +927,13 @@ var ConditionRow = function ConditionRow(_ref) {
|
|
|
891
927
|
className: "mb-sentence",
|
|
892
928
|
children: [isFirst ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
893
929
|
className: "mb-fixed",
|
|
894
|
-
children: t("neetoRules.operators.and")
|
|
930
|
+
children: isTriggerEnabled(schema) ? t("neetoRules.operators.and") : t("neetoRules.common.when")
|
|
895
931
|
}) : /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
896
932
|
active: isActive({
|
|
897
933
|
type: BUILDER_ANCHORS.COND_CONNECTOR,
|
|
898
934
|
index: index
|
|
899
935
|
}),
|
|
900
|
-
className: "mb-tok-
|
|
936
|
+
className: "mb-tok-connector",
|
|
901
937
|
dataTestid: "cond-connector-".concat(index),
|
|
902
938
|
onClick: handleToken && function () {
|
|
903
939
|
return handleToken({
|
|
@@ -1120,8 +1156,8 @@ var MetaBlock = function MetaBlock(_ref) {
|
|
|
1120
1156
|
className: "mb-meta-label",
|
|
1121
1157
|
children: t("neetoRules.builder.automationName")
|
|
1122
1158
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1123
|
-
ref: nameRef,
|
|
1124
1159
|
"data-testid": "rule-name-edit",
|
|
1160
|
+
ref: nameRef,
|
|
1125
1161
|
role: handleEditName ? "button" : undefined,
|
|
1126
1162
|
tabIndex: handleEditName ? 0 : undefined,
|
|
1127
1163
|
className: classNames("mb-meta-input-wrap", {
|
|
@@ -1394,7 +1430,10 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1394
1430
|
paramKind = _actionParts.paramKind,
|
|
1395
1431
|
valueNoun = _actionParts.valueNoun,
|
|
1396
1432
|
valueNounPlural = _actionParts.valueNounPlural;
|
|
1397
|
-
|
|
1433
|
+
|
|
1434
|
+
// A separator-less action still needs a value slot when the host declares a
|
|
1435
|
+
// placeholder for it, otherwise its chosen value never reaches the canvas.
|
|
1436
|
+
var hasParamTail = paramKind === PARAM_KIND.ENUM_SINGLE || paramKind === PARAM_KIND.ENUM_MULTI || !!configValuePlaceholder || !!configValue;
|
|
1398
1437
|
var multiPlaceholder = valueNounPlural ? t("neetoRules.builder.selectNoun", {
|
|
1399
1438
|
noun: valueNounPlural
|
|
1400
1439
|
}) : t("neetoRules.form.selectValues");
|
|
@@ -1412,12 +1451,66 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1412
1451
|
index: index
|
|
1413
1452
|
});
|
|
1414
1453
|
var configLabel = mediumLabel || sentencify(option === null || option === void 0 ? void 0 : option.placeholder);
|
|
1454
|
+
// A host may declare two separators: the first introduces the recipient
|
|
1455
|
+
// ("whose email is"), the second the configured value ("with the following").
|
|
1456
|
+
var _ref2 = Array.isArray(separator) ? separator : [null, separator],
|
|
1457
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
1458
|
+
recipientSeparator = _ref3[0],
|
|
1459
|
+
configSeparator = _ref3[1];
|
|
1415
1460
|
var isConfigured = neetoCist.isNotEmpty(action === null || action === void 0 ? void 0 : action.metadata);
|
|
1416
1461
|
// A host that shows no value label still needs the token to read as filled.
|
|
1417
1462
|
var configState = configValue || isConfigured ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED;
|
|
1418
1463
|
var _useClearingHover = useClearingHover(),
|
|
1419
1464
|
clearing = _useClearingHover.clearing,
|
|
1420
1465
|
clearingHoverProps = _useClearingHover.clearingHoverProps;
|
|
1466
|
+
var configToken = configSeparator ? /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
1467
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1468
|
+
className: "mb-fixed",
|
|
1469
|
+
children: configSeparator
|
|
1470
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1471
|
+
active: isActive({
|
|
1472
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1473
|
+
index: index
|
|
1474
|
+
}),
|
|
1475
|
+
dataTestid: "action-config-value-".concat(index),
|
|
1476
|
+
state: configState,
|
|
1477
|
+
invalid: isInvalid({
|
|
1478
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1479
|
+
index: index
|
|
1480
|
+
}),
|
|
1481
|
+
onClick: handleToken && function () {
|
|
1482
|
+
return handleToken({
|
|
1483
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1484
|
+
index: index
|
|
1485
|
+
});
|
|
1486
|
+
},
|
|
1487
|
+
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1488
|
+
})]
|
|
1489
|
+
}, "config") : null;
|
|
1490
|
+
var recipientToken = needsRecipient ? /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
1491
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1492
|
+
className: "mb-fixed",
|
|
1493
|
+
children: recipientSeparator || t("neetoRules.common.to")
|
|
1494
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1495
|
+
dataTestid: "action-recipient-".concat(index),
|
|
1496
|
+
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1497
|
+
active: isActive({
|
|
1498
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1499
|
+
index: index
|
|
1500
|
+
}),
|
|
1501
|
+
invalid: isInvalid({
|
|
1502
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1503
|
+
index: index
|
|
1504
|
+
}),
|
|
1505
|
+
onClick: handleToken && function () {
|
|
1506
|
+
return handleToken({
|
|
1507
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1508
|
+
index: index
|
|
1509
|
+
});
|
|
1510
|
+
},
|
|
1511
|
+
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1512
|
+
})]
|
|
1513
|
+
}, "recipient") : null;
|
|
1421
1514
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1422
1515
|
className: classNames("mb-row mb-row-draggable", {
|
|
1423
1516
|
clearing: clearing
|
|
@@ -1427,7 +1520,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1427
1520
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1428
1521
|
className: "mb-fixed",
|
|
1429
1522
|
children: connector
|
|
1430
|
-
}),
|
|
1523
|
+
}), configSeparator ? /*#__PURE__*/jsxRuntime.jsxs(Token, {
|
|
1431
1524
|
active: isVerbActive,
|
|
1432
1525
|
className: "mb-tok-medium",
|
|
1433
1526
|
dataTestid: "action-verb-".concat(index),
|
|
@@ -1468,7 +1561,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1468
1561
|
index: index
|
|
1469
1562
|
});
|
|
1470
1563
|
},
|
|
1471
|
-
children: configValue || paramPlaceholder
|
|
1564
|
+
children: configValue || sentencify(configValuePlaceholder) || paramPlaceholder
|
|
1472
1565
|
}) : configLabel && /*#__PURE__*/jsxRuntime.jsxs(Token, {
|
|
1473
1566
|
className: "mb-tok-medium",
|
|
1474
1567
|
dataTestid: "action-config-".concat(index),
|
|
@@ -1491,53 +1584,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1491
1584
|
size: 14
|
|
1492
1585
|
}), configLabel]
|
|
1493
1586
|
})]
|
|
1494
|
-
}),
|
|
1495
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1496
|
-
className: "mb-fixed",
|
|
1497
|
-
children: separator
|
|
1498
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1499
|
-
active: isActive({
|
|
1500
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1501
|
-
index: index
|
|
1502
|
-
}),
|
|
1503
|
-
dataTestid: "action-config-value-".concat(index),
|
|
1504
|
-
state: configState,
|
|
1505
|
-
invalid: isInvalid({
|
|
1506
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1507
|
-
index: index
|
|
1508
|
-
}),
|
|
1509
|
-
onClick: handleToken && function () {
|
|
1510
|
-
return handleToken({
|
|
1511
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1512
|
-
index: index
|
|
1513
|
-
});
|
|
1514
|
-
},
|
|
1515
|
-
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1516
|
-
})]
|
|
1517
|
-
}), needsRecipient && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1518
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1519
|
-
className: "mb-fixed",
|
|
1520
|
-
children: t("neetoRules.common.to")
|
|
1521
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1522
|
-
dataTestid: "action-recipient-".concat(index),
|
|
1523
|
-
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1524
|
-
active: isActive({
|
|
1525
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1526
|
-
index: index
|
|
1527
|
-
}),
|
|
1528
|
-
invalid: isInvalid({
|
|
1529
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1530
|
-
index: index
|
|
1531
|
-
}),
|
|
1532
|
-
onClick: handleToken && function () {
|
|
1533
|
-
return handleToken({
|
|
1534
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1535
|
-
index: index
|
|
1536
|
-
});
|
|
1537
|
-
},
|
|
1538
|
-
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1539
|
-
})]
|
|
1540
|
-
})]
|
|
1587
|
+
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken]]
|
|
1541
1588
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1542
1589
|
className: "mb-row-actions",
|
|
1543
1590
|
children: [handleAddAction && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
@@ -1593,7 +1640,10 @@ var ThenBlock = function ThenBlock(_ref) {
|
|
|
1593
1640
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
1594
1641
|
});
|
|
1595
1642
|
if (ramda.isEmpty(named)) {
|
|
1596
|
-
var isTriggerSet =
|
|
1643
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
1644
|
+
rule: rule,
|
|
1645
|
+
schema: schema
|
|
1646
|
+
});
|
|
1597
1647
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1598
1648
|
className: "mb-row",
|
|
1599
1649
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -1685,6 +1735,21 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1685
1735
|
var _schema$triggers;
|
|
1686
1736
|
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);
|
|
1687
1737
|
};
|
|
1738
|
+
if (!isTriggerEnabled(schema)) {
|
|
1739
|
+
if (!ramda.isEmpty(rule.conditions)) return null;
|
|
1740
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1741
|
+
className: "mb-row",
|
|
1742
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1743
|
+
className: "mb-sentence",
|
|
1744
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1745
|
+
dataTestid: "condition-add",
|
|
1746
|
+
state: TOKEN_STATE.PLACEHOLDER_NEXT,
|
|
1747
|
+
onClick: handleAddCondition || undefined,
|
|
1748
|
+
children: t("neetoRules.builder.whenThisIsTrue")
|
|
1749
|
+
})
|
|
1750
|
+
})
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1688
1753
|
if (ramda.isEmpty(triggers)) {
|
|
1689
1754
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1690
1755
|
className: "mb-row",
|
|
@@ -2237,7 +2302,7 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2237
2302
|
});
|
|
2238
2303
|
};
|
|
2239
2304
|
var descriptorFor = function descriptorFor(_ref15) {
|
|
2240
|
-
var _schema$actor2
|
|
2305
|
+
var _schema$actor2;
|
|
2241
2306
|
var anchor = _ref15.anchor,
|
|
2242
2307
|
schema = _ref15.schema,
|
|
2243
2308
|
rule = _ref15.rule,
|
|
@@ -2283,7 +2348,10 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2283
2348
|
title: i18next.t("neetoRules.builder.panes.addCondition"),
|
|
2284
2349
|
subtitle: i18next.t("neetoRules.builder.panes.condFieldSubtitle"),
|
|
2285
2350
|
cascade: true,
|
|
2286
|
-
options: (
|
|
2351
|
+
options: offeredConditionFields({
|
|
2352
|
+
schema: schema,
|
|
2353
|
+
rule: rule
|
|
2354
|
+
}).map(function (field) {
|
|
2287
2355
|
return {
|
|
2288
2356
|
label: field.paneLabel || field.label,
|
|
2289
2357
|
value: optionValue(field),
|
|
@@ -2297,7 +2365,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2297
2365
|
};
|
|
2298
2366
|
case BUILDER_ANCHORS.COND_OP_TOGGLE:
|
|
2299
2367
|
{
|
|
2300
|
-
var _schema$
|
|
2368
|
+
var _schema$conditions2;
|
|
2301
2369
|
var field = findField({
|
|
2302
2370
|
schema: schema,
|
|
2303
2371
|
value: conditionAt({
|
|
@@ -2305,7 +2373,7 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2305
2373
|
index: index
|
|
2306
2374
|
}).field
|
|
2307
2375
|
});
|
|
2308
|
-
var labels = ((_schema$
|
|
2376
|
+
var labels = ((_schema$conditions2 = schema.conditions) === null || _schema$conditions2 === void 0 ? void 0 : _schema$conditions2.operatorLabels) || {};
|
|
2309
2377
|
var verbs = (field === null || field === void 0 ? void 0 : field.allowMatching) || [];
|
|
2310
2378
|
var fieldLabel = (field === null || field === void 0 ? void 0 : field.paneLabel) || (field === null || field === void 0 ? void 0 : field.label) || "";
|
|
2311
2379
|
var isContains = neetoCist.isNotEmpty(verbs) && verbs.every(isContainsVerb);
|
|
@@ -2369,13 +2437,18 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2369
2437
|
subtitle: isSwap ? i18next.t("neetoRules.builder.panes.actionSwapSubtitle") : i18next.t("neetoRules.builder.panes.actionAddSubtitle"),
|
|
2370
2438
|
cascade: true,
|
|
2371
2439
|
options: sourceOptions.map(function (option) {
|
|
2440
|
+
var _option$disabled;
|
|
2372
2441
|
var value = optionValue(option);
|
|
2373
2442
|
var meta = channelMetaFor(value);
|
|
2374
2443
|
return {
|
|
2375
2444
|
label: isSwap ? meta.channelLabel || option.label : option.label,
|
|
2376
2445
|
value: value,
|
|
2377
2446
|
category: option.category,
|
|
2378
|
-
|
|
2447
|
+
// Hosts mark unavailable actions with isDisabled; without carrying
|
|
2448
|
+
// the reason across, the picker disables them with no explanation.
|
|
2449
|
+
disabled: !!((_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : option.isDisabled),
|
|
2450
|
+
disabledReason: option.disabledReason,
|
|
2451
|
+
disabledPopover: option.disabledPopover,
|
|
2379
2452
|
icon: (isSwap ? meta.icon : option.icon) || option.icon
|
|
2380
2453
|
};
|
|
2381
2454
|
}),
|
|
@@ -2423,7 +2496,10 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2423
2496
|
selectedValues: [recipientOf({
|
|
2424
2497
|
schema: schema,
|
|
2425
2498
|
action: action
|
|
2426
|
-
})]
|
|
2499
|
+
})],
|
|
2500
|
+
// Confirming a recipient always offers Continue; whether that chains
|
|
2501
|
+
// onward or just closes is decided by continueTargetFor.
|
|
2502
|
+
cascade: true
|
|
2427
2503
|
};
|
|
2428
2504
|
}
|
|
2429
2505
|
case BUILDER_ANCHORS.SCOPE:
|
|
@@ -2440,14 +2516,16 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2440
2516
|
subtitle: sc.paneSubtitle || i18next.t("neetoRules.builder.panes.scopeSubtitle"),
|
|
2441
2517
|
multi: true,
|
|
2442
2518
|
options: (sc.options || []).map(function (option) {
|
|
2519
|
+
var _option$disabled2;
|
|
2443
2520
|
var value = optionValue(option);
|
|
2444
2521
|
var blockedNoPhone = requiresPhone && option.hasPhoneField === false;
|
|
2445
2522
|
var isSelected = selected.includes(value);
|
|
2446
2523
|
return {
|
|
2447
2524
|
label: option.label,
|
|
2448
2525
|
value: value,
|
|
2449
|
-
disabled: (!!option.disabled || blockedNoPhone) && !isSelected,
|
|
2450
|
-
disabledReason: blockedNoPhone
|
|
2526
|
+
disabled: (!!((_option$disabled2 = option.disabled) !== null && _option$disabled2 !== void 0 ? _option$disabled2 : option.isDisabled) || blockedNoPhone) && !isSelected,
|
|
2527
|
+
disabledReason: blockedNoPhone ? sc.disabledReason : option.disabledReason,
|
|
2528
|
+
disabledPopover: option.disabledPopover,
|
|
2451
2529
|
disabledTooltip: blockedNoPhone && sc.disabledTooltip
|
|
2452
2530
|
};
|
|
2453
2531
|
}),
|
|
@@ -2604,7 +2682,8 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2604
2682
|
var anchor = _ref17.anchor,
|
|
2605
2683
|
schema = _ref17.schema,
|
|
2606
2684
|
rule = _ref17.rule,
|
|
2607
|
-
index = _ref17.index
|
|
2685
|
+
index = _ref17.index,
|
|
2686
|
+
configPending = _ref17.configPending;
|
|
2608
2687
|
switch (anchor) {
|
|
2609
2688
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2610
2689
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2660,6 +2739,9 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2660
2739
|
}
|
|
2661
2740
|
};
|
|
2662
2741
|
}
|
|
2742
|
+
|
|
2743
|
+
// Reached here only because the action has no config yet — its name is
|
|
2744
|
+
// still unresolved — so the recipient pane owes us that step afterwards.
|
|
2663
2745
|
return channelMetaOf({
|
|
2664
2746
|
schema: schema,
|
|
2665
2747
|
action: action
|
|
@@ -2667,12 +2749,30 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2667
2749
|
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
2668
2750
|
data: {
|
|
2669
2751
|
index: index,
|
|
2670
|
-
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
2752
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
2753
|
+
configPending: true
|
|
2671
2754
|
}
|
|
2672
2755
|
} : null;
|
|
2673
2756
|
}
|
|
2674
2757
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2675
|
-
|
|
2758
|
+
{
|
|
2759
|
+
// Only chain onward when config was skipped on the way in; arriving from
|
|
2760
|
+
// the config pane or from the token means this is the last step.
|
|
2761
|
+
var _action = actionAt({
|
|
2762
|
+
rule: rule,
|
|
2763
|
+
index: index
|
|
2764
|
+
});
|
|
2765
|
+
return configPending && actionHasConfig({
|
|
2766
|
+
schema: schema,
|
|
2767
|
+
action: _action
|
|
2768
|
+
}) ? {
|
|
2769
|
+
type: BUILDER_PANEL_TYPES.ACTION_CONFIG,
|
|
2770
|
+
data: {
|
|
2771
|
+
index: index,
|
|
2772
|
+
anchor: BUILDER_ANCHORS.ACTION_CONFIG
|
|
2773
|
+
}
|
|
2774
|
+
} : null;
|
|
2775
|
+
}
|
|
2676
2776
|
default:
|
|
2677
2777
|
return null;
|
|
2678
2778
|
}
|
|
@@ -2788,7 +2888,7 @@ var applyPreview = function applyPreview(_ref19) {
|
|
|
2788
2888
|
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; }
|
|
2789
2889
|
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; }
|
|
2790
2890
|
var Canvas = function Canvas(_ref) {
|
|
2791
|
-
var _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2891
|
+
var _schema$actor2, _ref6, _actorOptions$0$value, _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2792
2892
|
var schema = _ref.schema;
|
|
2793
2893
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2794
2894
|
t = _useTranslation.t;
|
|
@@ -2843,7 +2943,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
2843
2943
|
react.useEffect(function () {
|
|
2844
2944
|
if (submitCount <= lastSubmitCount.current) return undefined;
|
|
2845
2945
|
lastSubmitCount.current = submitCount;
|
|
2846
|
-
if (ramda.isEmpty(flatErrors) && isRuleComplete(
|
|
2946
|
+
if (ramda.isEmpty(flatErrors) && isRuleComplete({
|
|
2947
|
+
rule: rule,
|
|
2948
|
+
schema: schema
|
|
2949
|
+
}) && ramda.isEmpty(invalidScopeIndexes({
|
|
2847
2950
|
rule: rule,
|
|
2848
2951
|
schema: schema
|
|
2849
2952
|
})) && ramda.isEmpty(invalidScopePhoneFieldIndexes({
|
|
@@ -3007,7 +3110,15 @@ var Canvas = function Canvas(_ref) {
|
|
|
3007
3110
|
});
|
|
3008
3111
|
setDelay(null);
|
|
3009
3112
|
};
|
|
3010
|
-
|
|
3113
|
+
|
|
3114
|
+
// An actor with a single choice is not a choice; leaving it unset only makes
|
|
3115
|
+
// the user open a one-option pane to say the obvious.
|
|
3116
|
+
var actorOptions = schema !== null && schema !== void 0 && (_schema$actor2 = schema.actor) !== null && _schema$actor2 !== void 0 && _schema$actor2.enabled ? schema.actor.options || [] : [];
|
|
3117
|
+
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;
|
|
3118
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
3119
|
+
rule: rule,
|
|
3120
|
+
schema: schema
|
|
3121
|
+
});
|
|
3011
3122
|
var hasAction = rule.actions.some(function (action) {
|
|
3012
3123
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
3013
3124
|
});
|
|
@@ -3021,13 +3132,21 @@ var Canvas = function Canvas(_ref) {
|
|
|
3021
3132
|
return i !== index;
|
|
3022
3133
|
}));
|
|
3023
3134
|
};
|
|
3024
|
-
var conditionFields = (
|
|
3135
|
+
var conditionFields = offeredConditionFields({
|
|
3136
|
+
schema: schema,
|
|
3137
|
+
rule: rule
|
|
3138
|
+
});
|
|
3025
3139
|
var canAddCondition = neetoCist.isNotEmpty(conditionFields);
|
|
3140
|
+
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;
|
|
3026
3141
|
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) || [];
|
|
3027
3142
|
var hasLeadTimeTrigger = rule.triggers.some(function (trigger) {
|
|
3028
3143
|
return leadTimeAppliesTo.includes(trigger.name);
|
|
3029
3144
|
});
|
|
3030
3145
|
var isDelayEnabled = (schema === null || schema === void 0 || (_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.enabled) && !hasLeadTimeTrigger;
|
|
3146
|
+
react.useEffect(function () {
|
|
3147
|
+
if (soleActorOption && !rule.performer) setPerformer(soleActorOption);
|
|
3148
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3149
|
+
}, [soleActorOption, rule.performer]);
|
|
3031
3150
|
react.useEffect(function () {
|
|
3032
3151
|
if (hasLeadTimeTrigger && rule.delay) setDelay(null);
|
|
3033
3152
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3044,10 +3163,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
3044
3163
|
});
|
|
3045
3164
|
};
|
|
3046
3165
|
var handleClearTrigger = function handleClearTrigger() {
|
|
3047
|
-
var _schema$
|
|
3166
|
+
var _schema$actor3;
|
|
3048
3167
|
clearTriggers();
|
|
3049
3168
|
// Hosts without an actor pane can never re-set it, and null fails its validation.
|
|
3050
|
-
if ((_schema$
|
|
3169
|
+
if ((_schema$actor3 = schema.actor) !== null && _schema$actor3 !== void 0 && _schema$actor3.enabled) setPerformer(soleActorOption);
|
|
3051
3170
|
clearConditions();
|
|
3052
3171
|
setDelay(null);
|
|
3053
3172
|
clearActions();
|
|
@@ -3075,7 +3194,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3075
3194
|
className: "neeto-rules-builder nrb-atoms",
|
|
3076
3195
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3077
3196
|
className: "mb-canvas neeto-rules-main-card",
|
|
3078
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(WhenBlock, {
|
|
3197
|
+
children: [renderSlot("beforeWhen"), /*#__PURE__*/jsxRuntime.jsx(WhenBlock, {
|
|
3079
3198
|
isActive: isActive,
|
|
3080
3199
|
isInvalid: isInvalid,
|
|
3081
3200
|
schema: schema,
|
|
@@ -3093,11 +3212,11 @@ var Canvas = function Canvas(_ref) {
|
|
|
3093
3212
|
schema: schema,
|
|
3094
3213
|
key: (_condition$id = condition.id) !== null && _condition$id !== void 0 ? _condition$id : index,
|
|
3095
3214
|
rule: displayRule,
|
|
3096
|
-
onRemove: function onRemove() {
|
|
3097
|
-
return handleRemoveCondition(index);
|
|
3098
|
-
},
|
|
3099
3215
|
onToken: openPane,
|
|
3100
|
-
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition
|
|
3216
|
+
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition,
|
|
3217
|
+
onRemove: canRemoveCondition && function () {
|
|
3218
|
+
return handleRemoveCondition(index);
|
|
3219
|
+
}
|
|
3101
3220
|
});
|
|
3102
3221
|
}), renderSlot("afterConditions"), /*#__PURE__*/jsxRuntime.jsx(Connector, {
|
|
3103
3222
|
active: isTriggerSet
|
|
@@ -3169,6 +3288,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3169
3288
|
|
|
3170
3289
|
var ACTION_CONFIG_TYPES = {
|
|
3171
3290
|
emailChannel: "emailChannel",
|
|
3291
|
+
sendToApi: "sendToApi",
|
|
3172
3292
|
multiSelect: "multiSelect",
|
|
3173
3293
|
dropdown: "dropdown",
|
|
3174
3294
|
note: "note",
|
|
@@ -3195,7 +3315,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3195
3315
|
option = _ref.option,
|
|
3196
3316
|
action = _ref.action,
|
|
3197
3317
|
_ref$searchTerm = _ref.searchTerm,
|
|
3198
|
-
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm
|
|
3318
|
+
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm,
|
|
3319
|
+
_ref$hasRecipientFiel = _ref.hasRecipientField,
|
|
3320
|
+
hasRecipientField = _ref$hasRecipientFiel === void 0 ? false : _ref$hasRecipientFiel;
|
|
3199
3321
|
var _useTranslation = reactI18next.useTranslation(),
|
|
3200
3322
|
t = _useTranslation.t;
|
|
3201
3323
|
var _useFormikContext = formik.useFormikContext(),
|
|
@@ -3237,19 +3359,42 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3237
3359
|
"data-testid": "pane-no-matches",
|
|
3238
3360
|
children: t("neetoRules.builder.noMatches")
|
|
3239
3361
|
});
|
|
3362
|
+
if (type === ACTION_CONFIG_TYPES.sendToApi) {
|
|
3363
|
+
return /*#__PURE__*/jsxRuntime.jsx(index.ApiFields, {
|
|
3364
|
+
name: name,
|
|
3365
|
+
selectedField: option
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3240
3368
|
if (type === ACTION_CONFIG_TYPES.emailChannel) {
|
|
3241
|
-
var _getIn, _action$metadata;
|
|
3369
|
+
var _getIn, _getIn2, _action$metadata;
|
|
3242
3370
|
var subjectPath = "".concat(name, ".subject");
|
|
3243
3371
|
var bodyPath = "".concat(name, ".body");
|
|
3372
|
+
// Hosts whose email action picks its recipient from a list keep that
|
|
3373
|
+
// choice in the same pane as the message.
|
|
3374
|
+
var hasRecipientList = neetoCist.isNotEmpty(options) && !hasRecipientField;
|
|
3244
3375
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3245
3376
|
className: "flex flex-col gap-4",
|
|
3246
|
-
children: [
|
|
3377
|
+
children: [hasRecipientList && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Select, {
|
|
3378
|
+
options: options,
|
|
3379
|
+
required: true,
|
|
3380
|
+
error: fieldError(valuePath),
|
|
3381
|
+
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3382
|
+
size: "large",
|
|
3383
|
+
value: (_getIn = formik.getIn(values, valuePath)) !== null && _getIn !== void 0 ? _getIn : undefined,
|
|
3384
|
+
label: (option === null || option === void 0 ? void 0 : option.recipientLabel) || t("neetoRules.builder.config.recipient"),
|
|
3385
|
+
onBlur: function onBlur() {
|
|
3386
|
+
return setFieldTouched(valuePath, true);
|
|
3387
|
+
},
|
|
3388
|
+
onChange: function onChange(value) {
|
|
3389
|
+
return setFieldValue(valuePath, value);
|
|
3390
|
+
}
|
|
3391
|
+
}), !(option !== null && option !== void 0 && option.hideSubject) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
3247
3392
|
required: true,
|
|
3248
3393
|
error: fieldError(subjectPath),
|
|
3249
3394
|
label: t("neetoRules.builder.config.subject"),
|
|
3250
3395
|
placeholder: t("neetoRules.builder.config.subjectPlaceholder"),
|
|
3251
3396
|
size: "large",
|
|
3252
|
-
value: (
|
|
3397
|
+
value: (_getIn2 = formik.getIn(values, subjectPath)) !== null && _getIn2 !== void 0 ? _getIn2 : "",
|
|
3253
3398
|
onBlur: function onBlur() {
|
|
3254
3399
|
return setFieldTouched(subjectPath, true);
|
|
3255
3400
|
},
|
|
@@ -3301,9 +3446,6 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3301
3446
|
error: fieldError(valuePath),
|
|
3302
3447
|
orientation: "vertical",
|
|
3303
3448
|
value: String(_current !== null && _current !== void 0 ? _current : ""),
|
|
3304
|
-
onBlur: function onBlur() {
|
|
3305
|
-
return setFieldTouched(valuePath, true);
|
|
3306
|
-
},
|
|
3307
3449
|
onValueChange: function onValueChange(value) {
|
|
3308
3450
|
var picked = options.find(function (item) {
|
|
3309
3451
|
return String(item.value) === value;
|
|
@@ -3341,14 +3483,14 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3341
3483
|
});
|
|
3342
3484
|
}
|
|
3343
3485
|
if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
|
|
3344
|
-
var
|
|
3486
|
+
var _getIn3, _getIn4;
|
|
3345
3487
|
return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
3346
3488
|
required: true,
|
|
3347
3489
|
error: fieldError(valuePath),
|
|
3348
3490
|
label: t("neetoRules.builder.config.value"),
|
|
3349
3491
|
size: "large",
|
|
3350
3492
|
type: "number",
|
|
3351
|
-
value: (
|
|
3493
|
+
value: (_getIn3 = formik.getIn(values, valuePath)) !== null && _getIn3 !== void 0 ? _getIn3 : "",
|
|
3352
3494
|
onBlur: function onBlur() {
|
|
3353
3495
|
return setFieldTouched(valuePath, true);
|
|
3354
3496
|
},
|
|
@@ -3361,7 +3503,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3361
3503
|
label: t("neetoRules.builder.config.message"),
|
|
3362
3504
|
rows: 5,
|
|
3363
3505
|
size: "large",
|
|
3364
|
-
value: (
|
|
3506
|
+
value: (_getIn4 = formik.getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
|
|
3365
3507
|
onBlur: function onBlur() {
|
|
3366
3508
|
return setFieldTouched(valuePath, true);
|
|
3367
3509
|
},
|
|
@@ -3371,7 +3513,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3371
3513
|
});
|
|
3372
3514
|
}
|
|
3373
3515
|
if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
|
|
3374
|
-
var
|
|
3516
|
+
var _getIn5;
|
|
3375
3517
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3376
3518
|
className: "flex flex-col gap-2",
|
|
3377
3519
|
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
@@ -3380,7 +3522,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3380
3522
|
label: t("neetoRules.builder.config.value"),
|
|
3381
3523
|
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3382
3524
|
size: "large",
|
|
3383
|
-
value: (
|
|
3525
|
+
value: (_getIn5 = formik.getIn(values, valuePath)) !== null && _getIn5 !== void 0 ? _getIn5 : "",
|
|
3384
3526
|
onBlur: function onBlur() {
|
|
3385
3527
|
return setFieldTouched(valuePath, true);
|
|
3386
3528
|
},
|
|
@@ -3491,7 +3633,7 @@ var usePaneValidation = function usePaneValidation(prefix) {
|
|
|
3491
3633
|
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 }; })(); }
|
|
3492
3634
|
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); }
|
|
3493
3635
|
var ConfigPane = function ConfigPane(_ref) {
|
|
3494
|
-
var _schema$actions, _schema$actions$optio, _schema$actions2, _schema$actions2$opti, _schema$actions3, _schema$
|
|
3636
|
+
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;
|
|
3495
3637
|
var schema = _ref.schema,
|
|
3496
3638
|
index$1 = _ref.index;
|
|
3497
3639
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -3526,14 +3668,24 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3526
3668
|
configSubtitle = _actionParts.configSubtitle;
|
|
3527
3669
|
var name = "".concat(base, ".metadata");
|
|
3528
3670
|
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;
|
|
3671
|
+
|
|
3672
|
+
// When the chosen recipient declares its own field, the recipient pane
|
|
3673
|
+
// renders it; showing the same picker here too would just duplicate it.
|
|
3674
|
+
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;
|
|
3675
|
+
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) {
|
|
3676
|
+
return o.recipients || [];
|
|
3677
|
+
})).find(function (item) {
|
|
3678
|
+
var _item$value;
|
|
3679
|
+
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipientValue;
|
|
3680
|
+
})) !== null && _concat$find !== void 0 && _concat$find.field);
|
|
3529
3681
|
var isSms = SMS_TYPES.includes(flatOption === null || flatOption === void 0 ? void 0 : flatOption.type);
|
|
3530
3682
|
var disabledReason = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.isDisabled) && flatOption.disabledReason;
|
|
3531
|
-
var hostRenderConfig = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.renderConfig) || (flatOption === null || flatOption === void 0 ? void 0 : flatOption.component) || ((_schema$
|
|
3683
|
+
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);
|
|
3532
3684
|
var showSearch = normalizeOptions(flatOption === null || flatOption === void 0 ? void 0 : flatOption.dropdownOptions).length >= PANE_SEARCH_THRESHOLD;
|
|
3533
3685
|
var shouldAdvanceToRecipient = !!needsRecipient;
|
|
3534
3686
|
var _usePaneValidation = usePaneValidation(name),
|
|
3535
3687
|
validate = _usePaneValidation.validate;
|
|
3536
|
-
var channelRepName = (_schema$
|
|
3688
|
+
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;
|
|
3537
3689
|
var unnamedOnOpen = react.useRef(!action.name);
|
|
3538
3690
|
react.useEffect(function () {
|
|
3539
3691
|
if (!unnamedOnOpen.current || !channelRepName) return undefined;
|
|
@@ -3652,6 +3804,7 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3652
3804
|
searchTerm: searchTerm
|
|
3653
3805
|
})) !== null && _hostRenderConfig !== void 0 ? _hostRenderConfig : /*#__PURE__*/jsxRuntime.jsx(ActionConfigFields, {
|
|
3654
3806
|
action: action,
|
|
3807
|
+
hasRecipientField: hasRecipientField,
|
|
3655
3808
|
name: name,
|
|
3656
3809
|
searchTerm: searchTerm,
|
|
3657
3810
|
option: flatOption
|
|
@@ -3990,7 +4143,9 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
3990
4143
|
anchor = _ref.anchor,
|
|
3991
4144
|
index$1 = _ref.index,
|
|
3992
4145
|
_ref$belowContent = _ref.belowContent,
|
|
3993
|
-
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent
|
|
4146
|
+
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent,
|
|
4147
|
+
_ref$configPending = _ref.configPending,
|
|
4148
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
3994
4149
|
var _useTranslation = reactI18next.useTranslation(),
|
|
3995
4150
|
t = _useTranslation.t;
|
|
3996
4151
|
var _useFormikContext = formik.useFormikContext(),
|
|
@@ -4096,7 +4251,8 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4096
4251
|
anchor: anchor,
|
|
4097
4252
|
schema: schema,
|
|
4098
4253
|
rule: rule,
|
|
4099
|
-
index: index$1
|
|
4254
|
+
index: index$1,
|
|
4255
|
+
configPending: configPending
|
|
4100
4256
|
});
|
|
4101
4257
|
if (target) openType({
|
|
4102
4258
|
type: target.type,
|
|
@@ -4110,21 +4266,53 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4110
4266
|
});
|
|
4111
4267
|
var optionLabel = function optionLabel(option) {
|
|
4112
4268
|
var Icon = option.icon;
|
|
4113
|
-
|
|
4269
|
+
// Short text sits inline as a pill; anything needing more room is a
|
|
4270
|
+
// standard popover behind an info icon.
|
|
4271
|
+
var reason = typeof option.disabledReason === "function" ? option.disabledReason() : option.disabledReason;
|
|
4272
|
+
var isTextReason = typeof reason === "string";
|
|
4273
|
+
// Only a node can be rendered as popover content; a host handing back a
|
|
4274
|
+
// plain object would otherwise crash the pane.
|
|
4275
|
+
var isNodeReason = /*#__PURE__*/react.isValidElement(reason) || Array.isArray(reason);
|
|
4276
|
+
var popover = option.disabledPopover || (isNodeReason ? {
|
|
4277
|
+
description: reason
|
|
4278
|
+
} : null);
|
|
4279
|
+
if (!Icon && !isTextReason && !popover) return option.label;
|
|
4114
4280
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
4115
4281
|
className: "mb-pane-option",
|
|
4116
4282
|
children: [Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
4117
4283
|
size: 20
|
|
4118
|
-
}), option.label,
|
|
4284
|
+
}), option.label, popover && /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Popover, {
|
|
4285
|
+
position: "top",
|
|
4286
|
+
trigger: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4287
|
+
className: "mb-pane-info",
|
|
4288
|
+
onClick: function onClick(event) {
|
|
4289
|
+
return event.preventDefault();
|
|
4290
|
+
},
|
|
4291
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Info, {
|
|
4292
|
+
size: 14
|
|
4293
|
+
})
|
|
4294
|
+
}),
|
|
4295
|
+
children: [popover.title && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Popover.Title, {
|
|
4296
|
+
children: popover.title
|
|
4297
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
4298
|
+
color: "muted",
|
|
4299
|
+
variant: "body2",
|
|
4300
|
+
children: popover.description
|
|
4301
|
+
}), popover.helpLinkProps && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, _objectSpread$2(_objectSpread$2({}, popover.helpLinkProps), {}, {
|
|
4302
|
+
className: "h-auto self-start p-0",
|
|
4303
|
+
size: "sm",
|
|
4304
|
+
variant: "link"
|
|
4305
|
+
}))]
|
|
4306
|
+
}), !popover && reason && isTextReason && (option.disabledTooltip ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
|
|
4119
4307
|
content: option.disabledTooltip,
|
|
4120
4308
|
position: "top",
|
|
4121
4309
|
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4122
4310
|
className: "mb-pane-warn",
|
|
4123
|
-
children:
|
|
4311
|
+
children: reason
|
|
4124
4312
|
})
|
|
4125
4313
|
}) : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4126
4314
|
className: "mb-pane-warn",
|
|
4127
|
-
children:
|
|
4315
|
+
children: reason
|
|
4128
4316
|
}))]
|
|
4129
4317
|
});
|
|
4130
4318
|
};
|
|
@@ -4295,7 +4483,9 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4295
4483
|
var RecipientPane = function RecipientPane(_ref) {
|
|
4296
4484
|
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;
|
|
4297
4485
|
var schema = _ref.schema,
|
|
4298
|
-
index$1 = _ref.index
|
|
4486
|
+
index$1 = _ref.index,
|
|
4487
|
+
_ref$configPending = _ref.configPending,
|
|
4488
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
4299
4489
|
var _useTranslation = reactI18next.useTranslation(),
|
|
4300
4490
|
t = _useTranslation.t;
|
|
4301
4491
|
var _useRuleModel = useRuleModel(schema),
|
|
@@ -4370,6 +4560,7 @@ var RecipientPane = function RecipientPane(_ref) {
|
|
|
4370
4560
|
if (!editor) {
|
|
4371
4561
|
return /*#__PURE__*/jsxRuntime.jsx(OptionsPane, {
|
|
4372
4562
|
belowContent: belowContent,
|
|
4563
|
+
configPending: configPending,
|
|
4373
4564
|
index: index$1,
|
|
4374
4565
|
schema: schema,
|
|
4375
4566
|
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
@@ -4495,9 +4686,6 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4495
4686
|
error: fieldError(valuePath),
|
|
4496
4687
|
orientation: "vertical",
|
|
4497
4688
|
value: String(_current2 !== null && _current2 !== void 0 ? _current2 : ""),
|
|
4498
|
-
onBlur: function onBlur() {
|
|
4499
|
-
return setFieldTouched(valuePath, true);
|
|
4500
|
-
},
|
|
4501
4689
|
onValueChange: function onValueChange(value) {
|
|
4502
4690
|
return setFieldValue(valuePath, value);
|
|
4503
4691
|
},
|
|
@@ -4722,7 +4910,10 @@ var Form = function Form(_ref) {
|
|
|
4722
4910
|
values: values,
|
|
4723
4911
|
schema: schema
|
|
4724
4912
|
});
|
|
4725
|
-
if (!isRuleComplete(
|
|
4913
|
+
if (!isRuleComplete({
|
|
4914
|
+
rule: rule,
|
|
4915
|
+
schema: schema
|
|
4916
|
+
}) || invalidScopeIndexes({
|
|
4726
4917
|
rule: rule,
|
|
4727
4918
|
schema: schema
|
|
4728
4919
|
}).length || invalidScopePhoneFieldIndexes({
|