@bigbinary/neeto-rules-frontend 2.7.22 → 2.7.24
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 +2 -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 +723 -311
- 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-Br0dDuGK.js} +4 -4
- package/dist/index-Br0dDuGK.js.map +1 -0
- package/dist/{index-Fukq1VSN.js → index-D1PW24Zw.js} +4 -3
- package/dist/index-D1PW24Zw.js.map +1 -0
- 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.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 +730 -318
- 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/index-CcbW7H2S.js.map +0 -1
- package/dist/index-Fukq1VSN.js.map +0 -1
- 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-D1PW24Zw.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');
|
|
@@ -179,6 +180,7 @@ var BUILDER_PANEL_TYPES = {
|
|
|
179
180
|
CONDITION_VALUE: "builder-condition-value",
|
|
180
181
|
ACTION_CHANNEL: "builder-action-channel",
|
|
181
182
|
ACTION_CONFIG: "builder-action-config",
|
|
183
|
+
ACTION_STEP: "builder-action-step",
|
|
182
184
|
RECIPIENT: "builder-recipient",
|
|
183
185
|
DELAY: "builder-delay",
|
|
184
186
|
LEAD_TIME: "builder-lead-time",
|
|
@@ -199,15 +201,16 @@ var BUILDER_ANCHORS = {
|
|
|
199
201
|
ACTION_CHANNEL: "action-channel",
|
|
200
202
|
ACTION_CONFIG: "action-config",
|
|
201
203
|
ACTION_RECIPIENT: "action-recipient",
|
|
204
|
+
ACTION_STEP: "action-step",
|
|
202
205
|
RULE_DELAY: "rule-delay",
|
|
203
206
|
META_NAME: "meta-name",
|
|
204
207
|
SCOPE: "scope",
|
|
205
208
|
SCOPE_PHONE_FIELD: "scope-phone-field"
|
|
206
209
|
};
|
|
207
|
-
var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
|
|
210
|
+
var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.ACTION_STEP, BUILDER_PANEL_TYPES.ACTION_STEP), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
|
|
208
211
|
var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
|
|
209
212
|
var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
|
|
210
|
-
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
|
|
213
|
+
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_ANCHORS.ACTION_STEP];
|
|
211
214
|
var PANE_SEARCH_THRESHOLD = 8;
|
|
212
215
|
var CONFIG_FOCUSABLE_SELECTOR = 'input:not([type="radio"]):not([type="checkbox"]), textarea, [contenteditable="true"]';
|
|
213
216
|
var SMS_TYPES = ["sms", "smsToNumbers"];
|
|
@@ -268,7 +271,7 @@ var useReplayFlash = function useReplayFlash(flashSeq) {
|
|
|
268
271
|
return ref;
|
|
269
272
|
};
|
|
270
273
|
|
|
271
|
-
var _excluded = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
274
|
+
var _excluded$1 = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
272
275
|
function ownKeys$c(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; }
|
|
273
276
|
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
274
277
|
var Token = function Token(_ref) {
|
|
@@ -282,7 +285,7 @@ var Token = function Token(_ref) {
|
|
|
282
285
|
onClick = _ref.onClick,
|
|
283
286
|
className = _ref.className,
|
|
284
287
|
dataTestid = _ref.dataTestid,
|
|
285
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
288
|
+
rest = _objectWithoutProperties(_ref, _excluded$1);
|
|
286
289
|
var isInteractive = typeof onClick === "function" && state !== TOKEN_STATE.DISABLED;
|
|
287
290
|
var tokenRef = useReplayFlash(invalid);
|
|
288
291
|
return /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread$c(_objectSpread$c({
|
|
@@ -326,8 +329,13 @@ var isExcludeVerb = function isExcludeVerb(verb) {
|
|
|
326
329
|
var isMultiValueVerb = function isMultiValueVerb(verb) {
|
|
327
330
|
return String(verb).includes(VERB_TOKENS.MULTI_VALUE);
|
|
328
331
|
};
|
|
332
|
+
|
|
333
|
+
// Lowers a label so it reads mid-sentence, but never an acronym: "API" and
|
|
334
|
+
// "SMS" are already how they should appear.
|
|
329
335
|
var sentencify = function sentencify(label) {
|
|
330
|
-
|
|
336
|
+
if (!label) return label;
|
|
337
|
+
if (label.charAt(1) === label.charAt(1).toUpperCase()) return label;
|
|
338
|
+
return label.charAt(0).toLowerCase() + label.slice(1);
|
|
331
339
|
};
|
|
332
340
|
var copyFor = function copyFor(value, args) {
|
|
333
341
|
return typeof value === "function" ? value(args) : value;
|
|
@@ -436,10 +444,43 @@ var channelOption = function channelOption(_ref10) {
|
|
|
436
444
|
return ((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id) === channel;
|
|
437
445
|
});
|
|
438
446
|
};
|
|
439
|
-
|
|
440
|
-
|
|
447
|
+
|
|
448
|
+
// A step is an extra sentence token a host hangs off an action — its own
|
|
449
|
+
// separator, its own pane — for settings that do not belong in the config pane.
|
|
450
|
+
// Its key shares the action's metadata namespace, so declaring one is how a
|
|
451
|
+
// host hands a field to the step: whoever declares it owns it, and the config
|
|
452
|
+
// pane stops validating it.
|
|
453
|
+
var actionStepsOf = function actionStepsOf(_ref11) {
|
|
441
454
|
var schema = _ref11.schema,
|
|
442
455
|
action = _ref11.action;
|
|
456
|
+
return actionParts({
|
|
457
|
+
schema: schema,
|
|
458
|
+
action: action
|
|
459
|
+
}).steps || [];
|
|
460
|
+
};
|
|
461
|
+
var stepValueOf = function stepValueOf(_ref12) {
|
|
462
|
+
var _action$metadata;
|
|
463
|
+
var action = _ref12.action,
|
|
464
|
+
step = _ref12.step;
|
|
465
|
+
return action === null || action === void 0 || (_action$metadata = action.metadata) === null || _action$metadata === void 0 ? void 0 : _action$metadata[step.key];
|
|
466
|
+
};
|
|
467
|
+
var stepLabelOf = function stepLabelOf(_ref13) {
|
|
468
|
+
var _find;
|
|
469
|
+
var action = _ref13.action,
|
|
470
|
+
step = _ref13.step;
|
|
471
|
+
var value = stepValueOf({
|
|
472
|
+
action: action,
|
|
473
|
+
step: step
|
|
474
|
+
});
|
|
475
|
+
return ((_find = (step.options || []).find(function (option) {
|
|
476
|
+
var _option$value2;
|
|
477
|
+
return ((_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : option.id) === value;
|
|
478
|
+
})) === null || _find === void 0 ? void 0 : _find.label) || "";
|
|
479
|
+
};
|
|
480
|
+
var actionParts = function actionParts(_ref14) {
|
|
481
|
+
var _actions$actionForNam, _action$recipient, _actions$channelMeta, _find2, _find3, _channelMeta$needsRec, _actions$configValueL;
|
|
482
|
+
var schema = _ref14.schema,
|
|
483
|
+
action = _ref14.action;
|
|
443
484
|
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
444
485
|
var resolved = action !== null && action !== void 0 && action.channel ? {
|
|
445
486
|
channel: action.channel,
|
|
@@ -461,7 +502,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
461
502
|
var _recipient$value;
|
|
462
503
|
return ((_recipient$value = recipient.value) !== null && _recipient$value !== void 0 ? _recipient$value : recipient.id) === recipientValue;
|
|
463
504
|
};
|
|
464
|
-
var recipientLabel = ((
|
|
505
|
+
var recipientLabel = ((_find2 = (actions.recipients || []).find(matchesRecipient)) === null || _find2 === void 0 ? void 0 : _find2.label) || ((_find3 = ((option === null || option === void 0 ? void 0 : option.recipients) || []).find(matchesRecipient)) === null || _find3 === void 0 ? void 0 : _find3.label) || recipientValue;
|
|
465
506
|
return {
|
|
466
507
|
option: option,
|
|
467
508
|
channel: channel,
|
|
@@ -480,6 +521,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
480
521
|
recipientLabel: recipientLabel,
|
|
481
522
|
configTitle: channelMeta.configTitle || (option === null || option === void 0 ? void 0 : option.configTitle),
|
|
482
523
|
configSubtitle: channelMeta.configSubtitle || (option === null || option === void 0 ? void 0 : option.configSubtitle),
|
|
524
|
+
steps: channelMeta.steps || (option === null || option === void 0 ? void 0 : option.steps) || [],
|
|
483
525
|
recipientTitle: channelMeta.recipientTitle || (option === null || option === void 0 ? void 0 : option.recipientTitle),
|
|
484
526
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
485
527
|
};
|
|
@@ -488,13 +530,13 @@ var actionParts = function actionParts(_ref11) {
|
|
|
488
530
|
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
489
531
|
// only support a subset. Lookups deliberately keep using the full list so a
|
|
490
532
|
// field already on the rule still resolves after the offer narrows.
|
|
491
|
-
var offeredConditionFields = function offeredConditionFields(
|
|
492
|
-
var
|
|
493
|
-
var schema =
|
|
494
|
-
rule =
|
|
495
|
-
return (
|
|
533
|
+
var offeredConditionFields = function offeredConditionFields(_ref15) {
|
|
534
|
+
var _ref16, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
535
|
+
var schema = _ref15.schema,
|
|
536
|
+
rule = _ref15.rule;
|
|
537
|
+
return (_ref16 = (_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, {
|
|
496
538
|
rule: rule
|
|
497
|
-
})) !== 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 &&
|
|
539
|
+
})) !== 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 && _ref16 !== void 0 ? _ref16 : [];
|
|
498
540
|
};
|
|
499
541
|
var hasTrigger = function hasTrigger(rule) {
|
|
500
542
|
return !ramda.isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
@@ -504,31 +546,72 @@ var hasAction = function hasAction(rule) {
|
|
|
504
546
|
return action === null || action === void 0 ? void 0 : action.name;
|
|
505
547
|
});
|
|
506
548
|
};
|
|
507
|
-
var
|
|
508
|
-
|
|
549
|
+
var isTriggerEnabled = function isTriggerEnabled(schema) {
|
|
550
|
+
var _schema$triggers2;
|
|
551
|
+
return (schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.enabled) !== false;
|
|
552
|
+
};
|
|
553
|
+
var isTriggerSatisfied = function isTriggerSatisfied(_ref17) {
|
|
554
|
+
var rule = _ref17.rule,
|
|
555
|
+
schema = _ref17.schema;
|
|
556
|
+
return !isTriggerEnabled(schema) || hasTrigger(rule);
|
|
557
|
+
};
|
|
558
|
+
var hasRequiredConditions = function hasRequiredConditions(_ref18) {
|
|
559
|
+
var _schema$conditions5;
|
|
560
|
+
var rule = _ref18.rule,
|
|
561
|
+
schema = _ref18.schema;
|
|
562
|
+
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;
|
|
563
|
+
};
|
|
564
|
+
var hasUnansweredStep = function hasUnansweredStep(_ref19) {
|
|
565
|
+
var rule = _ref19.rule,
|
|
566
|
+
schema = _ref19.schema;
|
|
567
|
+
return ((rule === null || rule === void 0 ? void 0 : rule.actions) || []).some(function (action) {
|
|
568
|
+
return actionStepsOf({
|
|
569
|
+
schema: schema,
|
|
570
|
+
action: action
|
|
571
|
+
}).some(function (step) {
|
|
572
|
+
return step.required && !stepValueOf({
|
|
573
|
+
action: action,
|
|
574
|
+
step: step
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
};
|
|
579
|
+
var isRuleComplete = function isRuleComplete(_ref20) {
|
|
580
|
+
var rule = _ref20.rule,
|
|
581
|
+
schema = _ref20.schema;
|
|
582
|
+
return isTriggerSatisfied({
|
|
583
|
+
rule: rule,
|
|
584
|
+
schema: schema
|
|
585
|
+
}) && hasRequiredConditions({
|
|
586
|
+
rule: rule,
|
|
587
|
+
schema: schema
|
|
588
|
+
}) && hasAction(rule) && !hasUnansweredStep({
|
|
589
|
+
rule: rule,
|
|
590
|
+
schema: schema
|
|
591
|
+
});
|
|
509
592
|
};
|
|
510
|
-
var scopeOptionFor = function scopeOptionFor(
|
|
593
|
+
var scopeOptionFor = function scopeOptionFor(_ref21) {
|
|
511
594
|
var _item$value, _schema$scope;
|
|
512
|
-
var schema =
|
|
513
|
-
item =
|
|
595
|
+
var schema = _ref21.schema,
|
|
596
|
+
item = _ref21.item;
|
|
514
597
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
515
598
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
516
599
|
var _candidate$value2;
|
|
517
600
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
518
601
|
});
|
|
519
602
|
};
|
|
520
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
521
|
-
var
|
|
522
|
-
var schema =
|
|
523
|
-
item =
|
|
524
|
-
return (
|
|
603
|
+
var scopePhoneFields = function scopePhoneFields(_ref22) {
|
|
604
|
+
var _ref23, _item$phoneFields, _scopeOptionFor;
|
|
605
|
+
var schema = _ref22.schema,
|
|
606
|
+
item = _ref22.item;
|
|
607
|
+
return (_ref23 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
525
608
|
schema: schema,
|
|
526
609
|
item: item
|
|
527
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
610
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref23 !== void 0 ? _ref23 : null;
|
|
528
611
|
};
|
|
529
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
530
|
-
var schema =
|
|
531
|
-
item =
|
|
612
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref24) {
|
|
613
|
+
var schema = _ref24.schema,
|
|
614
|
+
item = _ref24.item;
|
|
532
615
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
533
616
|
var phoneFields = scopePhoneFields({
|
|
534
617
|
schema: schema,
|
|
@@ -536,14 +619,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref17) {
|
|
|
536
619
|
});
|
|
537
620
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
538
621
|
};
|
|
539
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
622
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref25) {
|
|
540
623
|
var _scope$requiresPhone;
|
|
541
|
-
var rule =
|
|
542
|
-
schema =
|
|
624
|
+
var rule = _ref25.rule,
|
|
625
|
+
schema = _ref25.schema;
|
|
543
626
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
544
627
|
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 [];
|
|
545
628
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
546
|
-
var
|
|
629
|
+
var _ref26, _item$hasPhoneField;
|
|
547
630
|
var option = scopeOptionFor({
|
|
548
631
|
schema: schema,
|
|
549
632
|
item: item
|
|
@@ -552,15 +635,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref18) {
|
|
|
552
635
|
schema: schema,
|
|
553
636
|
item: item
|
|
554
637
|
});
|
|
555
|
-
var hasPhoneField = (
|
|
638
|
+
var hasPhoneField = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : phoneFields ? phoneFields.length > 0 : undefined;
|
|
556
639
|
if (hasPhoneField === false) indexes.push(index);
|
|
557
640
|
return indexes;
|
|
558
641
|
}, []);
|
|
559
642
|
};
|
|
560
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
643
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref27) {
|
|
561
644
|
var _scope$requiresPhone2;
|
|
562
|
-
var rule =
|
|
563
|
-
schema =
|
|
645
|
+
var rule = _ref27.rule,
|
|
646
|
+
schema = _ref27.schema;
|
|
564
647
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
565
648
|
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 [];
|
|
566
649
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
@@ -597,9 +680,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
597
680
|
unit: "minutes"
|
|
598
681
|
};
|
|
599
682
|
};
|
|
600
|
-
var partsToMinutes = function partsToMinutes(
|
|
601
|
-
var value =
|
|
602
|
-
unit =
|
|
683
|
+
var partsToMinutes = function partsToMinutes(_ref28) {
|
|
684
|
+
var value = _ref28.value,
|
|
685
|
+
unit = _ref28.unit;
|
|
603
686
|
return (
|
|
604
687
|
// eslint-disable-next-line security/detect-object-injection
|
|
605
688
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -609,8 +692,8 @@ var leadTimeExceedsMax = function leadTimeExceedsMax(minutes) {
|
|
|
609
692
|
return minutesToParts(minutes).value > MAX_LEAD_TIME_VALUE;
|
|
610
693
|
};
|
|
611
694
|
var leadTimeValidationSchema = function leadTimeValidationSchema(schema) {
|
|
612
|
-
var _schema$
|
|
613
|
-
var fieldKey = schema === null || schema === void 0 || (_schema$
|
|
695
|
+
var _schema$triggers3;
|
|
696
|
+
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;
|
|
614
697
|
if (!fieldKey) return yup__namespace.object();
|
|
615
698
|
return yup__namespace.object().shape(_defineProperty({}, fieldKey, yup__namespace.object().shape({
|
|
616
699
|
// yup 0.32 can only concat schemas of the same type, and the host's
|
|
@@ -649,30 +732,64 @@ var joinTypeFor = function joinTypeFor(mode) {
|
|
|
649
732
|
var recipientStorageField = function recipientStorageField(field) {
|
|
650
733
|
return field === RECIPIENT_STORAGE_FIELDS.emails ? RECIPIENT_STORAGE_FIELDS.emails : RECIPIENT_STORAGE_FIELDS.value;
|
|
651
734
|
};
|
|
735
|
+
|
|
736
|
+
// Which metadata fields the recipient pane renders, and therefore owns: no
|
|
737
|
+
// other pane may block Continue on them. Canvas and ConfigPane both ask here
|
|
738
|
+
// so the two lists cannot drift apart.
|
|
739
|
+
var recipientOwnedFields = function recipientOwnedFields(_ref29) {
|
|
740
|
+
var _actions$actionForNam2, _action$recipient2, _actions$renderRecipi, _actions$renderRecipi2, _actions$optionForNam, _actions$optionForCha;
|
|
741
|
+
var schema = _ref29.schema,
|
|
742
|
+
action = _ref29.action,
|
|
743
|
+
name = _ref29.name;
|
|
744
|
+
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
745
|
+
var resolved = ((_actions$actionForNam2 = actions.actionForName) === null || _actions$actionForNam2 === void 0 ? void 0 : _actions$actionForNam2.call(actions, action === null || action === void 0 ? void 0 : action.name)) || {};
|
|
746
|
+
var channel = (action === null || action === void 0 ? void 0 : action.channel) || resolved.channel;
|
|
747
|
+
// A recipient the host implies from the action name counts just as much as
|
|
748
|
+
// one the user picked, or the pane it owns cannot be excluded.
|
|
749
|
+
var recipient = (_action$recipient2 = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient2 !== void 0 ? _action$recipient2 : resolved.recipient;
|
|
750
|
+
var rendersEmails = !!((_actions$renderRecipi = actions.renderRecipientEditor) !== null && _actions$renderRecipi !== void 0 && _actions$renderRecipi.call(actions, {
|
|
751
|
+
channel: channel,
|
|
752
|
+
name: name,
|
|
753
|
+
action: action
|
|
754
|
+
})) || !!((_actions$renderRecipi2 = actions.renderRecipientField) !== null && _actions$renderRecipi2 !== void 0 && _actions$renderRecipi2.call(actions, {
|
|
755
|
+
channel: channel,
|
|
756
|
+
name: name,
|
|
757
|
+
action: action,
|
|
758
|
+
recipient: recipient
|
|
759
|
+
}));
|
|
760
|
+
var recipientConfig = (actions.options || []).flatMap(function (option) {
|
|
761
|
+
return option.recipients || [];
|
|
762
|
+
}).concat(actions.recipients || []).find(function (item) {
|
|
763
|
+
var _item$value2;
|
|
764
|
+
return ((_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.id) === recipient;
|
|
765
|
+
});
|
|
766
|
+
var flatOption = ((_actions$optionForNam = actions.optionForName) === null || _actions$optionForNam === void 0 ? void 0 : _actions$optionForNam.call(actions, action === null || action === void 0 ? void 0 : action.name)) || ((_actions$optionForCha = actions.optionForChannel) === null || _actions$optionForCha === void 0 ? void 0 : _actions$optionForCha.call(actions, channel));
|
|
767
|
+
return [].concat(_toConsumableArray(rendersEmails ? [RECIPIENT_STORAGE_FIELDS.emails] : []), _toConsumableArray(recipientConfig !== null && recipientConfig !== void 0 && recipientConfig.field ? [recipientStorageField(recipientConfig.field)] : []), _toConsumableArray((flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === SMS_TO_NUMBERS ? [RECIPIENT_STORAGE_FIELDS.phoneNumbers] : []));
|
|
768
|
+
};
|
|
652
769
|
var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
653
770
|
return joinType === JOIN_TYPE.or ? CONDITION_MODE.OR : CONDITION_MODE.AND;
|
|
654
771
|
};
|
|
655
772
|
|
|
656
773
|
// eslint-disable-next-line security/detect-object-injection
|
|
657
|
-
var valueAt = function valueAt(
|
|
774
|
+
var valueAt = function valueAt(_ref30) {
|
|
658
775
|
var _values$key;
|
|
659
|
-
var values =
|
|
660
|
-
key =
|
|
776
|
+
var values = _ref30.values,
|
|
777
|
+
key = _ref30.key;
|
|
661
778
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
662
779
|
};
|
|
663
780
|
var asArray = function asArray(maybeArray) {
|
|
664
781
|
return Array.isArray(maybeArray) ? maybeArray : [];
|
|
665
782
|
};
|
|
666
783
|
var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
667
|
-
var _schema$
|
|
784
|
+
var _schema$triggers4, _schema$actor2, _schema$conditions6, _schema$actions3, _schema$delay, _schema$triggers5, _schema$scope2;
|
|
668
785
|
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
669
786
|
return {
|
|
670
|
-
triggers: ((_schema$
|
|
787
|
+
triggers: ((_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey) || "events",
|
|
671
788
|
performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
|
|
672
|
-
conditions: ((_schema$
|
|
789
|
+
conditions: ((_schema$conditions6 = schema.conditions) === null || _schema$conditions6 === void 0 ? void 0 : _schema$conditions6.fieldKey) || "conditions",
|
|
673
790
|
actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
|
|
674
791
|
delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
|
|
675
|
-
leadTime: (_schema$
|
|
792
|
+
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,
|
|
676
793
|
scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
|
|
677
794
|
status: "status",
|
|
678
795
|
name: "name"
|
|
@@ -680,11 +797,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
680
797
|
};
|
|
681
798
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
682
799
|
var _valueAt, _conditions$;
|
|
683
|
-
var
|
|
684
|
-
|
|
685
|
-
values =
|
|
686
|
-
|
|
687
|
-
schema =
|
|
800
|
+
var _ref31 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
801
|
+
_ref31$values = _ref31.values,
|
|
802
|
+
values = _ref31$values === void 0 ? {} : _ref31$values,
|
|
803
|
+
_ref31$schema = _ref31.schema,
|
|
804
|
+
schema = _ref31$schema === void 0 ? {} : _ref31$schema;
|
|
688
805
|
var keys = fieldKeysFromSchema(schema);
|
|
689
806
|
var conditions = asArray(valueAt({
|
|
690
807
|
values: values,
|
|
@@ -728,42 +845,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
728
845
|
}))
|
|
729
846
|
};
|
|
730
847
|
};
|
|
731
|
-
var setTriggers = function setTriggers(
|
|
732
|
-
var schema =
|
|
733
|
-
triggers =
|
|
848
|
+
var setTriggers = function setTriggers(_ref32) {
|
|
849
|
+
var schema = _ref32.schema,
|
|
850
|
+
triggers = _ref32.triggers;
|
|
734
851
|
return {
|
|
735
852
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
736
853
|
value: triggers
|
|
737
854
|
};
|
|
738
855
|
};
|
|
739
|
-
var setPerformer = function setPerformer(
|
|
740
|
-
var schema =
|
|
741
|
-
performer =
|
|
856
|
+
var setPerformer = function setPerformer(_ref33) {
|
|
857
|
+
var schema = _ref33.schema,
|
|
858
|
+
performer = _ref33.performer;
|
|
742
859
|
return {
|
|
743
860
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
744
861
|
value: performer
|
|
745
862
|
};
|
|
746
863
|
};
|
|
747
|
-
var setActions = function setActions(
|
|
748
|
-
var schema =
|
|
749
|
-
actions =
|
|
864
|
+
var setActions = function setActions(_ref34) {
|
|
865
|
+
var schema = _ref34.schema,
|
|
866
|
+
actions = _ref34.actions;
|
|
750
867
|
return {
|
|
751
868
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
752
869
|
value: actions
|
|
753
870
|
};
|
|
754
871
|
};
|
|
755
|
-
var setConditions = function setConditions(
|
|
756
|
-
var schema =
|
|
757
|
-
conditions =
|
|
872
|
+
var setConditions = function setConditions(_ref35) {
|
|
873
|
+
var schema = _ref35.schema,
|
|
874
|
+
conditions = _ref35.conditions;
|
|
758
875
|
return {
|
|
759
876
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
760
877
|
value: conditions
|
|
761
878
|
};
|
|
762
879
|
};
|
|
763
|
-
var setConditionMode = function setConditionMode(
|
|
764
|
-
var schema =
|
|
765
|
-
conditions =
|
|
766
|
-
joinType =
|
|
880
|
+
var setConditionMode = function setConditionMode(_ref36) {
|
|
881
|
+
var schema = _ref36.schema,
|
|
882
|
+
conditions = _ref36.conditions,
|
|
883
|
+
joinType = _ref36.joinType;
|
|
767
884
|
return setConditions({
|
|
768
885
|
schema: schema,
|
|
769
886
|
conditions: conditions.map(function (condition) {
|
|
@@ -771,34 +888,34 @@ var setConditionMode = function setConditionMode(_ref28) {
|
|
|
771
888
|
})
|
|
772
889
|
});
|
|
773
890
|
};
|
|
774
|
-
var setDelay = function setDelay(
|
|
775
|
-
var schema =
|
|
776
|
-
delay =
|
|
891
|
+
var setDelay = function setDelay(_ref37) {
|
|
892
|
+
var schema = _ref37.schema,
|
|
893
|
+
delay = _ref37.delay;
|
|
777
894
|
return {
|
|
778
895
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
779
896
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
780
897
|
};
|
|
781
898
|
};
|
|
782
|
-
var setActive = function setActive(
|
|
783
|
-
var schema =
|
|
784
|
-
active =
|
|
899
|
+
var setActive = function setActive(_ref38) {
|
|
900
|
+
var schema = _ref38.schema,
|
|
901
|
+
active = _ref38.active;
|
|
785
902
|
return {
|
|
786
903
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
787
904
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
788
905
|
};
|
|
789
906
|
};
|
|
790
|
-
var setScope = function setScope(
|
|
791
|
-
var schema =
|
|
792
|
-
scope =
|
|
907
|
+
var setScope = function setScope(_ref39) {
|
|
908
|
+
var schema = _ref39.schema,
|
|
909
|
+
scope = _ref39.scope;
|
|
793
910
|
return {
|
|
794
911
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
795
912
|
value: scope
|
|
796
913
|
};
|
|
797
914
|
};
|
|
798
|
-
var removeArrayItem = function removeArrayItem(
|
|
799
|
-
var values =
|
|
800
|
-
fieldKey =
|
|
801
|
-
index =
|
|
915
|
+
var removeArrayItem = function removeArrayItem(_ref40) {
|
|
916
|
+
var values = _ref40.values,
|
|
917
|
+
fieldKey = _ref40.fieldKey,
|
|
918
|
+
index = _ref40.index;
|
|
802
919
|
var list = asArray(valueAt({
|
|
803
920
|
values: values,
|
|
804
921
|
key: fieldKey
|
|
@@ -825,9 +942,9 @@ var removeArrayItem = function removeArrayItem(_ref32) {
|
|
|
825
942
|
}
|
|
826
943
|
return result;
|
|
827
944
|
};
|
|
828
|
-
var clearArrayItems = function clearArrayItems(
|
|
829
|
-
var values =
|
|
830
|
-
fieldKey =
|
|
945
|
+
var clearArrayItems = function clearArrayItems(_ref41) {
|
|
946
|
+
var values = _ref41.values,
|
|
947
|
+
fieldKey = _ref41.fieldKey;
|
|
831
948
|
var list = asArray(valueAt({
|
|
832
949
|
values: values,
|
|
833
950
|
key: fieldKey
|
|
@@ -903,13 +1020,13 @@ var ConditionRow = function ConditionRow(_ref) {
|
|
|
903
1020
|
className: "mb-sentence",
|
|
904
1021
|
children: [isFirst ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
905
1022
|
className: "mb-fixed",
|
|
906
|
-
children: t("neetoRules.operators.and")
|
|
1023
|
+
children: isTriggerEnabled(schema) ? t("neetoRules.operators.and") : t("neetoRules.common.when")
|
|
907
1024
|
}) : /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
908
1025
|
active: isActive({
|
|
909
1026
|
type: BUILDER_ANCHORS.COND_CONNECTOR,
|
|
910
1027
|
index: index
|
|
911
1028
|
}),
|
|
912
|
-
className: "mb-tok-
|
|
1029
|
+
className: "mb-tok-connector",
|
|
913
1030
|
dataTestid: "cond-connector-".concat(index),
|
|
914
1031
|
onClick: handleToken && function () {
|
|
915
1032
|
return handleToken({
|
|
@@ -1132,8 +1249,8 @@ var MetaBlock = function MetaBlock(_ref) {
|
|
|
1132
1249
|
className: "mb-meta-label",
|
|
1133
1250
|
children: t("neetoRules.builder.automationName")
|
|
1134
1251
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1135
|
-
ref: nameRef,
|
|
1136
1252
|
"data-testid": "rule-name-edit",
|
|
1253
|
+
ref: nameRef,
|
|
1137
1254
|
role: handleEditName ? "button" : undefined,
|
|
1138
1255
|
tabIndex: handleEditName ? 0 : undefined,
|
|
1139
1256
|
className: classNames("mb-meta-input-wrap", {
|
|
@@ -1405,8 +1522,12 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1405
1522
|
configValuePlaceholder = _actionParts.configValuePlaceholder,
|
|
1406
1523
|
paramKind = _actionParts.paramKind,
|
|
1407
1524
|
valueNoun = _actionParts.valueNoun,
|
|
1408
|
-
valueNounPlural = _actionParts.valueNounPlural
|
|
1409
|
-
|
|
1525
|
+
valueNounPlural = _actionParts.valueNounPlural,
|
|
1526
|
+
steps = _actionParts.steps;
|
|
1527
|
+
|
|
1528
|
+
// A separator-less action still needs a value slot when the host declares a
|
|
1529
|
+
// placeholder for it, otherwise its chosen value never reaches the canvas.
|
|
1530
|
+
var hasParamTail = paramKind === PARAM_KIND.ENUM_SINGLE || paramKind === PARAM_KIND.ENUM_MULTI || !!configValuePlaceholder || !!configValue;
|
|
1410
1531
|
var multiPlaceholder = valueNounPlural ? t("neetoRules.builder.selectNoun", {
|
|
1411
1532
|
noun: valueNounPlural
|
|
1412
1533
|
}) : t("neetoRules.form.selectValues");
|
|
@@ -1424,12 +1545,92 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1424
1545
|
index: index
|
|
1425
1546
|
});
|
|
1426
1547
|
var configLabel = mediumLabel || sentencify(option === null || option === void 0 ? void 0 : option.placeholder);
|
|
1548
|
+
// A host may declare two separators: the first introduces the recipient
|
|
1549
|
+
// ("whose email is"), the second the configured value ("with the following").
|
|
1550
|
+
var _ref2 = Array.isArray(separator) ? separator : [null, separator],
|
|
1551
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
1552
|
+
recipientSeparator = _ref3[0],
|
|
1553
|
+
configSeparator = _ref3[1];
|
|
1427
1554
|
var isConfigured = neetoCist.isNotEmpty(action === null || action === void 0 ? void 0 : action.metadata);
|
|
1428
1555
|
// A host that shows no value label still needs the token to read as filled.
|
|
1429
1556
|
var configState = configValue || isConfigured ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED;
|
|
1430
1557
|
var _useClearingHover = useClearingHover(),
|
|
1431
1558
|
clearing = _useClearingHover.clearing,
|
|
1432
1559
|
clearingHoverProps = _useClearingHover.clearingHoverProps;
|
|
1560
|
+
var configToken = configSeparator ? /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
1561
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1562
|
+
className: "mb-fixed",
|
|
1563
|
+
children: configSeparator
|
|
1564
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1565
|
+
active: isActive({
|
|
1566
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1567
|
+
index: index
|
|
1568
|
+
}),
|
|
1569
|
+
dataTestid: "action-config-value-".concat(index),
|
|
1570
|
+
state: configState,
|
|
1571
|
+
invalid: isInvalid({
|
|
1572
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1573
|
+
index: index
|
|
1574
|
+
}),
|
|
1575
|
+
onClick: handleToken && function () {
|
|
1576
|
+
return handleToken({
|
|
1577
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1578
|
+
index: index
|
|
1579
|
+
});
|
|
1580
|
+
},
|
|
1581
|
+
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1582
|
+
})]
|
|
1583
|
+
}, "config") : null;
|
|
1584
|
+
var recipientToken = needsRecipient ? /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
1585
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1586
|
+
className: "mb-fixed",
|
|
1587
|
+
children: recipientSeparator || t("neetoRules.common.to")
|
|
1588
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1589
|
+
dataTestid: "action-recipient-".concat(index),
|
|
1590
|
+
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1591
|
+
active: isActive({
|
|
1592
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1593
|
+
index: index
|
|
1594
|
+
}),
|
|
1595
|
+
invalid: isInvalid({
|
|
1596
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1597
|
+
index: index
|
|
1598
|
+
}),
|
|
1599
|
+
onClick: handleToken && function () {
|
|
1600
|
+
return handleToken({
|
|
1601
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1602
|
+
index: index
|
|
1603
|
+
});
|
|
1604
|
+
},
|
|
1605
|
+
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1606
|
+
})]
|
|
1607
|
+
}, "recipient") : null;
|
|
1608
|
+
var stepTokens = steps.map(function (step) {
|
|
1609
|
+
var stepLabel = stepLabelOf({
|
|
1610
|
+
action: action,
|
|
1611
|
+
step: step
|
|
1612
|
+
});
|
|
1613
|
+
var token = {
|
|
1614
|
+
type: BUILDER_ANCHORS.ACTION_STEP,
|
|
1615
|
+
index: index,
|
|
1616
|
+
stepKey: step.key
|
|
1617
|
+
};
|
|
1618
|
+
return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
1619
|
+
children: [step.separator && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1620
|
+
className: "mb-fixed",
|
|
1621
|
+
children: step.separator
|
|
1622
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1623
|
+
active: isActive(token),
|
|
1624
|
+
dataTestid: "action-step-".concat(step.key, "-").concat(index),
|
|
1625
|
+
invalid: isInvalid(token),
|
|
1626
|
+
state: stepLabel ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1627
|
+
onClick: handleToken && function () {
|
|
1628
|
+
return handleToken(token);
|
|
1629
|
+
},
|
|
1630
|
+
children: (step.preserveCase ? stepLabel : sentencify(stepLabel)) || sentencify(step.placeholder)
|
|
1631
|
+
})]
|
|
1632
|
+
}, "step-".concat(step.key));
|
|
1633
|
+
});
|
|
1433
1634
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1434
1635
|
className: classNames("mb-row mb-row-draggable", {
|
|
1435
1636
|
clearing: clearing
|
|
@@ -1439,7 +1640,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1439
1640
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1440
1641
|
className: "mb-fixed",
|
|
1441
1642
|
children: connector
|
|
1442
|
-
}),
|
|
1643
|
+
}), configSeparator ? /*#__PURE__*/jsxRuntime.jsxs(Token, {
|
|
1443
1644
|
active: isVerbActive,
|
|
1444
1645
|
className: "mb-tok-medium",
|
|
1445
1646
|
dataTestid: "action-verb-".concat(index),
|
|
@@ -1480,7 +1681,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1480
1681
|
index: index
|
|
1481
1682
|
});
|
|
1482
1683
|
},
|
|
1483
|
-
children: configValue || paramPlaceholder
|
|
1684
|
+
children: configValue || sentencify(configValuePlaceholder) || paramPlaceholder
|
|
1484
1685
|
}) : configLabel && /*#__PURE__*/jsxRuntime.jsxs(Token, {
|
|
1485
1686
|
className: "mb-tok-medium",
|
|
1486
1687
|
dataTestid: "action-config-".concat(index),
|
|
@@ -1503,53 +1704,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1503
1704
|
size: 14
|
|
1504
1705
|
}), configLabel]
|
|
1505
1706
|
})]
|
|
1506
|
-
}),
|
|
1507
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1508
|
-
className: "mb-fixed",
|
|
1509
|
-
children: separator
|
|
1510
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1511
|
-
active: isActive({
|
|
1512
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1513
|
-
index: index
|
|
1514
|
-
}),
|
|
1515
|
-
dataTestid: "action-config-value-".concat(index),
|
|
1516
|
-
state: configState,
|
|
1517
|
-
invalid: isInvalid({
|
|
1518
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1519
|
-
index: index
|
|
1520
|
-
}),
|
|
1521
|
-
onClick: handleToken && function () {
|
|
1522
|
-
return handleToken({
|
|
1523
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1524
|
-
index: index
|
|
1525
|
-
});
|
|
1526
|
-
},
|
|
1527
|
-
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1528
|
-
})]
|
|
1529
|
-
}), needsRecipient && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1530
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1531
|
-
className: "mb-fixed",
|
|
1532
|
-
children: t("neetoRules.common.to")
|
|
1533
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1534
|
-
dataTestid: "action-recipient-".concat(index),
|
|
1535
|
-
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1536
|
-
active: isActive({
|
|
1537
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1538
|
-
index: index
|
|
1539
|
-
}),
|
|
1540
|
-
invalid: isInvalid({
|
|
1541
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1542
|
-
index: index
|
|
1543
|
-
}),
|
|
1544
|
-
onClick: handleToken && function () {
|
|
1545
|
-
return handleToken({
|
|
1546
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1547
|
-
index: index
|
|
1548
|
-
});
|
|
1549
|
-
},
|
|
1550
|
-
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1551
|
-
})]
|
|
1552
|
-
})]
|
|
1707
|
+
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken], stepTokens]
|
|
1553
1708
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1554
1709
|
className: "mb-row-actions",
|
|
1555
1710
|
children: [handleAddAction && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
@@ -1605,7 +1760,10 @@ var ThenBlock = function ThenBlock(_ref) {
|
|
|
1605
1760
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
1606
1761
|
});
|
|
1607
1762
|
if (ramda.isEmpty(named)) {
|
|
1608
|
-
var isTriggerSet =
|
|
1763
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
1764
|
+
rule: rule,
|
|
1765
|
+
schema: schema
|
|
1766
|
+
});
|
|
1609
1767
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1610
1768
|
className: "mb-row",
|
|
1611
1769
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -1697,6 +1855,21 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1697
1855
|
var _schema$triggers;
|
|
1698
1856
|
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);
|
|
1699
1857
|
};
|
|
1858
|
+
if (!isTriggerEnabled(schema)) {
|
|
1859
|
+
if (!ramda.isEmpty(rule.conditions)) return null;
|
|
1860
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1861
|
+
className: "mb-row",
|
|
1862
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1863
|
+
className: "mb-sentence",
|
|
1864
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Token, {
|
|
1865
|
+
dataTestid: "condition-add",
|
|
1866
|
+
state: TOKEN_STATE.PLACEHOLDER_NEXT,
|
|
1867
|
+
onClick: handleAddCondition || undefined,
|
|
1868
|
+
children: t("neetoRules.builder.whenThisIsTrue")
|
|
1869
|
+
})
|
|
1870
|
+
})
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1700
1873
|
if (ramda.isEmpty(triggers)) {
|
|
1701
1874
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1702
1875
|
className: "mb-row",
|
|
@@ -1825,6 +1998,7 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1825
1998
|
});
|
|
1826
1999
|
};
|
|
1827
2000
|
|
|
2001
|
+
var _excluded = ["type"];
|
|
1828
2002
|
function ownKeys$5(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; }
|
|
1829
2003
|
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1830
2004
|
var usePaneCascade = function usePaneCascade(schema) {
|
|
@@ -1852,12 +2026,13 @@ var usePaneCascade = function usePaneCascade(schema) {
|
|
|
1852
2026
|
var openPane = react.useCallback(function (token) {
|
|
1853
2027
|
var type = TOKEN_TO_PANEL_TYPE[token === null || token === void 0 ? void 0 : token.type];
|
|
1854
2028
|
if (!type) return;
|
|
2029
|
+
var anchor = token.type,
|
|
2030
|
+
rest = _objectWithoutProperties(token, _excluded);
|
|
1855
2031
|
openType({
|
|
1856
2032
|
type: type,
|
|
1857
|
-
data: {
|
|
1858
|
-
anchor:
|
|
1859
|
-
|
|
1860
|
-
}
|
|
2033
|
+
data: _objectSpread$5({
|
|
2034
|
+
anchor: anchor
|
|
2035
|
+
}, rest)
|
|
1861
2036
|
});
|
|
1862
2037
|
}, [openType]);
|
|
1863
2038
|
return {
|
|
@@ -1978,6 +2153,52 @@ var triggerValue = function triggerValue(option) {
|
|
|
1978
2153
|
var _ref, _option$eventValue;
|
|
1979
2154
|
return (_ref = (_option$eventValue = option.eventValue) !== null && _option$eventValue !== void 0 ? _option$eventValue : option.value) !== null && _ref !== void 0 ? _ref : option.id;
|
|
1980
2155
|
};
|
|
2156
|
+
var stepAt = function stepAt(_ref2) {
|
|
2157
|
+
var schema = _ref2.schema,
|
|
2158
|
+
rule = _ref2.rule,
|
|
2159
|
+
index = _ref2.index,
|
|
2160
|
+
stepKey = _ref2.stepKey;
|
|
2161
|
+
return actionStepsOf({
|
|
2162
|
+
schema: schema,
|
|
2163
|
+
action: actionAt({
|
|
2164
|
+
rule: rule,
|
|
2165
|
+
index: index
|
|
2166
|
+
})
|
|
2167
|
+
}).find(function (step) {
|
|
2168
|
+
return step.key === stepKey;
|
|
2169
|
+
});
|
|
2170
|
+
};
|
|
2171
|
+
|
|
2172
|
+
// Panes hand off in sentence order — config, recipient, then each host step —
|
|
2173
|
+
// so every "what comes next" question resolves through this one list.
|
|
2174
|
+
var stepTargetAfter = function stepTargetAfter(_ref3) {
|
|
2175
|
+
var schema = _ref3.schema,
|
|
2176
|
+
rule = _ref3.rule,
|
|
2177
|
+
index = _ref3.index,
|
|
2178
|
+
stepKey = _ref3.stepKey;
|
|
2179
|
+
var steps = actionStepsOf({
|
|
2180
|
+
schema: schema,
|
|
2181
|
+
action: actionAt({
|
|
2182
|
+
rule: rule,
|
|
2183
|
+
index: index
|
|
2184
|
+
})
|
|
2185
|
+
});
|
|
2186
|
+
var at = stepKey ? steps.findIndex(function (step) {
|
|
2187
|
+
return step.key === stepKey;
|
|
2188
|
+
}) : -1;
|
|
2189
|
+
// An unknown key means the step is gone from under the pane; restarting the
|
|
2190
|
+
// cascade at the first step would be worse than ending it.
|
|
2191
|
+
if (stepKey && at === -1) return null;
|
|
2192
|
+
var next = steps[at + 1];
|
|
2193
|
+
return next ? {
|
|
2194
|
+
type: BUILDER_PANEL_TYPES.ACTION_STEP,
|
|
2195
|
+
data: {
|
|
2196
|
+
index: index,
|
|
2197
|
+
stepKey: next.key,
|
|
2198
|
+
anchor: BUILDER_ANCHORS.ACTION_STEP
|
|
2199
|
+
}
|
|
2200
|
+
} : null;
|
|
2201
|
+
};
|
|
1981
2202
|
var optionValue = function optionValue(option) {
|
|
1982
2203
|
var _option$value;
|
|
1983
2204
|
return (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id;
|
|
@@ -2003,9 +2224,9 @@ var groupByCategory = function groupByCategory(options) {
|
|
|
2003
2224
|
});
|
|
2004
2225
|
return groups;
|
|
2005
2226
|
};
|
|
2006
|
-
var conditionAt = function conditionAt(
|
|
2007
|
-
var rule =
|
|
2008
|
-
index =
|
|
2227
|
+
var conditionAt = function conditionAt(_ref4) {
|
|
2228
|
+
var rule = _ref4.rule,
|
|
2229
|
+
index = _ref4.index;
|
|
2009
2230
|
return (
|
|
2010
2231
|
// eslint-disable-next-line security/detect-object-injection
|
|
2011
2232
|
rule.conditions[index] || {}
|
|
@@ -2013,63 +2234,63 @@ var conditionAt = function conditionAt(_ref2) {
|
|
|
2013
2234
|
};
|
|
2014
2235
|
|
|
2015
2236
|
// eslint-disable-next-line security/detect-object-injection
|
|
2016
|
-
var actionAt = function actionAt(
|
|
2017
|
-
var rule =
|
|
2018
|
-
index =
|
|
2237
|
+
var actionAt = function actionAt(_ref5) {
|
|
2238
|
+
var rule = _ref5.rule,
|
|
2239
|
+
index = _ref5.index;
|
|
2019
2240
|
return rule.actions[index] || {};
|
|
2020
2241
|
};
|
|
2021
2242
|
|
|
2022
2243
|
// eslint-disable-next-line security/detect-object-injection
|
|
2023
|
-
var scopeItemAt = function scopeItemAt(
|
|
2244
|
+
var scopeItemAt = function scopeItemAt(_ref6) {
|
|
2024
2245
|
var _rule$scope;
|
|
2025
|
-
var rule =
|
|
2026
|
-
index =
|
|
2246
|
+
var rule = _ref6.rule,
|
|
2247
|
+
index = _ref6.index;
|
|
2027
2248
|
return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
|
|
2028
2249
|
};
|
|
2029
2250
|
var scopeItemLabel = function scopeItemLabel(item) {
|
|
2030
2251
|
return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
|
|
2031
2252
|
};
|
|
2032
|
-
var findField = function findField(
|
|
2253
|
+
var findField = function findField(_ref7) {
|
|
2033
2254
|
var _schema$conditions;
|
|
2034
|
-
var schema =
|
|
2035
|
-
value =
|
|
2255
|
+
var schema = _ref7.schema,
|
|
2256
|
+
value = _ref7.value;
|
|
2036
2257
|
return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
|
|
2037
2258
|
return optionValue(field) === value;
|
|
2038
2259
|
});
|
|
2039
2260
|
};
|
|
2040
|
-
var findActionOption = function findActionOption(
|
|
2261
|
+
var findActionOption = function findActionOption(_ref8) {
|
|
2041
2262
|
var _schema$actions;
|
|
2042
|
-
var schema =
|
|
2043
|
-
name =
|
|
2263
|
+
var schema = _ref8.schema,
|
|
2264
|
+
name = _ref8.name;
|
|
2044
2265
|
return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
|
|
2045
2266
|
return optionValue(option) === name;
|
|
2046
2267
|
});
|
|
2047
2268
|
};
|
|
2048
|
-
var channelOf = function channelOf(
|
|
2269
|
+
var channelOf = function channelOf(_ref9) {
|
|
2049
2270
|
var _schema$actions2, _schema$actions2$acti;
|
|
2050
|
-
var schema =
|
|
2051
|
-
action =
|
|
2271
|
+
var schema = _ref9.schema,
|
|
2272
|
+
action = _ref9.action;
|
|
2052
2273
|
return (action === null || action === void 0 ? void 0 : action.channel) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.channel);
|
|
2053
2274
|
};
|
|
2054
|
-
var recipientOf = function recipientOf(
|
|
2275
|
+
var recipientOf = function recipientOf(_ref0) {
|
|
2055
2276
|
var _action$recipient, _schema$actions3, _schema$actions3$acti;
|
|
2056
|
-
var schema =
|
|
2057
|
-
action =
|
|
2277
|
+
var schema = _ref0.schema,
|
|
2278
|
+
action = _ref0.action;
|
|
2058
2279
|
return (_action$recipient = action === null || action === void 0 ? void 0 : 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 === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions3$acti === void 0 ? void 0 : _schema$actions3$acti.recipient;
|
|
2059
2280
|
};
|
|
2060
|
-
var channelMetaOf = function channelMetaOf(
|
|
2281
|
+
var channelMetaOf = function channelMetaOf(_ref1) {
|
|
2061
2282
|
var _schema$actions4;
|
|
2062
|
-
var schema =
|
|
2063
|
-
action =
|
|
2283
|
+
var schema = _ref1.schema,
|
|
2284
|
+
action = _ref1.action;
|
|
2064
2285
|
return ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4 = _schema$actions4.channelMeta) === null || _schema$actions4 === void 0 ? void 0 : _schema$actions4[channelOf({
|
|
2065
2286
|
schema: schema,
|
|
2066
2287
|
action: action
|
|
2067
2288
|
})]) || {};
|
|
2068
2289
|
};
|
|
2069
|
-
var actionHasConfig = function actionHasConfig(
|
|
2290
|
+
var actionHasConfig = function actionHasConfig(_ref10) {
|
|
2070
2291
|
var _schema$actions5, _schema$actions6;
|
|
2071
|
-
var schema =
|
|
2072
|
-
action =
|
|
2292
|
+
var schema = _ref10.schema,
|
|
2293
|
+
action = _ref10.action;
|
|
2073
2294
|
var meta = channelMetaOf({
|
|
2074
2295
|
schema: schema,
|
|
2075
2296
|
action: action
|
|
@@ -2083,10 +2304,10 @@ var actionHasConfig = function actionHasConfig(_ref0) {
|
|
|
2083
2304
|
if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
|
|
2084
2305
|
return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
|
|
2085
2306
|
};
|
|
2086
|
-
var recipientsFor = function recipientsFor(
|
|
2307
|
+
var recipientsFor = function recipientsFor(_ref11) {
|
|
2087
2308
|
var _schema$actions7, _schema$actions8;
|
|
2088
|
-
var schema =
|
|
2089
|
-
action =
|
|
2309
|
+
var schema = _ref11.schema,
|
|
2310
|
+
action = _ref11.action;
|
|
2090
2311
|
var channel = channelOf({
|
|
2091
2312
|
schema: schema,
|
|
2092
2313
|
action: action
|
|
@@ -2101,11 +2322,11 @@ var recipientsFor = function recipientsFor(_ref1) {
|
|
|
2101
2322
|
if (option !== null && option !== void 0 && option.recipients) return option.recipients;
|
|
2102
2323
|
return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
|
|
2103
2324
|
};
|
|
2104
|
-
var nextTriggers = function nextTriggers(
|
|
2325
|
+
var nextTriggers = function nextTriggers(_ref12) {
|
|
2105
2326
|
var _schema$triggers;
|
|
2106
|
-
var schema =
|
|
2107
|
-
rule =
|
|
2108
|
-
value =
|
|
2327
|
+
var schema = _ref12.schema,
|
|
2328
|
+
rule = _ref12.rule,
|
|
2329
|
+
value = _ref12.value;
|
|
2109
2330
|
if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
|
|
2110
2331
|
var names = ramda.pluck("name", rule.triggers);
|
|
2111
2332
|
return names.includes(value) ? neetoCist.removeBy({
|
|
@@ -2118,12 +2339,12 @@ var nextTriggers = function nextTriggers(_ref10) {
|
|
|
2118
2339
|
name: value
|
|
2119
2340
|
})];
|
|
2120
2341
|
};
|
|
2121
|
-
var nextConditionAt = function nextConditionAt(
|
|
2342
|
+
var nextConditionAt = function nextConditionAt(_ref13) {
|
|
2122
2343
|
var _field$allowMatching;
|
|
2123
|
-
var schema =
|
|
2124
|
-
rule =
|
|
2125
|
-
index =
|
|
2126
|
-
value =
|
|
2344
|
+
var schema = _ref13.schema,
|
|
2345
|
+
rule = _ref13.rule,
|
|
2346
|
+
index = _ref13.index,
|
|
2347
|
+
value = _ref13.value;
|
|
2127
2348
|
var field = findField({
|
|
2128
2349
|
schema: schema,
|
|
2129
2350
|
value: value
|
|
@@ -2142,12 +2363,12 @@ var nextConditionAt = function nextConditionAt(_ref11) {
|
|
|
2142
2363
|
metadata: {}
|
|
2143
2364
|
});
|
|
2144
2365
|
};
|
|
2145
|
-
var nextActionAt = function nextActionAt(
|
|
2366
|
+
var nextActionAt = function nextActionAt(_ref14) {
|
|
2146
2367
|
var _schema$actions9;
|
|
2147
|
-
var schema =
|
|
2148
|
-
rule =
|
|
2149
|
-
index =
|
|
2150
|
-
value =
|
|
2368
|
+
var schema = _ref14.schema,
|
|
2369
|
+
rule = _ref14.rule,
|
|
2370
|
+
index = _ref14.index,
|
|
2371
|
+
value = _ref14.value;
|
|
2151
2372
|
if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
|
|
2152
2373
|
var option = findActionOption({
|
|
2153
2374
|
schema: schema,
|
|
@@ -2205,11 +2426,11 @@ var nextActionAt = function nextActionAt(_ref12) {
|
|
|
2205
2426
|
metadata: channelChanged ? {} : prev.metadata
|
|
2206
2427
|
});
|
|
2207
2428
|
};
|
|
2208
|
-
var appendScopeItem = function appendScopeItem(
|
|
2429
|
+
var appendScopeItem = function appendScopeItem(_ref15) {
|
|
2209
2430
|
var _sc$requiresPhone;
|
|
2210
|
-
var schema =
|
|
2211
|
-
rule =
|
|
2212
|
-
value =
|
|
2431
|
+
var schema = _ref15.schema,
|
|
2432
|
+
rule = _ref15.rule,
|
|
2433
|
+
value = _ref15.value;
|
|
2213
2434
|
var sc = schema.scope || {};
|
|
2214
2435
|
var option = (sc.options || []).find(function (candidate) {
|
|
2215
2436
|
return optionValue(candidate) === value;
|
|
@@ -2226,12 +2447,12 @@ var appendScopeItem = function appendScopeItem(_ref13) {
|
|
|
2226
2447
|
phoneField: phoneFields[0].value
|
|
2227
2448
|
}) : option;
|
|
2228
2449
|
};
|
|
2229
|
-
var nextActionRecipientAt = function nextActionRecipientAt(
|
|
2450
|
+
var nextActionRecipientAt = function nextActionRecipientAt(_ref16) {
|
|
2230
2451
|
var _schema$actions1;
|
|
2231
|
-
var schema =
|
|
2232
|
-
rule =
|
|
2233
|
-
index =
|
|
2234
|
-
value =
|
|
2452
|
+
var schema = _ref16.schema,
|
|
2453
|
+
rule = _ref16.rule,
|
|
2454
|
+
index = _ref16.index,
|
|
2455
|
+
value = _ref16.value;
|
|
2235
2456
|
var prev = actionAt({
|
|
2236
2457
|
rule: rule,
|
|
2237
2458
|
index: index
|
|
@@ -2248,12 +2469,13 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2248
2469
|
}) : value
|
|
2249
2470
|
});
|
|
2250
2471
|
};
|
|
2251
|
-
var descriptorFor = function descriptorFor(
|
|
2472
|
+
var descriptorFor = function descriptorFor(_ref17) {
|
|
2252
2473
|
var _schema$actor2;
|
|
2253
|
-
var anchor =
|
|
2254
|
-
schema =
|
|
2255
|
-
rule =
|
|
2256
|
-
index =
|
|
2474
|
+
var anchor = _ref17.anchor,
|
|
2475
|
+
schema = _ref17.schema,
|
|
2476
|
+
rule = _ref17.rule,
|
|
2477
|
+
index = _ref17.index,
|
|
2478
|
+
stepKey = _ref17.stepKey;
|
|
2257
2479
|
switch (anchor) {
|
|
2258
2480
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2259
2481
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2384,13 +2606,18 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2384
2606
|
subtitle: isSwap ? i18next.t("neetoRules.builder.panes.actionSwapSubtitle") : i18next.t("neetoRules.builder.panes.actionAddSubtitle"),
|
|
2385
2607
|
cascade: true,
|
|
2386
2608
|
options: sourceOptions.map(function (option) {
|
|
2609
|
+
var _option$disabled;
|
|
2387
2610
|
var value = optionValue(option);
|
|
2388
2611
|
var meta = channelMetaFor(value);
|
|
2389
2612
|
return {
|
|
2390
2613
|
label: isSwap ? meta.channelLabel || option.label : option.label,
|
|
2391
2614
|
value: value,
|
|
2392
2615
|
category: option.category,
|
|
2393
|
-
|
|
2616
|
+
// Hosts mark unavailable actions with isDisabled; without carrying
|
|
2617
|
+
// the reason across, the picker disables them with no explanation.
|
|
2618
|
+
disabled: !!((_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : option.isDisabled),
|
|
2619
|
+
disabledReason: option.disabledReason,
|
|
2620
|
+
disabledPopover: option.disabledPopover,
|
|
2394
2621
|
icon: (isSwap ? meta.icon : option.icon) || option.icon
|
|
2395
2622
|
};
|
|
2396
2623
|
}),
|
|
@@ -2438,7 +2665,33 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2438
2665
|
selectedValues: [recipientOf({
|
|
2439
2666
|
schema: schema,
|
|
2440
2667
|
action: action
|
|
2441
|
-
})]
|
|
2668
|
+
})],
|
|
2669
|
+
// Confirming a recipient always offers Continue; whether that chains
|
|
2670
|
+
// onward or just closes is decided by continueTargetFor.
|
|
2671
|
+
cascade: true
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2675
|
+
{
|
|
2676
|
+
var _action = actionAt({
|
|
2677
|
+
rule: rule,
|
|
2678
|
+
index: index
|
|
2679
|
+
});
|
|
2680
|
+
var step = stepAt({
|
|
2681
|
+
schema: schema,
|
|
2682
|
+
rule: rule,
|
|
2683
|
+
index: index,
|
|
2684
|
+
stepKey: stepKey
|
|
2685
|
+
}) || {};
|
|
2686
|
+
return {
|
|
2687
|
+
title: step.title || i18next.t("neetoRules.builder.panes.stepTitle"),
|
|
2688
|
+
subtitle: step.subtitle,
|
|
2689
|
+
options: normalizeOptions(step.options),
|
|
2690
|
+
selectedValues: [stepValueOf({
|
|
2691
|
+
action: _action,
|
|
2692
|
+
step: step
|
|
2693
|
+
})],
|
|
2694
|
+
cascade: true
|
|
2442
2695
|
};
|
|
2443
2696
|
}
|
|
2444
2697
|
case BUILDER_ANCHORS.SCOPE:
|
|
@@ -2455,14 +2708,16 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2455
2708
|
subtitle: sc.paneSubtitle || i18next.t("neetoRules.builder.panes.scopeSubtitle"),
|
|
2456
2709
|
multi: true,
|
|
2457
2710
|
options: (sc.options || []).map(function (option) {
|
|
2711
|
+
var _option$disabled2;
|
|
2458
2712
|
var value = optionValue(option);
|
|
2459
2713
|
var blockedNoPhone = requiresPhone && option.hasPhoneField === false;
|
|
2460
2714
|
var isSelected = selected.includes(value);
|
|
2461
2715
|
return {
|
|
2462
2716
|
label: option.label,
|
|
2463
2717
|
value: value,
|
|
2464
|
-
disabled: (!!option.disabled || blockedNoPhone) && !isSelected,
|
|
2465
|
-
disabledReason: blockedNoPhone
|
|
2718
|
+
disabled: (!!((_option$disabled2 = option.disabled) !== null && _option$disabled2 !== void 0 ? _option$disabled2 : option.isDisabled) || blockedNoPhone) && !isSelected,
|
|
2719
|
+
disabledReason: blockedNoPhone ? sc.disabledReason : option.disabledReason,
|
|
2720
|
+
disabledPopover: option.disabledPopover,
|
|
2466
2721
|
disabledTooltip: blockedNoPhone && sc.disabledTooltip
|
|
2467
2722
|
};
|
|
2468
2723
|
}),
|
|
@@ -2508,13 +2763,14 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2508
2763
|
};
|
|
2509
2764
|
}
|
|
2510
2765
|
};
|
|
2511
|
-
var commitFor = function commitFor(
|
|
2512
|
-
var anchor =
|
|
2513
|
-
schema =
|
|
2514
|
-
rule =
|
|
2515
|
-
index =
|
|
2516
|
-
|
|
2517
|
-
|
|
2766
|
+
var commitFor = function commitFor(_ref18) {
|
|
2767
|
+
var anchor = _ref18.anchor,
|
|
2768
|
+
schema = _ref18.schema,
|
|
2769
|
+
rule = _ref18.rule,
|
|
2770
|
+
index = _ref18.index,
|
|
2771
|
+
stepKey = _ref18.stepKey,
|
|
2772
|
+
value = _ref18.value,
|
|
2773
|
+
helpers = _ref18.helpers;
|
|
2518
2774
|
var setTriggers = helpers.setTriggers,
|
|
2519
2775
|
setPerformer = helpers.setPerformer,
|
|
2520
2776
|
setConditionMode = helpers.setConditionMode,
|
|
@@ -2585,6 +2841,11 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2585
2841
|
}));
|
|
2586
2842
|
return "stay";
|
|
2587
2843
|
}
|
|
2844
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2845
|
+
{
|
|
2846
|
+
setFieldValue("".concat(fieldKeys.actions, ".value.").concat(index, ".metadata.").concat(stepKey), value);
|
|
2847
|
+
return "stay";
|
|
2848
|
+
}
|
|
2588
2849
|
case BUILDER_ANCHORS.SCOPE:
|
|
2589
2850
|
{
|
|
2590
2851
|
var key = fieldKeys.scope;
|
|
@@ -2614,12 +2875,14 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2614
2875
|
return "close";
|
|
2615
2876
|
}
|
|
2616
2877
|
};
|
|
2617
|
-
var continueTargetFor = function continueTargetFor(
|
|
2878
|
+
var continueTargetFor = function continueTargetFor(_ref19) {
|
|
2618
2879
|
var _schema$actor3;
|
|
2619
|
-
var anchor =
|
|
2620
|
-
schema =
|
|
2621
|
-
rule =
|
|
2622
|
-
index =
|
|
2880
|
+
var anchor = _ref19.anchor,
|
|
2881
|
+
schema = _ref19.schema,
|
|
2882
|
+
rule = _ref19.rule,
|
|
2883
|
+
index = _ref19.index,
|
|
2884
|
+
stepKey = _ref19.stepKey,
|
|
2885
|
+
configPending = _ref19.configPending;
|
|
2623
2886
|
switch (anchor) {
|
|
2624
2887
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2625
2888
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2675,38 +2938,77 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2675
2938
|
}
|
|
2676
2939
|
};
|
|
2677
2940
|
}
|
|
2678
|
-
|
|
2941
|
+
|
|
2942
|
+
// Reached here only because the action has no config yet — its name is
|
|
2943
|
+
// still unresolved — so the recipient pane owes us that step afterwards.
|
|
2944
|
+
if (channelMetaOf({
|
|
2679
2945
|
schema: schema,
|
|
2680
2946
|
action: action
|
|
2681
|
-
}).needsRecipient
|
|
2682
|
-
|
|
2947
|
+
}).needsRecipient) {
|
|
2948
|
+
return {
|
|
2949
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
2950
|
+
data: {
|
|
2951
|
+
index: index,
|
|
2952
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
2953
|
+
configPending: true
|
|
2954
|
+
}
|
|
2955
|
+
};
|
|
2956
|
+
}
|
|
2957
|
+
return stepTargetAfter({
|
|
2958
|
+
schema: schema,
|
|
2959
|
+
rule: rule,
|
|
2960
|
+
index: index
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2964
|
+
{
|
|
2965
|
+
// Only chain back to config when it was skipped on the way in; arriving
|
|
2966
|
+
// from the config pane or from the token means config is already done.
|
|
2967
|
+
var _action2 = actionAt({
|
|
2968
|
+
rule: rule,
|
|
2969
|
+
index: index
|
|
2970
|
+
});
|
|
2971
|
+
return configPending && actionHasConfig({
|
|
2972
|
+
schema: schema,
|
|
2973
|
+
action: _action2
|
|
2974
|
+
}) ? {
|
|
2975
|
+
type: BUILDER_PANEL_TYPES.ACTION_CONFIG,
|
|
2683
2976
|
data: {
|
|
2684
2977
|
index: index,
|
|
2685
|
-
anchor: BUILDER_ANCHORS.
|
|
2978
|
+
anchor: BUILDER_ANCHORS.ACTION_CONFIG
|
|
2686
2979
|
}
|
|
2687
|
-
} :
|
|
2980
|
+
} : stepTargetAfter({
|
|
2981
|
+
schema: schema,
|
|
2982
|
+
rule: rule,
|
|
2983
|
+
index: index
|
|
2984
|
+
});
|
|
2688
2985
|
}
|
|
2689
|
-
case BUILDER_ANCHORS.
|
|
2690
|
-
return
|
|
2986
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2987
|
+
return stepTargetAfter({
|
|
2988
|
+
schema: schema,
|
|
2989
|
+
rule: rule,
|
|
2990
|
+
index: index,
|
|
2991
|
+
stepKey: stepKey
|
|
2992
|
+
});
|
|
2691
2993
|
default:
|
|
2692
2994
|
return null;
|
|
2693
2995
|
}
|
|
2694
2996
|
};
|
|
2695
|
-
var replaceAt = function replaceAt(
|
|
2696
|
-
var list =
|
|
2697
|
-
index =
|
|
2698
|
-
item =
|
|
2997
|
+
var replaceAt = function replaceAt(_ref20) {
|
|
2998
|
+
var list = _ref20.list,
|
|
2999
|
+
index = _ref20.index,
|
|
3000
|
+
item = _ref20.item;
|
|
2699
3001
|
var next = _toConsumableArray(list);
|
|
2700
3002
|
// eslint-disable-next-line security/detect-object-injection
|
|
2701
3003
|
next[index] = item;
|
|
2702
3004
|
return next;
|
|
2703
3005
|
};
|
|
2704
|
-
var applyPreview = function applyPreview(
|
|
2705
|
-
var rule =
|
|
2706
|
-
schema =
|
|
2707
|
-
anchor =
|
|
2708
|
-
index =
|
|
2709
|
-
value =
|
|
3006
|
+
var applyPreview = function applyPreview(_ref21) {
|
|
3007
|
+
var rule = _ref21.rule,
|
|
3008
|
+
schema = _ref21.schema,
|
|
3009
|
+
anchor = _ref21.anchor,
|
|
3010
|
+
index = _ref21.index,
|
|
3011
|
+
value = _ref21.value;
|
|
2710
3012
|
switch (anchor) {
|
|
2711
3013
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2712
3014
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2803,7 +3105,7 @@ var applyPreview = function applyPreview(_ref19) {
|
|
|
2803
3105
|
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; }
|
|
2804
3106
|
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; }
|
|
2805
3107
|
var Canvas = function Canvas(_ref) {
|
|
2806
|
-
var _schema$scope, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
3108
|
+
var _schema$actor2, _ref6, _actorOptions$0$value, _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2807
3109
|
var schema = _ref.schema;
|
|
2808
3110
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2809
3111
|
t = _useTranslation.t;
|
|
@@ -2858,7 +3160,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
2858
3160
|
react.useEffect(function () {
|
|
2859
3161
|
if (submitCount <= lastSubmitCount.current) return undefined;
|
|
2860
3162
|
lastSubmitCount.current = submitCount;
|
|
2861
|
-
if (ramda.isEmpty(flatErrors) && isRuleComplete(
|
|
3163
|
+
if (ramda.isEmpty(flatErrors) && isRuleComplete({
|
|
3164
|
+
rule: rule,
|
|
3165
|
+
schema: schema
|
|
3166
|
+
}) && ramda.isEmpty(invalidScopeIndexes({
|
|
2862
3167
|
rule: rule,
|
|
2863
3168
|
schema: schema
|
|
2864
3169
|
})) && ramda.isEmpty(invalidScopePhoneFieldIndexes({
|
|
@@ -2887,33 +3192,25 @@ var Canvas = function Canvas(_ref) {
|
|
|
2887
3192
|
});
|
|
2888
3193
|
};
|
|
2889
3194
|
var matchesInvalid = function matchesInvalid(_ref4) {
|
|
2890
|
-
var _schema$actions, _schema$actions$actio, _schema$actions2, _schema$actions2$rend, _schema$actions3, _schema$actions3$rend, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions5$opti, _schema$actions6, _schema$actions7;
|
|
2891
3195
|
var type = _ref4.type,
|
|
2892
|
-
index = _ref4.index
|
|
3196
|
+
index = _ref4.index,
|
|
3197
|
+
stepKey = _ref4.stepKey;
|
|
2893
3198
|
var conditionMeta = "".concat(fieldKeys.conditions, ".value.").concat(index, ".metadata");
|
|
2894
3199
|
var actionMeta = "".concat(fieldKeys.actions, ".value.").concat(index, ".metadata");
|
|
2895
3200
|
// eslint-disable-next-line security/detect-object-injection
|
|
2896
3201
|
var actionItem = rule.actions[index] || {};
|
|
2897
|
-
var
|
|
2898
|
-
|
|
2899
|
-
channel: channel,
|
|
2900
|
-
name: actionMeta,
|
|
2901
|
-
action: actionItem
|
|
2902
|
-
}));
|
|
2903
|
-
var hasRecipientField = !!((_schema$actions3 = schema.actions) !== null && _schema$actions3 !== void 0 && (_schema$actions3$rend = _schema$actions3.renderRecipientField) !== null && _schema$actions3$rend !== void 0 && _schema$actions3$rend.call(_schema$actions3, {
|
|
2904
|
-
channel: channel,
|
|
2905
|
-
recipient: actionItem.recipient,
|
|
2906
|
-
name: actionMeta,
|
|
3202
|
+
var steps = actionStepsOf({
|
|
3203
|
+
schema: schema,
|
|
2907
3204
|
action: actionItem
|
|
2908
|
-
}));
|
|
2909
|
-
var flatOption = ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForName) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, actionItem.name)) || ((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 || (_schema$actions5$opti = _schema$actions5.optionForChannel) === null || _schema$actions5$opti === void 0 ? void 0 : _schema$actions5$opti.call(_schema$actions5, channel));
|
|
2910
|
-
var recipientConfig = [].concat(_toConsumableArray((((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
|
|
2911
|
-
return option.recipients || [];
|
|
2912
|
-
})), _toConsumableArray(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [])).find(function (item) {
|
|
2913
|
-
var _item$value;
|
|
2914
|
-
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === actionItem.recipient;
|
|
2915
3205
|
});
|
|
2916
|
-
var
|
|
3206
|
+
var stepKeys = steps.map(function (step) {
|
|
3207
|
+
return step.key;
|
|
3208
|
+
});
|
|
3209
|
+
var recipientFields = recipientOwnedFields({
|
|
3210
|
+
schema: schema,
|
|
3211
|
+
action: actionItem,
|
|
3212
|
+
name: actionMeta
|
|
3213
|
+
});
|
|
2917
3214
|
switch (type) {
|
|
2918
3215
|
case BUILDER_ANCHORS.TRIGGER_ACTOR:
|
|
2919
3216
|
{
|
|
@@ -2944,8 +3241,20 @@ var Canvas = function Canvas(_ref) {
|
|
|
2944
3241
|
case BUILDER_ANCHORS.ACTION_CONFIG:
|
|
2945
3242
|
return hasErrorAt({
|
|
2946
3243
|
prefix: actionMeta,
|
|
2947
|
-
exclude: recipientFields
|
|
3244
|
+
exclude: [].concat(_toConsumableArray(recipientFields), _toConsumableArray(stepKeys))
|
|
2948
3245
|
});
|
|
3246
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
3247
|
+
{
|
|
3248
|
+
var step = steps.find(function (item) {
|
|
3249
|
+
return item.key === stepKey;
|
|
3250
|
+
});
|
|
3251
|
+
return hasErrorAt({
|
|
3252
|
+
prefix: "".concat(actionMeta, ".").concat(stepKey)
|
|
3253
|
+
}) || !!(step !== null && step !== void 0 && step.required) && !stepValueOf({
|
|
3254
|
+
action: actionItem,
|
|
3255
|
+
step: step
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
2949
3258
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2950
3259
|
return hasErrorAt({
|
|
2951
3260
|
prefix: "".concat(fieldKeys.actions, ".value.").concat(index, ".name")
|
|
@@ -3022,7 +3331,15 @@ var Canvas = function Canvas(_ref) {
|
|
|
3022
3331
|
});
|
|
3023
3332
|
setDelay(null);
|
|
3024
3333
|
};
|
|
3025
|
-
|
|
3334
|
+
|
|
3335
|
+
// An actor with a single choice is not a choice; leaving it unset only makes
|
|
3336
|
+
// the user open a one-option pane to say the obvious.
|
|
3337
|
+
var actorOptions = schema !== null && schema !== void 0 && (_schema$actor2 = schema.actor) !== null && _schema$actor2 !== void 0 && _schema$actor2.enabled ? schema.actor.options || [] : [];
|
|
3338
|
+
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;
|
|
3339
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
3340
|
+
rule: rule,
|
|
3341
|
+
schema: schema
|
|
3342
|
+
});
|
|
3026
3343
|
var hasAction = rule.actions.some(function (action) {
|
|
3027
3344
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
3028
3345
|
});
|
|
@@ -3041,11 +3358,16 @@ var Canvas = function Canvas(_ref) {
|
|
|
3041
3358
|
rule: rule
|
|
3042
3359
|
});
|
|
3043
3360
|
var canAddCondition = neetoCist.isNotEmpty(conditionFields);
|
|
3361
|
+
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;
|
|
3044
3362
|
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) || [];
|
|
3045
3363
|
var hasLeadTimeTrigger = rule.triggers.some(function (trigger) {
|
|
3046
3364
|
return leadTimeAppliesTo.includes(trigger.name);
|
|
3047
3365
|
});
|
|
3048
3366
|
var isDelayEnabled = (schema === null || schema === void 0 || (_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.enabled) && !hasLeadTimeTrigger;
|
|
3367
|
+
react.useEffect(function () {
|
|
3368
|
+
if (soleActorOption && !rule.performer) setPerformer(soleActorOption);
|
|
3369
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3370
|
+
}, [soleActorOption, rule.performer]);
|
|
3049
3371
|
react.useEffect(function () {
|
|
3050
3372
|
if (hasLeadTimeTrigger && rule.delay) setDelay(null);
|
|
3051
3373
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3062,10 +3384,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
3062
3384
|
});
|
|
3063
3385
|
};
|
|
3064
3386
|
var handleClearTrigger = function handleClearTrigger() {
|
|
3065
|
-
var _schema$
|
|
3387
|
+
var _schema$actor3;
|
|
3066
3388
|
clearTriggers();
|
|
3067
3389
|
// Hosts without an actor pane can never re-set it, and null fails its validation.
|
|
3068
|
-
if ((_schema$
|
|
3390
|
+
if ((_schema$actor3 = schema.actor) !== null && _schema$actor3 !== void 0 && _schema$actor3.enabled) setPerformer(soleActorOption);
|
|
3069
3391
|
clearConditions();
|
|
3070
3392
|
setDelay(null);
|
|
3071
3393
|
clearActions();
|
|
@@ -3093,7 +3415,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3093
3415
|
className: "neeto-rules-builder nrb-atoms",
|
|
3094
3416
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3095
3417
|
className: "mb-canvas neeto-rules-main-card",
|
|
3096
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(WhenBlock, {
|
|
3418
|
+
children: [renderSlot("beforeWhen"), /*#__PURE__*/jsxRuntime.jsx(WhenBlock, {
|
|
3097
3419
|
isActive: isActive,
|
|
3098
3420
|
isInvalid: isInvalid,
|
|
3099
3421
|
schema: schema,
|
|
@@ -3111,11 +3433,11 @@ var Canvas = function Canvas(_ref) {
|
|
|
3111
3433
|
schema: schema,
|
|
3112
3434
|
key: (_condition$id = condition.id) !== null && _condition$id !== void 0 ? _condition$id : index,
|
|
3113
3435
|
rule: displayRule,
|
|
3114
|
-
onRemove: function onRemove() {
|
|
3115
|
-
return handleRemoveCondition(index);
|
|
3116
|
-
},
|
|
3117
3436
|
onToken: openPane,
|
|
3118
|
-
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition
|
|
3437
|
+
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition,
|
|
3438
|
+
onRemove: canRemoveCondition && function () {
|
|
3439
|
+
return handleRemoveCondition(index);
|
|
3440
|
+
}
|
|
3119
3441
|
});
|
|
3120
3442
|
}), renderSlot("afterConditions"), /*#__PURE__*/jsxRuntime.jsx(Connector, {
|
|
3121
3443
|
active: isTriggerSet
|
|
@@ -3187,6 +3509,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3187
3509
|
|
|
3188
3510
|
var ACTION_CONFIG_TYPES = {
|
|
3189
3511
|
emailChannel: "emailChannel",
|
|
3512
|
+
sendToApi: "sendToApi",
|
|
3190
3513
|
multiSelect: "multiSelect",
|
|
3191
3514
|
dropdown: "dropdown",
|
|
3192
3515
|
note: "note",
|
|
@@ -3213,7 +3536,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3213
3536
|
option = _ref.option,
|
|
3214
3537
|
action = _ref.action,
|
|
3215
3538
|
_ref$searchTerm = _ref.searchTerm,
|
|
3216
|
-
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm
|
|
3539
|
+
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm,
|
|
3540
|
+
_ref$hasRecipientFiel = _ref.hasRecipientField,
|
|
3541
|
+
hasRecipientField = _ref$hasRecipientFiel === void 0 ? false : _ref$hasRecipientFiel;
|
|
3217
3542
|
var _useTranslation = reactI18next.useTranslation(),
|
|
3218
3543
|
t = _useTranslation.t;
|
|
3219
3544
|
var _useFormikContext = formik.useFormikContext(),
|
|
@@ -3255,19 +3580,42 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3255
3580
|
"data-testid": "pane-no-matches",
|
|
3256
3581
|
children: t("neetoRules.builder.noMatches")
|
|
3257
3582
|
});
|
|
3583
|
+
if (type === ACTION_CONFIG_TYPES.sendToApi) {
|
|
3584
|
+
return /*#__PURE__*/jsxRuntime.jsx(index.ApiFields, {
|
|
3585
|
+
name: name,
|
|
3586
|
+
selectedField: option
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3258
3589
|
if (type === ACTION_CONFIG_TYPES.emailChannel) {
|
|
3259
|
-
var _getIn, _action$metadata;
|
|
3590
|
+
var _getIn, _getIn2, _action$metadata;
|
|
3260
3591
|
var subjectPath = "".concat(name, ".subject");
|
|
3261
3592
|
var bodyPath = "".concat(name, ".body");
|
|
3593
|
+
// Hosts whose email action picks its recipient from a list keep that
|
|
3594
|
+
// choice in the same pane as the message.
|
|
3595
|
+
var hasRecipientList = neetoCist.isNotEmpty(options) && !hasRecipientField;
|
|
3262
3596
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3263
3597
|
className: "flex flex-col gap-4",
|
|
3264
|
-
children: [
|
|
3598
|
+
children: [hasRecipientList && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Select, {
|
|
3599
|
+
options: options,
|
|
3600
|
+
required: true,
|
|
3601
|
+
error: fieldError(valuePath),
|
|
3602
|
+
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3603
|
+
size: "large",
|
|
3604
|
+
value: (_getIn = formik.getIn(values, valuePath)) !== null && _getIn !== void 0 ? _getIn : undefined,
|
|
3605
|
+
label: (option === null || option === void 0 ? void 0 : option.recipientLabel) || t("neetoRules.builder.config.recipient"),
|
|
3606
|
+
onBlur: function onBlur() {
|
|
3607
|
+
return setFieldTouched(valuePath, true);
|
|
3608
|
+
},
|
|
3609
|
+
onChange: function onChange(value) {
|
|
3610
|
+
return setFieldValue(valuePath, value);
|
|
3611
|
+
}
|
|
3612
|
+
}), !(option !== null && option !== void 0 && option.hideSubject) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
3265
3613
|
required: true,
|
|
3266
3614
|
error: fieldError(subjectPath),
|
|
3267
3615
|
label: t("neetoRules.builder.config.subject"),
|
|
3268
3616
|
placeholder: t("neetoRules.builder.config.subjectPlaceholder"),
|
|
3269
3617
|
size: "large",
|
|
3270
|
-
value: (
|
|
3618
|
+
value: (_getIn2 = formik.getIn(values, subjectPath)) !== null && _getIn2 !== void 0 ? _getIn2 : "",
|
|
3271
3619
|
onBlur: function onBlur() {
|
|
3272
3620
|
return setFieldTouched(subjectPath, true);
|
|
3273
3621
|
},
|
|
@@ -3319,9 +3667,6 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3319
3667
|
error: fieldError(valuePath),
|
|
3320
3668
|
orientation: "vertical",
|
|
3321
3669
|
value: String(_current !== null && _current !== void 0 ? _current : ""),
|
|
3322
|
-
onBlur: function onBlur() {
|
|
3323
|
-
return setFieldTouched(valuePath, true);
|
|
3324
|
-
},
|
|
3325
3670
|
onValueChange: function onValueChange(value) {
|
|
3326
3671
|
var picked = options.find(function (item) {
|
|
3327
3672
|
return String(item.value) === value;
|
|
@@ -3359,14 +3704,14 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3359
3704
|
});
|
|
3360
3705
|
}
|
|
3361
3706
|
if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
|
|
3362
|
-
var
|
|
3707
|
+
var _getIn3, _getIn4;
|
|
3363
3708
|
return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
3364
3709
|
required: true,
|
|
3365
3710
|
error: fieldError(valuePath),
|
|
3366
3711
|
label: t("neetoRules.builder.config.value"),
|
|
3367
3712
|
size: "large",
|
|
3368
3713
|
type: "number",
|
|
3369
|
-
value: (
|
|
3714
|
+
value: (_getIn3 = formik.getIn(values, valuePath)) !== null && _getIn3 !== void 0 ? _getIn3 : "",
|
|
3370
3715
|
onBlur: function onBlur() {
|
|
3371
3716
|
return setFieldTouched(valuePath, true);
|
|
3372
3717
|
},
|
|
@@ -3379,7 +3724,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3379
3724
|
label: t("neetoRules.builder.config.message"),
|
|
3380
3725
|
rows: 5,
|
|
3381
3726
|
size: "large",
|
|
3382
|
-
value: (
|
|
3727
|
+
value: (_getIn4 = formik.getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
|
|
3383
3728
|
onBlur: function onBlur() {
|
|
3384
3729
|
return setFieldTouched(valuePath, true);
|
|
3385
3730
|
},
|
|
@@ -3389,7 +3734,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3389
3734
|
});
|
|
3390
3735
|
}
|
|
3391
3736
|
if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
|
|
3392
|
-
var
|
|
3737
|
+
var _getIn5;
|
|
3393
3738
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3394
3739
|
className: "flex flex-col gap-2",
|
|
3395
3740
|
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
@@ -3398,7 +3743,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3398
3743
|
label: t("neetoRules.builder.config.value"),
|
|
3399
3744
|
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3400
3745
|
size: "large",
|
|
3401
|
-
value: (
|
|
3746
|
+
value: (_getIn5 = formik.getIn(values, valuePath)) !== null && _getIn5 !== void 0 ? _getIn5 : "",
|
|
3402
3747
|
onBlur: function onBlur() {
|
|
3403
3748
|
return setFieldTouched(valuePath, true);
|
|
3404
3749
|
},
|
|
@@ -3509,7 +3854,7 @@ var usePaneValidation = function usePaneValidation(prefix) {
|
|
|
3509
3854
|
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 }; })(); }
|
|
3510
3855
|
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); }
|
|
3511
3856
|
var ConfigPane = function ConfigPane(_ref) {
|
|
3512
|
-
var _schema$actions, _schema$actions$optio, _schema$actions2, _schema$actions2$opti, _schema$actions3, _schema$
|
|
3857
|
+
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;
|
|
3513
3858
|
var schema = _ref.schema,
|
|
3514
3859
|
index$1 = _ref.index;
|
|
3515
3860
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -3541,17 +3886,28 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3541
3886
|
mediumLabel = _actionParts.mediumLabel,
|
|
3542
3887
|
needsRecipient = _actionParts.needsRecipient,
|
|
3543
3888
|
configTitle = _actionParts.configTitle,
|
|
3544
|
-
configSubtitle = _actionParts.configSubtitle
|
|
3889
|
+
configSubtitle = _actionParts.configSubtitle,
|
|
3890
|
+
steps = _actionParts.steps;
|
|
3545
3891
|
var name = "".concat(base, ".metadata");
|
|
3546
3892
|
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;
|
|
3893
|
+
|
|
3894
|
+
// When the chosen recipient declares its own field, the recipient pane
|
|
3895
|
+
// renders it; showing the same picker here too would just duplicate it.
|
|
3896
|
+
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;
|
|
3897
|
+
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) {
|
|
3898
|
+
return o.recipients || [];
|
|
3899
|
+
})).find(function (item) {
|
|
3900
|
+
var _item$value;
|
|
3901
|
+
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipientValue;
|
|
3902
|
+
})) !== null && _concat$find !== void 0 && _concat$find.field);
|
|
3547
3903
|
var isSms = SMS_TYPES.includes(flatOption === null || flatOption === void 0 ? void 0 : flatOption.type);
|
|
3548
3904
|
var disabledReason = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.isDisabled) && flatOption.disabledReason;
|
|
3549
|
-
var hostRenderConfig = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.renderConfig) || (flatOption === null || flatOption === void 0 ? void 0 : flatOption.component) || ((_schema$
|
|
3905
|
+
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);
|
|
3550
3906
|
var showSearch = normalizeOptions(flatOption === null || flatOption === void 0 ? void 0 : flatOption.dropdownOptions).length >= PANE_SEARCH_THRESHOLD;
|
|
3551
3907
|
var shouldAdvanceToRecipient = !!needsRecipient;
|
|
3552
3908
|
var _usePaneValidation = usePaneValidation(name),
|
|
3553
3909
|
validate = _usePaneValidation.validate;
|
|
3554
|
-
var channelRepName = (_schema$
|
|
3910
|
+
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;
|
|
3555
3911
|
var unnamedOnOpen = react.useRef(!action.name);
|
|
3556
3912
|
react.useEffect(function () {
|
|
3557
3913
|
if (!unnamedOnOpen.current || !channelRepName) return undefined;
|
|
@@ -3585,11 +3941,21 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3585
3941
|
}) || (option === null || option === void 0 ? void 0 : option.label) || t("neetoRules.builder.setUpAction");
|
|
3586
3942
|
var handleContinue = /*#__PURE__*/function () {
|
|
3587
3943
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
3944
|
+
var owned, next;
|
|
3588
3945
|
return _regenerator().w(function (_context) {
|
|
3589
3946
|
while (1) switch (_context.n) {
|
|
3590
3947
|
case 0:
|
|
3948
|
+
// A pane only answers for what it renders: the recipient pane owns its
|
|
3949
|
+
// storage fields and each step owns its key, so neither blocks Continue.
|
|
3950
|
+
owned = [].concat(_toConsumableArray(recipientOwnedFields({
|
|
3951
|
+
schema: schema,
|
|
3952
|
+
action: action,
|
|
3953
|
+
name: name
|
|
3954
|
+
})), _toConsumableArray(steps.map(function (step) {
|
|
3955
|
+
return step.key;
|
|
3956
|
+
})));
|
|
3591
3957
|
_context.n = 1;
|
|
3592
|
-
return validate(
|
|
3958
|
+
return validate(owned);
|
|
3593
3959
|
case 1:
|
|
3594
3960
|
if (_context.v) {
|
|
3595
3961
|
_context.n = 2;
|
|
@@ -3597,17 +3963,18 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3597
3963
|
}
|
|
3598
3964
|
return _context.a(2);
|
|
3599
3965
|
case 2:
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
}
|
|
3966
|
+
next = shouldAdvanceToRecipient ? {
|
|
3967
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
3968
|
+
data: {
|
|
3969
|
+
index: index$1,
|
|
3970
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
3971
|
+
}
|
|
3972
|
+
} : stepTargetAfter({
|
|
3973
|
+
schema: schema,
|
|
3974
|
+
rule: rule,
|
|
3975
|
+
index: index$1
|
|
3976
|
+
});
|
|
3977
|
+
if (next) openType(next);else closePane();
|
|
3611
3978
|
case 3:
|
|
3612
3979
|
return _context.a(2);
|
|
3613
3980
|
}
|
|
@@ -3670,6 +4037,7 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3670
4037
|
searchTerm: searchTerm
|
|
3671
4038
|
})) !== null && _hostRenderConfig !== void 0 ? _hostRenderConfig : /*#__PURE__*/jsxRuntime.jsx(ActionConfigFields, {
|
|
3672
4039
|
action: action,
|
|
4040
|
+
hasRecipientField: hasRecipientField,
|
|
3673
4041
|
name: name,
|
|
3674
4042
|
searchTerm: searchTerm,
|
|
3675
4043
|
option: flatOption
|
|
@@ -4007,8 +4375,11 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4007
4375
|
var schema = _ref.schema,
|
|
4008
4376
|
anchor = _ref.anchor,
|
|
4009
4377
|
index$1 = _ref.index,
|
|
4378
|
+
stepKey = _ref.stepKey,
|
|
4010
4379
|
_ref$belowContent = _ref.belowContent,
|
|
4011
|
-
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent
|
|
4380
|
+
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent,
|
|
4381
|
+
_ref$configPending = _ref.configPending,
|
|
4382
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
4012
4383
|
var _useTranslation = reactI18next.useTranslation(),
|
|
4013
4384
|
t = _useTranslation.t;
|
|
4014
4385
|
var _useFormikContext = formik.useFormikContext(),
|
|
@@ -4049,9 +4420,10 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4049
4420
|
anchor: anchor,
|
|
4050
4421
|
schema: schema,
|
|
4051
4422
|
rule: rule,
|
|
4052
|
-
index: index$1
|
|
4423
|
+
index: index$1,
|
|
4424
|
+
stepKey: stepKey
|
|
4053
4425
|
});
|
|
4054
|
-
}, [anchor, schema, rule, index$1]),
|
|
4426
|
+
}, [anchor, schema, rule, index$1, stepKey]),
|
|
4055
4427
|
title = _useMemo.title,
|
|
4056
4428
|
subtitle = _useMemo.subtitle,
|
|
4057
4429
|
multi = _useMemo.multi,
|
|
@@ -4086,6 +4458,7 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4086
4458
|
schema: schema,
|
|
4087
4459
|
rule: rule,
|
|
4088
4460
|
index: index$1,
|
|
4461
|
+
stepKey: stepKey,
|
|
4089
4462
|
value: value,
|
|
4090
4463
|
helpers: helpers
|
|
4091
4464
|
});
|
|
@@ -4114,7 +4487,9 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4114
4487
|
anchor: anchor,
|
|
4115
4488
|
schema: schema,
|
|
4116
4489
|
rule: rule,
|
|
4117
|
-
index: index$1
|
|
4490
|
+
index: index$1,
|
|
4491
|
+
stepKey: stepKey,
|
|
4492
|
+
configPending: configPending
|
|
4118
4493
|
});
|
|
4119
4494
|
if (target) openType({
|
|
4120
4495
|
type: target.type,
|
|
@@ -4128,21 +4503,53 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4128
4503
|
});
|
|
4129
4504
|
var optionLabel = function optionLabel(option) {
|
|
4130
4505
|
var Icon = option.icon;
|
|
4131
|
-
|
|
4506
|
+
// Short text sits inline as a pill; anything needing more room is a
|
|
4507
|
+
// standard popover behind an info icon.
|
|
4508
|
+
var reason = typeof option.disabledReason === "function" ? option.disabledReason() : option.disabledReason;
|
|
4509
|
+
var isTextReason = typeof reason === "string";
|
|
4510
|
+
// Only a node can be rendered as popover content; a host handing back a
|
|
4511
|
+
// plain object would otherwise crash the pane.
|
|
4512
|
+
var isNodeReason = /*#__PURE__*/react.isValidElement(reason) || Array.isArray(reason);
|
|
4513
|
+
var popover = option.disabledPopover || (isNodeReason ? {
|
|
4514
|
+
description: reason
|
|
4515
|
+
} : null);
|
|
4516
|
+
if (!Icon && !isTextReason && !popover) return option.label;
|
|
4132
4517
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
4133
4518
|
className: "mb-pane-option",
|
|
4134
4519
|
children: [Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
4135
4520
|
size: 20
|
|
4136
|
-
}), option.label,
|
|
4521
|
+
}), option.label, popover && /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Popover, {
|
|
4522
|
+
position: "top",
|
|
4523
|
+
trigger: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4524
|
+
className: "mb-pane-info",
|
|
4525
|
+
onClick: function onClick(event) {
|
|
4526
|
+
return event.preventDefault();
|
|
4527
|
+
},
|
|
4528
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Info, {
|
|
4529
|
+
size: 14
|
|
4530
|
+
})
|
|
4531
|
+
}),
|
|
4532
|
+
children: [popover.title && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Popover.Title, {
|
|
4533
|
+
children: popover.title
|
|
4534
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
4535
|
+
color: "muted",
|
|
4536
|
+
variant: "body2",
|
|
4537
|
+
children: popover.description
|
|
4538
|
+
}), popover.helpLinkProps && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, _objectSpread$2(_objectSpread$2({}, popover.helpLinkProps), {}, {
|
|
4539
|
+
className: "h-auto self-start p-0",
|
|
4540
|
+
size: "sm",
|
|
4541
|
+
variant: "link"
|
|
4542
|
+
}))]
|
|
4543
|
+
}), !popover && reason && isTextReason && (option.disabledTooltip ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
|
|
4137
4544
|
content: option.disabledTooltip,
|
|
4138
4545
|
position: "top",
|
|
4139
4546
|
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4140
4547
|
className: "mb-pane-warn",
|
|
4141
|
-
children:
|
|
4548
|
+
children: reason
|
|
4142
4549
|
})
|
|
4143
4550
|
}) : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4144
4551
|
className: "mb-pane-warn",
|
|
4145
|
-
children:
|
|
4552
|
+
children: reason
|
|
4146
4553
|
}))]
|
|
4147
4554
|
});
|
|
4148
4555
|
};
|
|
@@ -4313,7 +4720,9 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4313
4720
|
var RecipientPane = function RecipientPane(_ref) {
|
|
4314
4721
|
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;
|
|
4315
4722
|
var schema = _ref.schema,
|
|
4316
|
-
index$1 = _ref.index
|
|
4723
|
+
index$1 = _ref.index,
|
|
4724
|
+
_ref$configPending = _ref.configPending,
|
|
4725
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
4317
4726
|
var _useTranslation = reactI18next.useTranslation(),
|
|
4318
4727
|
t = _useTranslation.t;
|
|
4319
4728
|
var _useRuleModel = useRuleModel(schema),
|
|
@@ -4388,6 +4797,7 @@ var RecipientPane = function RecipientPane(_ref) {
|
|
|
4388
4797
|
if (!editor) {
|
|
4389
4798
|
return /*#__PURE__*/jsxRuntime.jsx(OptionsPane, {
|
|
4390
4799
|
belowContent: belowContent,
|
|
4800
|
+
configPending: configPending,
|
|
4391
4801
|
index: index$1,
|
|
4392
4802
|
schema: schema,
|
|
4393
4803
|
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
@@ -4513,9 +4923,6 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4513
4923
|
error: fieldError(valuePath),
|
|
4514
4924
|
orientation: "vertical",
|
|
4515
4925
|
value: String(_current2 !== null && _current2 !== void 0 ? _current2 : ""),
|
|
4516
|
-
onBlur: function onBlur() {
|
|
4517
|
-
return setFieldTouched(valuePath, true);
|
|
4518
|
-
},
|
|
4519
4926
|
onValueChange: function onValueChange(value) {
|
|
4520
4927
|
return setFieldValue(valuePath, value);
|
|
4521
4928
|
},
|
|
@@ -4655,9 +5062,11 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
|
|
|
4655
5062
|
component: ValuePane
|
|
4656
5063
|
}), BUILDER_PANEL_TYPES.ACTION_CONFIG, {
|
|
4657
5064
|
component: ConfigPane
|
|
4658
|
-
}), BUILDER_PANEL_TYPES.
|
|
5065
|
+
}), BUILDER_PANEL_TYPES.ACTION_STEP, {
|
|
5066
|
+
component: OptionsPane
|
|
5067
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.DELAY, {
|
|
4659
5068
|
component: DelayPane
|
|
4660
|
-
}),
|
|
5069
|
+
}), BUILDER_PANEL_TYPES.LEAD_TIME, {
|
|
4661
5070
|
component: LeadTimePane
|
|
4662
5071
|
}), BUILDER_PANEL_TYPES.NAME, {
|
|
4663
5072
|
component: NamePane
|
|
@@ -4740,7 +5149,10 @@ var Form = function Form(_ref) {
|
|
|
4740
5149
|
values: values,
|
|
4741
5150
|
schema: schema
|
|
4742
5151
|
});
|
|
4743
|
-
if (!isRuleComplete(
|
|
5152
|
+
if (!isRuleComplete({
|
|
5153
|
+
rule: rule,
|
|
5154
|
+
schema: schema
|
|
5155
|
+
}) || invalidScopeIndexes({
|
|
4744
5156
|
rule: rule,
|
|
4745
5157
|
schema: schema
|
|
4746
5158
|
}).length || invalidScopePhoneFieldIndexes({
|