@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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
3
|
-
import { f as flatten, S as SHORTCUTS } from '../keyboardShortcuts-
|
|
3
|
+
import { f as flatten, S as SHORTCUTS } from '../keyboardShortcuts-DwgF8Mcu.js';
|
|
4
4
|
import { useShallow } from 'zustand/shallow';
|
|
5
|
-
import { useState, useRef, useEffect, createElement, Fragment as Fragment$1, useCallback, useMemo } from 'react';
|
|
6
|
-
import { Button, Input, Checkbox, Typography, RadioGroup, Textarea, DatePicker,
|
|
7
|
-
import { Input as Input$1, Select, ActionBlock } from '@bigbinary/neeto-atoms/formik';
|
|
5
|
+
import { useState, useRef, useEffect, createElement, Fragment as Fragment$1, useCallback, useMemo, isValidElement } from 'react';
|
|
6
|
+
import { Button, Select, Input, Checkbox, Typography, RadioGroup, Textarea, DatePicker, Popover, Tooltip, MultiEmailInput, Spinner } from '@bigbinary/neeto-atoms';
|
|
7
|
+
import { Input as Input$1, Select as Select$1, ActionBlock } from '@bigbinary/neeto-atoms/formik';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { useFormikContext, getIn, useField, Formik, Form as Form$1 } from 'formik';
|
|
10
10
|
import { isNotEmpty, toLabelAndValue, removeBy, isNot, noop } from '@bigbinary/neeto-cist';
|
|
11
11
|
import Container from '@bigbinary/neeto-molecules/v2/Container';
|
|
12
12
|
import Header from '@bigbinary/neeto-molecules/v2/Header';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
-
import { E as EditorAction, L as ListField, o as Panel,
|
|
14
|
+
import { r as ApiFields, E as EditorAction, L as ListField, o as Panel, s as ErrorCallout, t as SmsFields, M as MIN_DELAY_VALUE, v as MAX_DELAY_VALUE, w as PhoneNumberField, l as formatData, u as usePollRuleName, T as TouchErrors, n as ScrollToErrorField, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE, m as buildPayload } from '../index-Br0dDuGK.js';
|
|
15
15
|
import { u as useCustomDataStore } from '../useCustomDataStore-CEbhXugO.js';
|
|
16
16
|
import { u as useUtilityStore } from '../useUtilityStore-BVCulMEC.js';
|
|
17
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -30,6 +30,7 @@ import { dayjs } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
|
30
30
|
import { D as DATE_FORMAT } from '../utils-DeqHhpwQ.js';
|
|
31
31
|
import Up from '@bigbinary/neeto-icons/Up';
|
|
32
32
|
import Down from '@bigbinary/neeto-icons/Down';
|
|
33
|
+
import Info from '@bigbinary/neeto-icons/Info';
|
|
33
34
|
import '@babel/runtime/helpers/typeof';
|
|
34
35
|
import '../useAutomationRulesApi-C9I3wUZ8.js';
|
|
35
36
|
import '@tanstack/react-query';
|
|
@@ -158,6 +159,7 @@ var BUILDER_PANEL_TYPES = {
|
|
|
158
159
|
CONDITION_VALUE: "builder-condition-value",
|
|
159
160
|
ACTION_CHANNEL: "builder-action-channel",
|
|
160
161
|
ACTION_CONFIG: "builder-action-config",
|
|
162
|
+
ACTION_STEP: "builder-action-step",
|
|
161
163
|
RECIPIENT: "builder-recipient",
|
|
162
164
|
DELAY: "builder-delay",
|
|
163
165
|
LEAD_TIME: "builder-lead-time",
|
|
@@ -178,15 +180,16 @@ var BUILDER_ANCHORS = {
|
|
|
178
180
|
ACTION_CHANNEL: "action-channel",
|
|
179
181
|
ACTION_CONFIG: "action-config",
|
|
180
182
|
ACTION_RECIPIENT: "action-recipient",
|
|
183
|
+
ACTION_STEP: "action-step",
|
|
181
184
|
RULE_DELAY: "rule-delay",
|
|
182
185
|
META_NAME: "meta-name",
|
|
183
186
|
SCOPE: "scope",
|
|
184
187
|
SCOPE_PHONE_FIELD: "scope-phone-field"
|
|
185
188
|
};
|
|
186
|
-
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));
|
|
189
|
+
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));
|
|
187
190
|
var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
|
|
188
191
|
var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
|
|
189
|
-
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
|
|
192
|
+
var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_ANCHORS.ACTION_STEP];
|
|
190
193
|
var PANE_SEARCH_THRESHOLD = 8;
|
|
191
194
|
var CONFIG_FOCUSABLE_SELECTOR = 'input:not([type="radio"]):not([type="checkbox"]), textarea, [contenteditable="true"]';
|
|
192
195
|
var SMS_TYPES = ["sms", "smsToNumbers"];
|
|
@@ -247,7 +250,7 @@ var useReplayFlash = function useReplayFlash(flashSeq) {
|
|
|
247
250
|
return ref;
|
|
248
251
|
};
|
|
249
252
|
|
|
250
|
-
var _excluded = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
253
|
+
var _excluded$1 = ["children", "state", "active", "invalid", "onClick", "className", "dataTestid"];
|
|
251
254
|
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; }
|
|
252
255
|
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; }
|
|
253
256
|
var Token = function Token(_ref) {
|
|
@@ -261,7 +264,7 @@ var Token = function Token(_ref) {
|
|
|
261
264
|
onClick = _ref.onClick,
|
|
262
265
|
className = _ref.className,
|
|
263
266
|
dataTestid = _ref.dataTestid,
|
|
264
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
267
|
+
rest = _objectWithoutProperties(_ref, _excluded$1);
|
|
265
268
|
var isInteractive = typeof onClick === "function" && state !== TOKEN_STATE.DISABLED;
|
|
266
269
|
var tokenRef = useReplayFlash(invalid);
|
|
267
270
|
return /*#__PURE__*/jsx("span", _objectSpread$c(_objectSpread$c({
|
|
@@ -305,8 +308,13 @@ var isExcludeVerb = function isExcludeVerb(verb) {
|
|
|
305
308
|
var isMultiValueVerb = function isMultiValueVerb(verb) {
|
|
306
309
|
return String(verb).includes(VERB_TOKENS.MULTI_VALUE);
|
|
307
310
|
};
|
|
311
|
+
|
|
312
|
+
// Lowers a label so it reads mid-sentence, but never an acronym: "API" and
|
|
313
|
+
// "SMS" are already how they should appear.
|
|
308
314
|
var sentencify = function sentencify(label) {
|
|
309
|
-
|
|
315
|
+
if (!label) return label;
|
|
316
|
+
if (label.charAt(1) === label.charAt(1).toUpperCase()) return label;
|
|
317
|
+
return label.charAt(0).toLowerCase() + label.slice(1);
|
|
310
318
|
};
|
|
311
319
|
var copyFor = function copyFor(value, args) {
|
|
312
320
|
return typeof value === "function" ? value(args) : value;
|
|
@@ -415,10 +423,43 @@ var channelOption = function channelOption(_ref10) {
|
|
|
415
423
|
return ((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id) === channel;
|
|
416
424
|
});
|
|
417
425
|
};
|
|
418
|
-
|
|
419
|
-
|
|
426
|
+
|
|
427
|
+
// A step is an extra sentence token a host hangs off an action — its own
|
|
428
|
+
// separator, its own pane — for settings that do not belong in the config pane.
|
|
429
|
+
// Its key shares the action's metadata namespace, so declaring one is how a
|
|
430
|
+
// host hands a field to the step: whoever declares it owns it, and the config
|
|
431
|
+
// pane stops validating it.
|
|
432
|
+
var actionStepsOf = function actionStepsOf(_ref11) {
|
|
420
433
|
var schema = _ref11.schema,
|
|
421
434
|
action = _ref11.action;
|
|
435
|
+
return actionParts({
|
|
436
|
+
schema: schema,
|
|
437
|
+
action: action
|
|
438
|
+
}).steps || [];
|
|
439
|
+
};
|
|
440
|
+
var stepValueOf = function stepValueOf(_ref12) {
|
|
441
|
+
var _action$metadata;
|
|
442
|
+
var action = _ref12.action,
|
|
443
|
+
step = _ref12.step;
|
|
444
|
+
return action === null || action === void 0 || (_action$metadata = action.metadata) === null || _action$metadata === void 0 ? void 0 : _action$metadata[step.key];
|
|
445
|
+
};
|
|
446
|
+
var stepLabelOf = function stepLabelOf(_ref13) {
|
|
447
|
+
var _find;
|
|
448
|
+
var action = _ref13.action,
|
|
449
|
+
step = _ref13.step;
|
|
450
|
+
var value = stepValueOf({
|
|
451
|
+
action: action,
|
|
452
|
+
step: step
|
|
453
|
+
});
|
|
454
|
+
return ((_find = (step.options || []).find(function (option) {
|
|
455
|
+
var _option$value2;
|
|
456
|
+
return ((_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : option.id) === value;
|
|
457
|
+
})) === null || _find === void 0 ? void 0 : _find.label) || "";
|
|
458
|
+
};
|
|
459
|
+
var actionParts = function actionParts(_ref14) {
|
|
460
|
+
var _actions$actionForNam, _action$recipient, _actions$channelMeta, _find2, _find3, _channelMeta$needsRec, _actions$configValueL;
|
|
461
|
+
var schema = _ref14.schema,
|
|
462
|
+
action = _ref14.action;
|
|
422
463
|
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
423
464
|
var resolved = action !== null && action !== void 0 && action.channel ? {
|
|
424
465
|
channel: action.channel,
|
|
@@ -440,7 +481,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
440
481
|
var _recipient$value;
|
|
441
482
|
return ((_recipient$value = recipient.value) !== null && _recipient$value !== void 0 ? _recipient$value : recipient.id) === recipientValue;
|
|
442
483
|
};
|
|
443
|
-
var recipientLabel = ((
|
|
484
|
+
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;
|
|
444
485
|
return {
|
|
445
486
|
option: option,
|
|
446
487
|
channel: channel,
|
|
@@ -459,6 +500,7 @@ var actionParts = function actionParts(_ref11) {
|
|
|
459
500
|
recipientLabel: recipientLabel,
|
|
460
501
|
configTitle: channelMeta.configTitle || (option === null || option === void 0 ? void 0 : option.configTitle),
|
|
461
502
|
configSubtitle: channelMeta.configSubtitle || (option === null || option === void 0 ? void 0 : option.configSubtitle),
|
|
503
|
+
steps: channelMeta.steps || (option === null || option === void 0 ? void 0 : option.steps) || [],
|
|
462
504
|
recipientTitle: channelMeta.recipientTitle || (option === null || option === void 0 ? void 0 : option.recipientTitle),
|
|
463
505
|
recipientSubtitle: channelMeta.recipientSubtitle || (option === null || option === void 0 ? void 0 : option.recipientSubtitle)
|
|
464
506
|
};
|
|
@@ -467,13 +509,13 @@ var actionParts = function actionParts(_ref11) {
|
|
|
467
509
|
// Which condition fields a host offers can depend on the rule — a trigger may
|
|
468
510
|
// only support a subset. Lookups deliberately keep using the full list so a
|
|
469
511
|
// field already on the rule still resolves after the offer narrows.
|
|
470
|
-
var offeredConditionFields = function offeredConditionFields(
|
|
471
|
-
var
|
|
472
|
-
var schema =
|
|
473
|
-
rule =
|
|
474
|
-
return (
|
|
512
|
+
var offeredConditionFields = function offeredConditionFields(_ref15) {
|
|
513
|
+
var _ref16, _schema$conditions$fi, _schema$conditions3, _schema$conditions3$f, _schema$conditions4;
|
|
514
|
+
var schema = _ref15.schema,
|
|
515
|
+
rule = _ref15.rule;
|
|
516
|
+
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, {
|
|
475
517
|
rule: rule
|
|
476
|
-
})) !== 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 &&
|
|
518
|
+
})) !== 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 : [];
|
|
477
519
|
};
|
|
478
520
|
var hasTrigger = function hasTrigger(rule) {
|
|
479
521
|
return !isEmpty((rule === null || rule === void 0 ? void 0 : rule.triggers) || []);
|
|
@@ -483,31 +525,72 @@ var hasAction = function hasAction(rule) {
|
|
|
483
525
|
return action === null || action === void 0 ? void 0 : action.name;
|
|
484
526
|
});
|
|
485
527
|
};
|
|
486
|
-
var
|
|
487
|
-
|
|
528
|
+
var isTriggerEnabled = function isTriggerEnabled(schema) {
|
|
529
|
+
var _schema$triggers2;
|
|
530
|
+
return (schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.enabled) !== false;
|
|
531
|
+
};
|
|
532
|
+
var isTriggerSatisfied = function isTriggerSatisfied(_ref17) {
|
|
533
|
+
var rule = _ref17.rule,
|
|
534
|
+
schema = _ref17.schema;
|
|
535
|
+
return !isTriggerEnabled(schema) || hasTrigger(rule);
|
|
536
|
+
};
|
|
537
|
+
var hasRequiredConditions = function hasRequiredConditions(_ref18) {
|
|
538
|
+
var _schema$conditions5;
|
|
539
|
+
var rule = _ref18.rule,
|
|
540
|
+
schema = _ref18.schema;
|
|
541
|
+
return (schema === null || schema === void 0 || (_schema$conditions5 = schema.conditions) === null || _schema$conditions5 === void 0 ? void 0 : _schema$conditions5.allowEmpty) === false ? isNotEmpty((rule === null || rule === void 0 ? void 0 : rule.conditions) || []) : true;
|
|
488
542
|
};
|
|
489
|
-
var
|
|
543
|
+
var hasUnansweredStep = function hasUnansweredStep(_ref19) {
|
|
544
|
+
var rule = _ref19.rule,
|
|
545
|
+
schema = _ref19.schema;
|
|
546
|
+
return ((rule === null || rule === void 0 ? void 0 : rule.actions) || []).some(function (action) {
|
|
547
|
+
return actionStepsOf({
|
|
548
|
+
schema: schema,
|
|
549
|
+
action: action
|
|
550
|
+
}).some(function (step) {
|
|
551
|
+
return step.required && !stepValueOf({
|
|
552
|
+
action: action,
|
|
553
|
+
step: step
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
var isRuleComplete = function isRuleComplete(_ref20) {
|
|
559
|
+
var rule = _ref20.rule,
|
|
560
|
+
schema = _ref20.schema;
|
|
561
|
+
return isTriggerSatisfied({
|
|
562
|
+
rule: rule,
|
|
563
|
+
schema: schema
|
|
564
|
+
}) && hasRequiredConditions({
|
|
565
|
+
rule: rule,
|
|
566
|
+
schema: schema
|
|
567
|
+
}) && hasAction(rule) && !hasUnansweredStep({
|
|
568
|
+
rule: rule,
|
|
569
|
+
schema: schema
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
var scopeOptionFor = function scopeOptionFor(_ref21) {
|
|
490
573
|
var _item$value, _schema$scope;
|
|
491
|
-
var schema =
|
|
492
|
-
item =
|
|
574
|
+
var schema = _ref21.schema,
|
|
575
|
+
item = _ref21.item;
|
|
493
576
|
var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
|
|
494
577
|
return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
|
|
495
578
|
var _candidate$value2;
|
|
496
579
|
return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
|
|
497
580
|
});
|
|
498
581
|
};
|
|
499
|
-
var scopePhoneFields = function scopePhoneFields(
|
|
500
|
-
var
|
|
501
|
-
var schema =
|
|
502
|
-
item =
|
|
503
|
-
return (
|
|
582
|
+
var scopePhoneFields = function scopePhoneFields(_ref22) {
|
|
583
|
+
var _ref23, _item$phoneFields, _scopeOptionFor;
|
|
584
|
+
var schema = _ref22.schema,
|
|
585
|
+
item = _ref22.item;
|
|
586
|
+
return (_ref23 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
|
|
504
587
|
schema: schema,
|
|
505
588
|
item: item
|
|
506
|
-
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null &&
|
|
589
|
+
})) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref23 !== void 0 ? _ref23 : null;
|
|
507
590
|
};
|
|
508
|
-
var effectiveScopePhoneField = function effectiveScopePhoneField(
|
|
509
|
-
var schema =
|
|
510
|
-
item =
|
|
591
|
+
var effectiveScopePhoneField = function effectiveScopePhoneField(_ref24) {
|
|
592
|
+
var schema = _ref24.schema,
|
|
593
|
+
item = _ref24.item;
|
|
511
594
|
if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
|
|
512
595
|
var phoneFields = scopePhoneFields({
|
|
513
596
|
schema: schema,
|
|
@@ -515,14 +598,14 @@ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref17) {
|
|
|
515
598
|
});
|
|
516
599
|
return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
|
|
517
600
|
};
|
|
518
|
-
var invalidScopeIndexes = function invalidScopeIndexes(
|
|
601
|
+
var invalidScopeIndexes = function invalidScopeIndexes(_ref25) {
|
|
519
602
|
var _scope$requiresPhone;
|
|
520
|
-
var rule =
|
|
521
|
-
schema =
|
|
603
|
+
var rule = _ref25.rule,
|
|
604
|
+
schema = _ref25.schema;
|
|
522
605
|
var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
|
|
523
606
|
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 [];
|
|
524
607
|
return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
|
|
525
|
-
var
|
|
608
|
+
var _ref26, _item$hasPhoneField;
|
|
526
609
|
var option = scopeOptionFor({
|
|
527
610
|
schema: schema,
|
|
528
611
|
item: item
|
|
@@ -531,15 +614,15 @@ var invalidScopeIndexes = function invalidScopeIndexes(_ref18) {
|
|
|
531
614
|
schema: schema,
|
|
532
615
|
item: item
|
|
533
616
|
});
|
|
534
|
-
var hasPhoneField = (
|
|
617
|
+
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;
|
|
535
618
|
if (hasPhoneField === false) indexes.push(index);
|
|
536
619
|
return indexes;
|
|
537
620
|
}, []);
|
|
538
621
|
};
|
|
539
|
-
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(
|
|
622
|
+
var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref27) {
|
|
540
623
|
var _scope$requiresPhone2;
|
|
541
|
-
var rule =
|
|
542
|
-
schema =
|
|
624
|
+
var rule = _ref27.rule,
|
|
625
|
+
schema = _ref27.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$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.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) {
|
|
@@ -576,9 +659,9 @@ var minutesToParts = function minutesToParts(minutes) {
|
|
|
576
659
|
unit: "minutes"
|
|
577
660
|
};
|
|
578
661
|
};
|
|
579
|
-
var partsToMinutes = function partsToMinutes(
|
|
580
|
-
var value =
|
|
581
|
-
unit =
|
|
662
|
+
var partsToMinutes = function partsToMinutes(_ref28) {
|
|
663
|
+
var value = _ref28.value,
|
|
664
|
+
unit = _ref28.unit;
|
|
582
665
|
return (
|
|
583
666
|
// eslint-disable-next-line security/detect-object-injection
|
|
584
667
|
(Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
|
|
@@ -588,8 +671,8 @@ var leadTimeExceedsMax = function leadTimeExceedsMax(minutes) {
|
|
|
588
671
|
return minutesToParts(minutes).value > MAX_LEAD_TIME_VALUE;
|
|
589
672
|
};
|
|
590
673
|
var leadTimeValidationSchema = function leadTimeValidationSchema(schema) {
|
|
591
|
-
var _schema$
|
|
592
|
-
var fieldKey = schema === null || schema === void 0 || (_schema$
|
|
674
|
+
var _schema$triggers3;
|
|
675
|
+
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;
|
|
593
676
|
if (!fieldKey) return yup.object();
|
|
594
677
|
return yup.object().shape(_defineProperty({}, fieldKey, yup.object().shape({
|
|
595
678
|
// yup 0.32 can only concat schemas of the same type, and the host's
|
|
@@ -628,30 +711,64 @@ var joinTypeFor = function joinTypeFor(mode) {
|
|
|
628
711
|
var recipientStorageField = function recipientStorageField(field) {
|
|
629
712
|
return field === RECIPIENT_STORAGE_FIELDS.emails ? RECIPIENT_STORAGE_FIELDS.emails : RECIPIENT_STORAGE_FIELDS.value;
|
|
630
713
|
};
|
|
714
|
+
|
|
715
|
+
// Which metadata fields the recipient pane renders, and therefore owns: no
|
|
716
|
+
// other pane may block Continue on them. Canvas and ConfigPane both ask here
|
|
717
|
+
// so the two lists cannot drift apart.
|
|
718
|
+
var recipientOwnedFields = function recipientOwnedFields(_ref29) {
|
|
719
|
+
var _actions$actionForNam2, _action$recipient2, _actions$renderRecipi, _actions$renderRecipi2, _actions$optionForNam, _actions$optionForCha;
|
|
720
|
+
var schema = _ref29.schema,
|
|
721
|
+
action = _ref29.action,
|
|
722
|
+
name = _ref29.name;
|
|
723
|
+
var actions = (schema === null || schema === void 0 ? void 0 : schema.actions) || {};
|
|
724
|
+
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)) || {};
|
|
725
|
+
var channel = (action === null || action === void 0 ? void 0 : action.channel) || resolved.channel;
|
|
726
|
+
// A recipient the host implies from the action name counts just as much as
|
|
727
|
+
// one the user picked, or the pane it owns cannot be excluded.
|
|
728
|
+
var recipient = (_action$recipient2 = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient2 !== void 0 ? _action$recipient2 : resolved.recipient;
|
|
729
|
+
var rendersEmails = !!((_actions$renderRecipi = actions.renderRecipientEditor) !== null && _actions$renderRecipi !== void 0 && _actions$renderRecipi.call(actions, {
|
|
730
|
+
channel: channel,
|
|
731
|
+
name: name,
|
|
732
|
+
action: action
|
|
733
|
+
})) || !!((_actions$renderRecipi2 = actions.renderRecipientField) !== null && _actions$renderRecipi2 !== void 0 && _actions$renderRecipi2.call(actions, {
|
|
734
|
+
channel: channel,
|
|
735
|
+
name: name,
|
|
736
|
+
action: action,
|
|
737
|
+
recipient: recipient
|
|
738
|
+
}));
|
|
739
|
+
var recipientConfig = (actions.options || []).flatMap(function (option) {
|
|
740
|
+
return option.recipients || [];
|
|
741
|
+
}).concat(actions.recipients || []).find(function (item) {
|
|
742
|
+
var _item$value2;
|
|
743
|
+
return ((_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.id) === recipient;
|
|
744
|
+
});
|
|
745
|
+
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));
|
|
746
|
+
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] : []));
|
|
747
|
+
};
|
|
631
748
|
var modeFromJoinType = function modeFromJoinType(joinType) {
|
|
632
749
|
return joinType === JOIN_TYPE.or ? CONDITION_MODE.OR : CONDITION_MODE.AND;
|
|
633
750
|
};
|
|
634
751
|
|
|
635
752
|
// eslint-disable-next-line security/detect-object-injection
|
|
636
|
-
var valueAt = function valueAt(
|
|
753
|
+
var valueAt = function valueAt(_ref30) {
|
|
637
754
|
var _values$key;
|
|
638
|
-
var values =
|
|
639
|
-
key =
|
|
755
|
+
var values = _ref30.values,
|
|
756
|
+
key = _ref30.key;
|
|
640
757
|
return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
|
|
641
758
|
};
|
|
642
759
|
var asArray = function asArray(maybeArray) {
|
|
643
760
|
return Array.isArray(maybeArray) ? maybeArray : [];
|
|
644
761
|
};
|
|
645
762
|
var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
646
|
-
var _schema$
|
|
763
|
+
var _schema$triggers4, _schema$actor2, _schema$conditions6, _schema$actions3, _schema$delay, _schema$triggers5, _schema$scope2;
|
|
647
764
|
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
648
765
|
return {
|
|
649
|
-
triggers: ((_schema$
|
|
766
|
+
triggers: ((_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey) || "events",
|
|
650
767
|
performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
|
|
651
|
-
conditions: ((_schema$
|
|
768
|
+
conditions: ((_schema$conditions6 = schema.conditions) === null || _schema$conditions6 === void 0 ? void 0 : _schema$conditions6.fieldKey) || "conditions",
|
|
652
769
|
actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
|
|
653
770
|
delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
|
|
654
|
-
leadTime: (_schema$
|
|
771
|
+
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,
|
|
655
772
|
scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
|
|
656
773
|
status: "status",
|
|
657
774
|
name: "name"
|
|
@@ -659,11 +776,11 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
|
|
|
659
776
|
};
|
|
660
777
|
var valuesToRuleModel = function valuesToRuleModel() {
|
|
661
778
|
var _valueAt, _conditions$;
|
|
662
|
-
var
|
|
663
|
-
|
|
664
|
-
values =
|
|
665
|
-
|
|
666
|
-
schema =
|
|
779
|
+
var _ref31 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
780
|
+
_ref31$values = _ref31.values,
|
|
781
|
+
values = _ref31$values === void 0 ? {} : _ref31$values,
|
|
782
|
+
_ref31$schema = _ref31.schema,
|
|
783
|
+
schema = _ref31$schema === void 0 ? {} : _ref31$schema;
|
|
667
784
|
var keys = fieldKeysFromSchema(schema);
|
|
668
785
|
var conditions = asArray(valueAt({
|
|
669
786
|
values: values,
|
|
@@ -707,42 +824,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
|
|
|
707
824
|
}))
|
|
708
825
|
};
|
|
709
826
|
};
|
|
710
|
-
var setTriggers = function setTriggers(
|
|
711
|
-
var schema =
|
|
712
|
-
triggers =
|
|
827
|
+
var setTriggers = function setTriggers(_ref32) {
|
|
828
|
+
var schema = _ref32.schema,
|
|
829
|
+
triggers = _ref32.triggers;
|
|
713
830
|
return {
|
|
714
831
|
path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
|
|
715
832
|
value: triggers
|
|
716
833
|
};
|
|
717
834
|
};
|
|
718
|
-
var setPerformer = function setPerformer(
|
|
719
|
-
var schema =
|
|
720
|
-
performer =
|
|
835
|
+
var setPerformer = function setPerformer(_ref33) {
|
|
836
|
+
var schema = _ref33.schema,
|
|
837
|
+
performer = _ref33.performer;
|
|
721
838
|
return {
|
|
722
839
|
path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
|
|
723
840
|
value: performer
|
|
724
841
|
};
|
|
725
842
|
};
|
|
726
|
-
var setActions = function setActions(
|
|
727
|
-
var schema =
|
|
728
|
-
actions =
|
|
843
|
+
var setActions = function setActions(_ref34) {
|
|
844
|
+
var schema = _ref34.schema,
|
|
845
|
+
actions = _ref34.actions;
|
|
729
846
|
return {
|
|
730
847
|
path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
|
|
731
848
|
value: actions
|
|
732
849
|
};
|
|
733
850
|
};
|
|
734
|
-
var setConditions = function setConditions(
|
|
735
|
-
var schema =
|
|
736
|
-
conditions =
|
|
851
|
+
var setConditions = function setConditions(_ref35) {
|
|
852
|
+
var schema = _ref35.schema,
|
|
853
|
+
conditions = _ref35.conditions;
|
|
737
854
|
return {
|
|
738
855
|
path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
|
|
739
856
|
value: conditions
|
|
740
857
|
};
|
|
741
858
|
};
|
|
742
|
-
var setConditionMode = function setConditionMode(
|
|
743
|
-
var schema =
|
|
744
|
-
conditions =
|
|
745
|
-
joinType =
|
|
859
|
+
var setConditionMode = function setConditionMode(_ref36) {
|
|
860
|
+
var schema = _ref36.schema,
|
|
861
|
+
conditions = _ref36.conditions,
|
|
862
|
+
joinType = _ref36.joinType;
|
|
746
863
|
return setConditions({
|
|
747
864
|
schema: schema,
|
|
748
865
|
conditions: conditions.map(function (condition) {
|
|
@@ -750,34 +867,34 @@ var setConditionMode = function setConditionMode(_ref28) {
|
|
|
750
867
|
})
|
|
751
868
|
});
|
|
752
869
|
};
|
|
753
|
-
var setDelay = function setDelay(
|
|
754
|
-
var schema =
|
|
755
|
-
delay =
|
|
870
|
+
var setDelay = function setDelay(_ref37) {
|
|
871
|
+
var schema = _ref37.schema,
|
|
872
|
+
delay = _ref37.delay;
|
|
756
873
|
return {
|
|
757
874
|
path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
|
|
758
875
|
value: delay !== null && delay !== void 0 ? delay : {}
|
|
759
876
|
};
|
|
760
877
|
};
|
|
761
|
-
var setActive = function setActive(
|
|
762
|
-
var schema =
|
|
763
|
-
active =
|
|
878
|
+
var setActive = function setActive(_ref38) {
|
|
879
|
+
var schema = _ref38.schema,
|
|
880
|
+
active = _ref38.active;
|
|
764
881
|
return {
|
|
765
882
|
path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
|
|
766
883
|
value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
|
|
767
884
|
};
|
|
768
885
|
};
|
|
769
|
-
var setScope = function setScope(
|
|
770
|
-
var schema =
|
|
771
|
-
scope =
|
|
886
|
+
var setScope = function setScope(_ref39) {
|
|
887
|
+
var schema = _ref39.schema,
|
|
888
|
+
scope = _ref39.scope;
|
|
772
889
|
return {
|
|
773
890
|
path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
|
|
774
891
|
value: scope
|
|
775
892
|
};
|
|
776
893
|
};
|
|
777
|
-
var removeArrayItem = function removeArrayItem(
|
|
778
|
-
var values =
|
|
779
|
-
fieldKey =
|
|
780
|
-
index =
|
|
894
|
+
var removeArrayItem = function removeArrayItem(_ref40) {
|
|
895
|
+
var values = _ref40.values,
|
|
896
|
+
fieldKey = _ref40.fieldKey,
|
|
897
|
+
index = _ref40.index;
|
|
781
898
|
var list = asArray(valueAt({
|
|
782
899
|
values: values,
|
|
783
900
|
key: fieldKey
|
|
@@ -804,9 +921,9 @@ var removeArrayItem = function removeArrayItem(_ref32) {
|
|
|
804
921
|
}
|
|
805
922
|
return result;
|
|
806
923
|
};
|
|
807
|
-
var clearArrayItems = function clearArrayItems(
|
|
808
|
-
var values =
|
|
809
|
-
fieldKey =
|
|
924
|
+
var clearArrayItems = function clearArrayItems(_ref41) {
|
|
925
|
+
var values = _ref41.values,
|
|
926
|
+
fieldKey = _ref41.fieldKey;
|
|
810
927
|
var list = asArray(valueAt({
|
|
811
928
|
values: values,
|
|
812
929
|
key: fieldKey
|
|
@@ -882,13 +999,13 @@ var ConditionRow = function ConditionRow(_ref) {
|
|
|
882
999
|
className: "mb-sentence",
|
|
883
1000
|
children: [isFirst ? /*#__PURE__*/jsx("span", {
|
|
884
1001
|
className: "mb-fixed",
|
|
885
|
-
children: t("neetoRules.operators.and")
|
|
1002
|
+
children: isTriggerEnabled(schema) ? t("neetoRules.operators.and") : t("neetoRules.common.when")
|
|
886
1003
|
}) : /*#__PURE__*/jsx(Token, {
|
|
887
1004
|
active: isActive({
|
|
888
1005
|
type: BUILDER_ANCHORS.COND_CONNECTOR,
|
|
889
1006
|
index: index
|
|
890
1007
|
}),
|
|
891
|
-
className: "mb-tok-
|
|
1008
|
+
className: "mb-tok-connector",
|
|
892
1009
|
dataTestid: "cond-connector-".concat(index),
|
|
893
1010
|
onClick: handleToken && function () {
|
|
894
1011
|
return handleToken({
|
|
@@ -1111,8 +1228,8 @@ var MetaBlock = function MetaBlock(_ref) {
|
|
|
1111
1228
|
className: "mb-meta-label",
|
|
1112
1229
|
children: t("neetoRules.builder.automationName")
|
|
1113
1230
|
}), /*#__PURE__*/jsxs("div", {
|
|
1114
|
-
ref: nameRef,
|
|
1115
1231
|
"data-testid": "rule-name-edit",
|
|
1232
|
+
ref: nameRef,
|
|
1116
1233
|
role: handleEditName ? "button" : undefined,
|
|
1117
1234
|
tabIndex: handleEditName ? 0 : undefined,
|
|
1118
1235
|
className: classNames("mb-meta-input-wrap", {
|
|
@@ -1384,8 +1501,12 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1384
1501
|
configValuePlaceholder = _actionParts.configValuePlaceholder,
|
|
1385
1502
|
paramKind = _actionParts.paramKind,
|
|
1386
1503
|
valueNoun = _actionParts.valueNoun,
|
|
1387
|
-
valueNounPlural = _actionParts.valueNounPlural
|
|
1388
|
-
|
|
1504
|
+
valueNounPlural = _actionParts.valueNounPlural,
|
|
1505
|
+
steps = _actionParts.steps;
|
|
1506
|
+
|
|
1507
|
+
// A separator-less action still needs a value slot when the host declares a
|
|
1508
|
+
// placeholder for it, otherwise its chosen value never reaches the canvas.
|
|
1509
|
+
var hasParamTail = paramKind === PARAM_KIND.ENUM_SINGLE || paramKind === PARAM_KIND.ENUM_MULTI || !!configValuePlaceholder || !!configValue;
|
|
1389
1510
|
var multiPlaceholder = valueNounPlural ? t("neetoRules.builder.selectNoun", {
|
|
1390
1511
|
noun: valueNounPlural
|
|
1391
1512
|
}) : t("neetoRules.form.selectValues");
|
|
@@ -1403,12 +1524,92 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1403
1524
|
index: index
|
|
1404
1525
|
});
|
|
1405
1526
|
var configLabel = mediumLabel || sentencify(option === null || option === void 0 ? void 0 : option.placeholder);
|
|
1527
|
+
// A host may declare two separators: the first introduces the recipient
|
|
1528
|
+
// ("whose email is"), the second the configured value ("with the following").
|
|
1529
|
+
var _ref2 = Array.isArray(separator) ? separator : [null, separator],
|
|
1530
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
1531
|
+
recipientSeparator = _ref3[0],
|
|
1532
|
+
configSeparator = _ref3[1];
|
|
1406
1533
|
var isConfigured = isNotEmpty(action === null || action === void 0 ? void 0 : action.metadata);
|
|
1407
1534
|
// A host that shows no value label still needs the token to read as filled.
|
|
1408
1535
|
var configState = configValue || isConfigured ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED;
|
|
1409
1536
|
var _useClearingHover = useClearingHover(),
|
|
1410
1537
|
clearing = _useClearingHover.clearing,
|
|
1411
1538
|
clearingHoverProps = _useClearingHover.clearingHoverProps;
|
|
1539
|
+
var configToken = configSeparator ? /*#__PURE__*/jsxs(Fragment$1, {
|
|
1540
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1541
|
+
className: "mb-fixed",
|
|
1542
|
+
children: configSeparator
|
|
1543
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1544
|
+
active: isActive({
|
|
1545
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1546
|
+
index: index
|
|
1547
|
+
}),
|
|
1548
|
+
dataTestid: "action-config-value-".concat(index),
|
|
1549
|
+
state: configState,
|
|
1550
|
+
invalid: isInvalid({
|
|
1551
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1552
|
+
index: index
|
|
1553
|
+
}),
|
|
1554
|
+
onClick: handleToken && function () {
|
|
1555
|
+
return handleToken({
|
|
1556
|
+
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1557
|
+
index: index
|
|
1558
|
+
});
|
|
1559
|
+
},
|
|
1560
|
+
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1561
|
+
})]
|
|
1562
|
+
}, "config") : null;
|
|
1563
|
+
var recipientToken = needsRecipient ? /*#__PURE__*/jsxs(Fragment$1, {
|
|
1564
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1565
|
+
className: "mb-fixed",
|
|
1566
|
+
children: recipientSeparator || t("neetoRules.common.to")
|
|
1567
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1568
|
+
dataTestid: "action-recipient-".concat(index),
|
|
1569
|
+
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1570
|
+
active: isActive({
|
|
1571
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1572
|
+
index: index
|
|
1573
|
+
}),
|
|
1574
|
+
invalid: isInvalid({
|
|
1575
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1576
|
+
index: index
|
|
1577
|
+
}),
|
|
1578
|
+
onClick: handleToken && function () {
|
|
1579
|
+
return handleToken({
|
|
1580
|
+
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1581
|
+
index: index
|
|
1582
|
+
});
|
|
1583
|
+
},
|
|
1584
|
+
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1585
|
+
})]
|
|
1586
|
+
}, "recipient") : null;
|
|
1587
|
+
var stepTokens = steps.map(function (step) {
|
|
1588
|
+
var stepLabel = stepLabelOf({
|
|
1589
|
+
action: action,
|
|
1590
|
+
step: step
|
|
1591
|
+
});
|
|
1592
|
+
var token = {
|
|
1593
|
+
type: BUILDER_ANCHORS.ACTION_STEP,
|
|
1594
|
+
index: index,
|
|
1595
|
+
stepKey: step.key
|
|
1596
|
+
};
|
|
1597
|
+
return /*#__PURE__*/jsxs(Fragment$1, {
|
|
1598
|
+
children: [step.separator && /*#__PURE__*/jsx("span", {
|
|
1599
|
+
className: "mb-fixed",
|
|
1600
|
+
children: step.separator
|
|
1601
|
+
}), /*#__PURE__*/jsx(Token, {
|
|
1602
|
+
active: isActive(token),
|
|
1603
|
+
dataTestid: "action-step-".concat(step.key, "-").concat(index),
|
|
1604
|
+
invalid: isInvalid(token),
|
|
1605
|
+
state: stepLabel ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1606
|
+
onClick: handleToken && function () {
|
|
1607
|
+
return handleToken(token);
|
|
1608
|
+
},
|
|
1609
|
+
children: (step.preserveCase ? stepLabel : sentencify(stepLabel)) || sentencify(step.placeholder)
|
|
1610
|
+
})]
|
|
1611
|
+
}, "step-".concat(step.key));
|
|
1612
|
+
});
|
|
1412
1613
|
return /*#__PURE__*/jsxs("div", {
|
|
1413
1614
|
className: classNames("mb-row mb-row-draggable", {
|
|
1414
1615
|
clearing: clearing
|
|
@@ -1418,7 +1619,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1418
1619
|
children: [/*#__PURE__*/jsx("span", {
|
|
1419
1620
|
className: "mb-fixed",
|
|
1420
1621
|
children: connector
|
|
1421
|
-
}),
|
|
1622
|
+
}), configSeparator ? /*#__PURE__*/jsxs(Token, {
|
|
1422
1623
|
active: isVerbActive,
|
|
1423
1624
|
className: "mb-tok-medium",
|
|
1424
1625
|
dataTestid: "action-verb-".concat(index),
|
|
@@ -1459,7 +1660,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1459
1660
|
index: index
|
|
1460
1661
|
});
|
|
1461
1662
|
},
|
|
1462
|
-
children: configValue || paramPlaceholder
|
|
1663
|
+
children: configValue || sentencify(configValuePlaceholder) || paramPlaceholder
|
|
1463
1664
|
}) : configLabel && /*#__PURE__*/jsxs(Token, {
|
|
1464
1665
|
className: "mb-tok-medium",
|
|
1465
1666
|
dataTestid: "action-config-".concat(index),
|
|
@@ -1482,53 +1683,7 @@ var ActionRow = function ActionRow(_ref) {
|
|
|
1482
1683
|
size: 14
|
|
1483
1684
|
}), configLabel]
|
|
1484
1685
|
})]
|
|
1485
|
-
}),
|
|
1486
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
1487
|
-
className: "mb-fixed",
|
|
1488
|
-
children: separator
|
|
1489
|
-
}), /*#__PURE__*/jsx(Token, {
|
|
1490
|
-
active: isActive({
|
|
1491
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1492
|
-
index: index
|
|
1493
|
-
}),
|
|
1494
|
-
dataTestid: "action-config-value-".concat(index),
|
|
1495
|
-
state: configState,
|
|
1496
|
-
invalid: isInvalid({
|
|
1497
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1498
|
-
index: index
|
|
1499
|
-
}),
|
|
1500
|
-
onClick: handleToken && function () {
|
|
1501
|
-
return handleToken({
|
|
1502
|
-
type: BUILDER_ANCHORS.ACTION_CONFIG,
|
|
1503
|
-
index: index
|
|
1504
|
-
});
|
|
1505
|
-
},
|
|
1506
|
-
children: configValue || sentencify(configValuePlaceholder) || t("neetoRules.builder.selectFallback")
|
|
1507
|
-
})]
|
|
1508
|
-
}), needsRecipient && /*#__PURE__*/jsxs(Fragment, {
|
|
1509
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
1510
|
-
className: "mb-fixed",
|
|
1511
|
-
children: t("neetoRules.common.to")
|
|
1512
|
-
}), /*#__PURE__*/jsx(Token, {
|
|
1513
|
-
dataTestid: "action-recipient-".concat(index),
|
|
1514
|
-
state: recipient ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
|
|
1515
|
-
active: isActive({
|
|
1516
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1517
|
-
index: index
|
|
1518
|
-
}),
|
|
1519
|
-
invalid: isInvalid({
|
|
1520
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1521
|
-
index: index
|
|
1522
|
-
}),
|
|
1523
|
-
onClick: handleToken && function () {
|
|
1524
|
-
return handleToken({
|
|
1525
|
-
type: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
1526
|
-
index: index
|
|
1527
|
-
});
|
|
1528
|
-
},
|
|
1529
|
-
children: recipient ? String(recipientLabel).toLowerCase() : t("neetoRules.builder.selectRecipient")
|
|
1530
|
-
})]
|
|
1531
|
-
})]
|
|
1686
|
+
}), recipientSeparator ? [recipientToken, configToken] : [configToken, recipientToken], stepTokens]
|
|
1532
1687
|
}), /*#__PURE__*/jsxs("div", {
|
|
1533
1688
|
className: "mb-row-actions",
|
|
1534
1689
|
children: [handleAddAction && /*#__PURE__*/jsx(Button, {
|
|
@@ -1584,7 +1739,10 @@ var ThenBlock = function ThenBlock(_ref) {
|
|
|
1584
1739
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
1585
1740
|
});
|
|
1586
1741
|
if (isEmpty(named)) {
|
|
1587
|
-
var isTriggerSet =
|
|
1742
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
1743
|
+
rule: rule,
|
|
1744
|
+
schema: schema
|
|
1745
|
+
});
|
|
1588
1746
|
return /*#__PURE__*/jsx("div", {
|
|
1589
1747
|
className: "mb-row",
|
|
1590
1748
|
children: /*#__PURE__*/jsx("div", {
|
|
@@ -1676,6 +1834,21 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1676
1834
|
var _schema$triggers;
|
|
1677
1835
|
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);
|
|
1678
1836
|
};
|
|
1837
|
+
if (!isTriggerEnabled(schema)) {
|
|
1838
|
+
if (!isEmpty(rule.conditions)) return null;
|
|
1839
|
+
return /*#__PURE__*/jsx("div", {
|
|
1840
|
+
className: "mb-row",
|
|
1841
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1842
|
+
className: "mb-sentence",
|
|
1843
|
+
children: /*#__PURE__*/jsx(Token, {
|
|
1844
|
+
dataTestid: "condition-add",
|
|
1845
|
+
state: TOKEN_STATE.PLACEHOLDER_NEXT,
|
|
1846
|
+
onClick: handleAddCondition || undefined,
|
|
1847
|
+
children: t("neetoRules.builder.whenThisIsTrue")
|
|
1848
|
+
})
|
|
1849
|
+
})
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1679
1852
|
if (isEmpty(triggers)) {
|
|
1680
1853
|
return /*#__PURE__*/jsx("div", {
|
|
1681
1854
|
className: "mb-row",
|
|
@@ -1804,6 +1977,7 @@ var WhenBlock = function WhenBlock(_ref) {
|
|
|
1804
1977
|
});
|
|
1805
1978
|
};
|
|
1806
1979
|
|
|
1980
|
+
var _excluded = ["type"];
|
|
1807
1981
|
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; }
|
|
1808
1982
|
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; }
|
|
1809
1983
|
var usePaneCascade = function usePaneCascade(schema) {
|
|
@@ -1831,12 +2005,13 @@ var usePaneCascade = function usePaneCascade(schema) {
|
|
|
1831
2005
|
var openPane = useCallback(function (token) {
|
|
1832
2006
|
var type = TOKEN_TO_PANEL_TYPE[token === null || token === void 0 ? void 0 : token.type];
|
|
1833
2007
|
if (!type) return;
|
|
2008
|
+
var anchor = token.type,
|
|
2009
|
+
rest = _objectWithoutProperties(token, _excluded);
|
|
1834
2010
|
openType({
|
|
1835
2011
|
type: type,
|
|
1836
|
-
data: {
|
|
1837
|
-
anchor:
|
|
1838
|
-
|
|
1839
|
-
}
|
|
2012
|
+
data: _objectSpread$5({
|
|
2013
|
+
anchor: anchor
|
|
2014
|
+
}, rest)
|
|
1840
2015
|
});
|
|
1841
2016
|
}, [openType]);
|
|
1842
2017
|
return {
|
|
@@ -1957,6 +2132,52 @@ var triggerValue = function triggerValue(option) {
|
|
|
1957
2132
|
var _ref, _option$eventValue;
|
|
1958
2133
|
return (_ref = (_option$eventValue = option.eventValue) !== null && _option$eventValue !== void 0 ? _option$eventValue : option.value) !== null && _ref !== void 0 ? _ref : option.id;
|
|
1959
2134
|
};
|
|
2135
|
+
var stepAt = function stepAt(_ref2) {
|
|
2136
|
+
var schema = _ref2.schema,
|
|
2137
|
+
rule = _ref2.rule,
|
|
2138
|
+
index = _ref2.index,
|
|
2139
|
+
stepKey = _ref2.stepKey;
|
|
2140
|
+
return actionStepsOf({
|
|
2141
|
+
schema: schema,
|
|
2142
|
+
action: actionAt({
|
|
2143
|
+
rule: rule,
|
|
2144
|
+
index: index
|
|
2145
|
+
})
|
|
2146
|
+
}).find(function (step) {
|
|
2147
|
+
return step.key === stepKey;
|
|
2148
|
+
});
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
// Panes hand off in sentence order — config, recipient, then each host step —
|
|
2152
|
+
// so every "what comes next" question resolves through this one list.
|
|
2153
|
+
var stepTargetAfter = function stepTargetAfter(_ref3) {
|
|
2154
|
+
var schema = _ref3.schema,
|
|
2155
|
+
rule = _ref3.rule,
|
|
2156
|
+
index = _ref3.index,
|
|
2157
|
+
stepKey = _ref3.stepKey;
|
|
2158
|
+
var steps = actionStepsOf({
|
|
2159
|
+
schema: schema,
|
|
2160
|
+
action: actionAt({
|
|
2161
|
+
rule: rule,
|
|
2162
|
+
index: index
|
|
2163
|
+
})
|
|
2164
|
+
});
|
|
2165
|
+
var at = stepKey ? steps.findIndex(function (step) {
|
|
2166
|
+
return step.key === stepKey;
|
|
2167
|
+
}) : -1;
|
|
2168
|
+
// An unknown key means the step is gone from under the pane; restarting the
|
|
2169
|
+
// cascade at the first step would be worse than ending it.
|
|
2170
|
+
if (stepKey && at === -1) return null;
|
|
2171
|
+
var next = steps[at + 1];
|
|
2172
|
+
return next ? {
|
|
2173
|
+
type: BUILDER_PANEL_TYPES.ACTION_STEP,
|
|
2174
|
+
data: {
|
|
2175
|
+
index: index,
|
|
2176
|
+
stepKey: next.key,
|
|
2177
|
+
anchor: BUILDER_ANCHORS.ACTION_STEP
|
|
2178
|
+
}
|
|
2179
|
+
} : null;
|
|
2180
|
+
};
|
|
1960
2181
|
var optionValue = function optionValue(option) {
|
|
1961
2182
|
var _option$value;
|
|
1962
2183
|
return (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.id;
|
|
@@ -1982,9 +2203,9 @@ var groupByCategory = function groupByCategory(options) {
|
|
|
1982
2203
|
});
|
|
1983
2204
|
return groups;
|
|
1984
2205
|
};
|
|
1985
|
-
var conditionAt = function conditionAt(
|
|
1986
|
-
var rule =
|
|
1987
|
-
index =
|
|
2206
|
+
var conditionAt = function conditionAt(_ref4) {
|
|
2207
|
+
var rule = _ref4.rule,
|
|
2208
|
+
index = _ref4.index;
|
|
1988
2209
|
return (
|
|
1989
2210
|
// eslint-disable-next-line security/detect-object-injection
|
|
1990
2211
|
rule.conditions[index] || {}
|
|
@@ -1992,63 +2213,63 @@ var conditionAt = function conditionAt(_ref2) {
|
|
|
1992
2213
|
};
|
|
1993
2214
|
|
|
1994
2215
|
// eslint-disable-next-line security/detect-object-injection
|
|
1995
|
-
var actionAt = function actionAt(
|
|
1996
|
-
var rule =
|
|
1997
|
-
index =
|
|
2216
|
+
var actionAt = function actionAt(_ref5) {
|
|
2217
|
+
var rule = _ref5.rule,
|
|
2218
|
+
index = _ref5.index;
|
|
1998
2219
|
return rule.actions[index] || {};
|
|
1999
2220
|
};
|
|
2000
2221
|
|
|
2001
2222
|
// eslint-disable-next-line security/detect-object-injection
|
|
2002
|
-
var scopeItemAt = function scopeItemAt(
|
|
2223
|
+
var scopeItemAt = function scopeItemAt(_ref6) {
|
|
2003
2224
|
var _rule$scope;
|
|
2004
|
-
var rule =
|
|
2005
|
-
index =
|
|
2225
|
+
var rule = _ref6.rule,
|
|
2226
|
+
index = _ref6.index;
|
|
2006
2227
|
return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
|
|
2007
2228
|
};
|
|
2008
2229
|
var scopeItemLabel = function scopeItemLabel(item) {
|
|
2009
2230
|
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 : "");
|
|
2010
2231
|
};
|
|
2011
|
-
var findField = function findField(
|
|
2232
|
+
var findField = function findField(_ref7) {
|
|
2012
2233
|
var _schema$conditions;
|
|
2013
|
-
var schema =
|
|
2014
|
-
value =
|
|
2234
|
+
var schema = _ref7.schema,
|
|
2235
|
+
value = _ref7.value;
|
|
2015
2236
|
return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
|
|
2016
2237
|
return optionValue(field) === value;
|
|
2017
2238
|
});
|
|
2018
2239
|
};
|
|
2019
|
-
var findActionOption = function findActionOption(
|
|
2240
|
+
var findActionOption = function findActionOption(_ref8) {
|
|
2020
2241
|
var _schema$actions;
|
|
2021
|
-
var schema =
|
|
2022
|
-
name =
|
|
2242
|
+
var schema = _ref8.schema,
|
|
2243
|
+
name = _ref8.name;
|
|
2023
2244
|
return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
|
|
2024
2245
|
return optionValue(option) === name;
|
|
2025
2246
|
});
|
|
2026
2247
|
};
|
|
2027
|
-
var channelOf = function channelOf(
|
|
2248
|
+
var channelOf = function channelOf(_ref9) {
|
|
2028
2249
|
var _schema$actions2, _schema$actions2$acti;
|
|
2029
|
-
var schema =
|
|
2030
|
-
action =
|
|
2250
|
+
var schema = _ref9.schema,
|
|
2251
|
+
action = _ref9.action;
|
|
2031
2252
|
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);
|
|
2032
2253
|
};
|
|
2033
|
-
var recipientOf = function recipientOf(
|
|
2254
|
+
var recipientOf = function recipientOf(_ref0) {
|
|
2034
2255
|
var _action$recipient, _schema$actions3, _schema$actions3$acti;
|
|
2035
|
-
var schema =
|
|
2036
|
-
action =
|
|
2256
|
+
var schema = _ref0.schema,
|
|
2257
|
+
action = _ref0.action;
|
|
2037
2258
|
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;
|
|
2038
2259
|
};
|
|
2039
|
-
var channelMetaOf = function channelMetaOf(
|
|
2260
|
+
var channelMetaOf = function channelMetaOf(_ref1) {
|
|
2040
2261
|
var _schema$actions4;
|
|
2041
|
-
var schema =
|
|
2042
|
-
action =
|
|
2262
|
+
var schema = _ref1.schema,
|
|
2263
|
+
action = _ref1.action;
|
|
2043
2264
|
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({
|
|
2044
2265
|
schema: schema,
|
|
2045
2266
|
action: action
|
|
2046
2267
|
})]) || {};
|
|
2047
2268
|
};
|
|
2048
|
-
var actionHasConfig = function actionHasConfig(
|
|
2269
|
+
var actionHasConfig = function actionHasConfig(_ref10) {
|
|
2049
2270
|
var _schema$actions5, _schema$actions6;
|
|
2050
|
-
var schema =
|
|
2051
|
-
action =
|
|
2271
|
+
var schema = _ref10.schema,
|
|
2272
|
+
action = _ref10.action;
|
|
2052
2273
|
var meta = channelMetaOf({
|
|
2053
2274
|
schema: schema,
|
|
2054
2275
|
action: action
|
|
@@ -2062,10 +2283,10 @@ var actionHasConfig = function actionHasConfig(_ref0) {
|
|
|
2062
2283
|
if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
|
|
2063
2284
|
return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
|
|
2064
2285
|
};
|
|
2065
|
-
var recipientsFor = function recipientsFor(
|
|
2286
|
+
var recipientsFor = function recipientsFor(_ref11) {
|
|
2066
2287
|
var _schema$actions7, _schema$actions8;
|
|
2067
|
-
var schema =
|
|
2068
|
-
action =
|
|
2288
|
+
var schema = _ref11.schema,
|
|
2289
|
+
action = _ref11.action;
|
|
2069
2290
|
var channel = channelOf({
|
|
2070
2291
|
schema: schema,
|
|
2071
2292
|
action: action
|
|
@@ -2080,11 +2301,11 @@ var recipientsFor = function recipientsFor(_ref1) {
|
|
|
2080
2301
|
if (option !== null && option !== void 0 && option.recipients) return option.recipients;
|
|
2081
2302
|
return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
|
|
2082
2303
|
};
|
|
2083
|
-
var nextTriggers = function nextTriggers(
|
|
2304
|
+
var nextTriggers = function nextTriggers(_ref12) {
|
|
2084
2305
|
var _schema$triggers;
|
|
2085
|
-
var schema =
|
|
2086
|
-
rule =
|
|
2087
|
-
value =
|
|
2306
|
+
var schema = _ref12.schema,
|
|
2307
|
+
rule = _ref12.rule,
|
|
2308
|
+
value = _ref12.value;
|
|
2088
2309
|
if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
|
|
2089
2310
|
var names = pluck("name", rule.triggers);
|
|
2090
2311
|
return names.includes(value) ? removeBy({
|
|
@@ -2097,12 +2318,12 @@ var nextTriggers = function nextTriggers(_ref10) {
|
|
|
2097
2318
|
name: value
|
|
2098
2319
|
})];
|
|
2099
2320
|
};
|
|
2100
|
-
var nextConditionAt = function nextConditionAt(
|
|
2321
|
+
var nextConditionAt = function nextConditionAt(_ref13) {
|
|
2101
2322
|
var _field$allowMatching;
|
|
2102
|
-
var schema =
|
|
2103
|
-
rule =
|
|
2104
|
-
index =
|
|
2105
|
-
value =
|
|
2323
|
+
var schema = _ref13.schema,
|
|
2324
|
+
rule = _ref13.rule,
|
|
2325
|
+
index = _ref13.index,
|
|
2326
|
+
value = _ref13.value;
|
|
2106
2327
|
var field = findField({
|
|
2107
2328
|
schema: schema,
|
|
2108
2329
|
value: value
|
|
@@ -2121,12 +2342,12 @@ var nextConditionAt = function nextConditionAt(_ref11) {
|
|
|
2121
2342
|
metadata: {}
|
|
2122
2343
|
});
|
|
2123
2344
|
};
|
|
2124
|
-
var nextActionAt = function nextActionAt(
|
|
2345
|
+
var nextActionAt = function nextActionAt(_ref14) {
|
|
2125
2346
|
var _schema$actions9;
|
|
2126
|
-
var schema =
|
|
2127
|
-
rule =
|
|
2128
|
-
index =
|
|
2129
|
-
value =
|
|
2347
|
+
var schema = _ref14.schema,
|
|
2348
|
+
rule = _ref14.rule,
|
|
2349
|
+
index = _ref14.index,
|
|
2350
|
+
value = _ref14.value;
|
|
2130
2351
|
if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
|
|
2131
2352
|
var option = findActionOption({
|
|
2132
2353
|
schema: schema,
|
|
@@ -2184,11 +2405,11 @@ var nextActionAt = function nextActionAt(_ref12) {
|
|
|
2184
2405
|
metadata: channelChanged ? {} : prev.metadata
|
|
2185
2406
|
});
|
|
2186
2407
|
};
|
|
2187
|
-
var appendScopeItem = function appendScopeItem(
|
|
2408
|
+
var appendScopeItem = function appendScopeItem(_ref15) {
|
|
2188
2409
|
var _sc$requiresPhone;
|
|
2189
|
-
var schema =
|
|
2190
|
-
rule =
|
|
2191
|
-
value =
|
|
2410
|
+
var schema = _ref15.schema,
|
|
2411
|
+
rule = _ref15.rule,
|
|
2412
|
+
value = _ref15.value;
|
|
2192
2413
|
var sc = schema.scope || {};
|
|
2193
2414
|
var option = (sc.options || []).find(function (candidate) {
|
|
2194
2415
|
return optionValue(candidate) === value;
|
|
@@ -2205,12 +2426,12 @@ var appendScopeItem = function appendScopeItem(_ref13) {
|
|
|
2205
2426
|
phoneField: phoneFields[0].value
|
|
2206
2427
|
}) : option;
|
|
2207
2428
|
};
|
|
2208
|
-
var nextActionRecipientAt = function nextActionRecipientAt(
|
|
2429
|
+
var nextActionRecipientAt = function nextActionRecipientAt(_ref16) {
|
|
2209
2430
|
var _schema$actions1;
|
|
2210
|
-
var schema =
|
|
2211
|
-
rule =
|
|
2212
|
-
index =
|
|
2213
|
-
value =
|
|
2431
|
+
var schema = _ref16.schema,
|
|
2432
|
+
rule = _ref16.rule,
|
|
2433
|
+
index = _ref16.index,
|
|
2434
|
+
value = _ref16.value;
|
|
2214
2435
|
var prev = actionAt({
|
|
2215
2436
|
rule: rule,
|
|
2216
2437
|
index: index
|
|
@@ -2227,12 +2448,13 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
|
|
|
2227
2448
|
}) : value
|
|
2228
2449
|
});
|
|
2229
2450
|
};
|
|
2230
|
-
var descriptorFor = function descriptorFor(
|
|
2451
|
+
var descriptorFor = function descriptorFor(_ref17) {
|
|
2231
2452
|
var _schema$actor2;
|
|
2232
|
-
var anchor =
|
|
2233
|
-
schema =
|
|
2234
|
-
rule =
|
|
2235
|
-
index =
|
|
2453
|
+
var anchor = _ref17.anchor,
|
|
2454
|
+
schema = _ref17.schema,
|
|
2455
|
+
rule = _ref17.rule,
|
|
2456
|
+
index = _ref17.index,
|
|
2457
|
+
stepKey = _ref17.stepKey;
|
|
2236
2458
|
switch (anchor) {
|
|
2237
2459
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2238
2460
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2363,13 +2585,18 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2363
2585
|
subtitle: isSwap ? t("neetoRules.builder.panes.actionSwapSubtitle") : t("neetoRules.builder.panes.actionAddSubtitle"),
|
|
2364
2586
|
cascade: true,
|
|
2365
2587
|
options: sourceOptions.map(function (option) {
|
|
2588
|
+
var _option$disabled;
|
|
2366
2589
|
var value = optionValue(option);
|
|
2367
2590
|
var meta = channelMetaFor(value);
|
|
2368
2591
|
return {
|
|
2369
2592
|
label: isSwap ? meta.channelLabel || option.label : option.label,
|
|
2370
2593
|
value: value,
|
|
2371
2594
|
category: option.category,
|
|
2372
|
-
|
|
2595
|
+
// Hosts mark unavailable actions with isDisabled; without carrying
|
|
2596
|
+
// the reason across, the picker disables them with no explanation.
|
|
2597
|
+
disabled: !!((_option$disabled = option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : option.isDisabled),
|
|
2598
|
+
disabledReason: option.disabledReason,
|
|
2599
|
+
disabledPopover: option.disabledPopover,
|
|
2373
2600
|
icon: (isSwap ? meta.icon : option.icon) || option.icon
|
|
2374
2601
|
};
|
|
2375
2602
|
}),
|
|
@@ -2417,7 +2644,33 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2417
2644
|
selectedValues: [recipientOf({
|
|
2418
2645
|
schema: schema,
|
|
2419
2646
|
action: action
|
|
2420
|
-
})]
|
|
2647
|
+
})],
|
|
2648
|
+
// Confirming a recipient always offers Continue; whether that chains
|
|
2649
|
+
// onward or just closes is decided by continueTargetFor.
|
|
2650
|
+
cascade: true
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2654
|
+
{
|
|
2655
|
+
var _action = actionAt({
|
|
2656
|
+
rule: rule,
|
|
2657
|
+
index: index
|
|
2658
|
+
});
|
|
2659
|
+
var step = stepAt({
|
|
2660
|
+
schema: schema,
|
|
2661
|
+
rule: rule,
|
|
2662
|
+
index: index,
|
|
2663
|
+
stepKey: stepKey
|
|
2664
|
+
}) || {};
|
|
2665
|
+
return {
|
|
2666
|
+
title: step.title || t("neetoRules.builder.panes.stepTitle"),
|
|
2667
|
+
subtitle: step.subtitle,
|
|
2668
|
+
options: normalizeOptions(step.options),
|
|
2669
|
+
selectedValues: [stepValueOf({
|
|
2670
|
+
action: _action,
|
|
2671
|
+
step: step
|
|
2672
|
+
})],
|
|
2673
|
+
cascade: true
|
|
2421
2674
|
};
|
|
2422
2675
|
}
|
|
2423
2676
|
case BUILDER_ANCHORS.SCOPE:
|
|
@@ -2434,14 +2687,16 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2434
2687
|
subtitle: sc.paneSubtitle || t("neetoRules.builder.panes.scopeSubtitle"),
|
|
2435
2688
|
multi: true,
|
|
2436
2689
|
options: (sc.options || []).map(function (option) {
|
|
2690
|
+
var _option$disabled2;
|
|
2437
2691
|
var value = optionValue(option);
|
|
2438
2692
|
var blockedNoPhone = requiresPhone && option.hasPhoneField === false;
|
|
2439
2693
|
var isSelected = selected.includes(value);
|
|
2440
2694
|
return {
|
|
2441
2695
|
label: option.label,
|
|
2442
2696
|
value: value,
|
|
2443
|
-
disabled: (!!option.disabled || blockedNoPhone) && !isSelected,
|
|
2444
|
-
disabledReason: blockedNoPhone
|
|
2697
|
+
disabled: (!!((_option$disabled2 = option.disabled) !== null && _option$disabled2 !== void 0 ? _option$disabled2 : option.isDisabled) || blockedNoPhone) && !isSelected,
|
|
2698
|
+
disabledReason: blockedNoPhone ? sc.disabledReason : option.disabledReason,
|
|
2699
|
+
disabledPopover: option.disabledPopover,
|
|
2445
2700
|
disabledTooltip: blockedNoPhone && sc.disabledTooltip
|
|
2446
2701
|
};
|
|
2447
2702
|
}),
|
|
@@ -2487,13 +2742,14 @@ var descriptorFor = function descriptorFor(_ref15) {
|
|
|
2487
2742
|
};
|
|
2488
2743
|
}
|
|
2489
2744
|
};
|
|
2490
|
-
var commitFor = function commitFor(
|
|
2491
|
-
var anchor =
|
|
2492
|
-
schema =
|
|
2493
|
-
rule =
|
|
2494
|
-
index =
|
|
2495
|
-
|
|
2496
|
-
|
|
2745
|
+
var commitFor = function commitFor(_ref18) {
|
|
2746
|
+
var anchor = _ref18.anchor,
|
|
2747
|
+
schema = _ref18.schema,
|
|
2748
|
+
rule = _ref18.rule,
|
|
2749
|
+
index = _ref18.index,
|
|
2750
|
+
stepKey = _ref18.stepKey,
|
|
2751
|
+
value = _ref18.value,
|
|
2752
|
+
helpers = _ref18.helpers;
|
|
2497
2753
|
var setTriggers = helpers.setTriggers,
|
|
2498
2754
|
setPerformer = helpers.setPerformer,
|
|
2499
2755
|
setConditionMode = helpers.setConditionMode,
|
|
@@ -2564,6 +2820,11 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2564
2820
|
}));
|
|
2565
2821
|
return "stay";
|
|
2566
2822
|
}
|
|
2823
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2824
|
+
{
|
|
2825
|
+
setFieldValue("".concat(fieldKeys.actions, ".value.").concat(index, ".metadata.").concat(stepKey), value);
|
|
2826
|
+
return "stay";
|
|
2827
|
+
}
|
|
2567
2828
|
case BUILDER_ANCHORS.SCOPE:
|
|
2568
2829
|
{
|
|
2569
2830
|
var key = fieldKeys.scope;
|
|
@@ -2593,12 +2854,14 @@ var commitFor = function commitFor(_ref16) {
|
|
|
2593
2854
|
return "close";
|
|
2594
2855
|
}
|
|
2595
2856
|
};
|
|
2596
|
-
var continueTargetFor = function continueTargetFor(
|
|
2857
|
+
var continueTargetFor = function continueTargetFor(_ref19) {
|
|
2597
2858
|
var _schema$actor3;
|
|
2598
|
-
var anchor =
|
|
2599
|
-
schema =
|
|
2600
|
-
rule =
|
|
2601
|
-
index =
|
|
2859
|
+
var anchor = _ref19.anchor,
|
|
2860
|
+
schema = _ref19.schema,
|
|
2861
|
+
rule = _ref19.rule,
|
|
2862
|
+
index = _ref19.index,
|
|
2863
|
+
stepKey = _ref19.stepKey,
|
|
2864
|
+
configPending = _ref19.configPending;
|
|
2602
2865
|
switch (anchor) {
|
|
2603
2866
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2604
2867
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2654,38 +2917,77 @@ var continueTargetFor = function continueTargetFor(_ref17) {
|
|
|
2654
2917
|
}
|
|
2655
2918
|
};
|
|
2656
2919
|
}
|
|
2657
|
-
|
|
2920
|
+
|
|
2921
|
+
// Reached here only because the action has no config yet — its name is
|
|
2922
|
+
// still unresolved — so the recipient pane owes us that step afterwards.
|
|
2923
|
+
if (channelMetaOf({
|
|
2658
2924
|
schema: schema,
|
|
2659
2925
|
action: action
|
|
2660
|
-
}).needsRecipient
|
|
2661
|
-
|
|
2926
|
+
}).needsRecipient) {
|
|
2927
|
+
return {
|
|
2928
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
2929
|
+
data: {
|
|
2930
|
+
index: index,
|
|
2931
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT,
|
|
2932
|
+
configPending: true
|
|
2933
|
+
}
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
return stepTargetAfter({
|
|
2937
|
+
schema: schema,
|
|
2938
|
+
rule: rule,
|
|
2939
|
+
index: index
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2943
|
+
{
|
|
2944
|
+
// Only chain back to config when it was skipped on the way in; arriving
|
|
2945
|
+
// from the config pane or from the token means config is already done.
|
|
2946
|
+
var _action2 = actionAt({
|
|
2947
|
+
rule: rule,
|
|
2948
|
+
index: index
|
|
2949
|
+
});
|
|
2950
|
+
return configPending && actionHasConfig({
|
|
2951
|
+
schema: schema,
|
|
2952
|
+
action: _action2
|
|
2953
|
+
}) ? {
|
|
2954
|
+
type: BUILDER_PANEL_TYPES.ACTION_CONFIG,
|
|
2662
2955
|
data: {
|
|
2663
2956
|
index: index,
|
|
2664
|
-
anchor: BUILDER_ANCHORS.
|
|
2957
|
+
anchor: BUILDER_ANCHORS.ACTION_CONFIG
|
|
2665
2958
|
}
|
|
2666
|
-
} :
|
|
2959
|
+
} : stepTargetAfter({
|
|
2960
|
+
schema: schema,
|
|
2961
|
+
rule: rule,
|
|
2962
|
+
index: index
|
|
2963
|
+
});
|
|
2667
2964
|
}
|
|
2668
|
-
case BUILDER_ANCHORS.
|
|
2669
|
-
return
|
|
2965
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
2966
|
+
return stepTargetAfter({
|
|
2967
|
+
schema: schema,
|
|
2968
|
+
rule: rule,
|
|
2969
|
+
index: index,
|
|
2970
|
+
stepKey: stepKey
|
|
2971
|
+
});
|
|
2670
2972
|
default:
|
|
2671
2973
|
return null;
|
|
2672
2974
|
}
|
|
2673
2975
|
};
|
|
2674
|
-
var replaceAt = function replaceAt(
|
|
2675
|
-
var list =
|
|
2676
|
-
index =
|
|
2677
|
-
item =
|
|
2976
|
+
var replaceAt = function replaceAt(_ref20) {
|
|
2977
|
+
var list = _ref20.list,
|
|
2978
|
+
index = _ref20.index,
|
|
2979
|
+
item = _ref20.item;
|
|
2678
2980
|
var next = _toConsumableArray(list);
|
|
2679
2981
|
// eslint-disable-next-line security/detect-object-injection
|
|
2680
2982
|
next[index] = item;
|
|
2681
2983
|
return next;
|
|
2682
2984
|
};
|
|
2683
|
-
var applyPreview = function applyPreview(
|
|
2684
|
-
var rule =
|
|
2685
|
-
schema =
|
|
2686
|
-
anchor =
|
|
2687
|
-
index =
|
|
2688
|
-
value =
|
|
2985
|
+
var applyPreview = function applyPreview(_ref21) {
|
|
2986
|
+
var rule = _ref21.rule,
|
|
2987
|
+
schema = _ref21.schema,
|
|
2988
|
+
anchor = _ref21.anchor,
|
|
2989
|
+
index = _ref21.index,
|
|
2990
|
+
value = _ref21.value;
|
|
2689
2991
|
switch (anchor) {
|
|
2690
2992
|
case BUILDER_ANCHORS.TRIGGER_ADD:
|
|
2691
2993
|
case BUILDER_ANCHORS.TRIGGER_REPLACE:
|
|
@@ -2782,7 +3084,7 @@ var applyPreview = function applyPreview(_ref19) {
|
|
|
2782
3084
|
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; }
|
|
2783
3085
|
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; }
|
|
2784
3086
|
var Canvas = function Canvas(_ref) {
|
|
2785
|
-
var _schema$scope, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
3087
|
+
var _schema$actor2, _ref6, _actorOptions$0$value, _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
|
|
2786
3088
|
var schema = _ref.schema;
|
|
2787
3089
|
var _useTranslation = useTranslation(),
|
|
2788
3090
|
t = _useTranslation.t;
|
|
@@ -2837,7 +3139,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
2837
3139
|
useEffect(function () {
|
|
2838
3140
|
if (submitCount <= lastSubmitCount.current) return undefined;
|
|
2839
3141
|
lastSubmitCount.current = submitCount;
|
|
2840
|
-
if (isEmpty(flatErrors) && isRuleComplete(
|
|
3142
|
+
if (isEmpty(flatErrors) && isRuleComplete({
|
|
3143
|
+
rule: rule,
|
|
3144
|
+
schema: schema
|
|
3145
|
+
}) && isEmpty(invalidScopeIndexes({
|
|
2841
3146
|
rule: rule,
|
|
2842
3147
|
schema: schema
|
|
2843
3148
|
})) && isEmpty(invalidScopePhoneFieldIndexes({
|
|
@@ -2866,33 +3171,25 @@ var Canvas = function Canvas(_ref) {
|
|
|
2866
3171
|
});
|
|
2867
3172
|
};
|
|
2868
3173
|
var matchesInvalid = function matchesInvalid(_ref4) {
|
|
2869
|
-
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;
|
|
2870
3174
|
var type = _ref4.type,
|
|
2871
|
-
index = _ref4.index
|
|
3175
|
+
index = _ref4.index,
|
|
3176
|
+
stepKey = _ref4.stepKey;
|
|
2872
3177
|
var conditionMeta = "".concat(fieldKeys.conditions, ".value.").concat(index, ".metadata");
|
|
2873
3178
|
var actionMeta = "".concat(fieldKeys.actions, ".value.").concat(index, ".metadata");
|
|
2874
3179
|
// eslint-disable-next-line security/detect-object-injection
|
|
2875
3180
|
var actionItem = rule.actions[index] || {};
|
|
2876
|
-
var
|
|
2877
|
-
|
|
2878
|
-
channel: channel,
|
|
2879
|
-
name: actionMeta,
|
|
2880
|
-
action: actionItem
|
|
2881
|
-
}));
|
|
2882
|
-
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, {
|
|
2883
|
-
channel: channel,
|
|
2884
|
-
recipient: actionItem.recipient,
|
|
2885
|
-
name: actionMeta,
|
|
3181
|
+
var steps = actionStepsOf({
|
|
3182
|
+
schema: schema,
|
|
2886
3183
|
action: actionItem
|
|
2887
|
-
}));
|
|
2888
|
-
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));
|
|
2889
|
-
var recipientConfig = [].concat(_toConsumableArray((((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
|
|
2890
|
-
return option.recipients || [];
|
|
2891
|
-
})), _toConsumableArray(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [])).find(function (item) {
|
|
2892
|
-
var _item$value;
|
|
2893
|
-
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === actionItem.recipient;
|
|
2894
3184
|
});
|
|
2895
|
-
var
|
|
3185
|
+
var stepKeys = steps.map(function (step) {
|
|
3186
|
+
return step.key;
|
|
3187
|
+
});
|
|
3188
|
+
var recipientFields = recipientOwnedFields({
|
|
3189
|
+
schema: schema,
|
|
3190
|
+
action: actionItem,
|
|
3191
|
+
name: actionMeta
|
|
3192
|
+
});
|
|
2896
3193
|
switch (type) {
|
|
2897
3194
|
case BUILDER_ANCHORS.TRIGGER_ACTOR:
|
|
2898
3195
|
{
|
|
@@ -2923,8 +3220,20 @@ var Canvas = function Canvas(_ref) {
|
|
|
2923
3220
|
case BUILDER_ANCHORS.ACTION_CONFIG:
|
|
2924
3221
|
return hasErrorAt({
|
|
2925
3222
|
prefix: actionMeta,
|
|
2926
|
-
exclude: recipientFields
|
|
3223
|
+
exclude: [].concat(_toConsumableArray(recipientFields), _toConsumableArray(stepKeys))
|
|
2927
3224
|
});
|
|
3225
|
+
case BUILDER_ANCHORS.ACTION_STEP:
|
|
3226
|
+
{
|
|
3227
|
+
var step = steps.find(function (item) {
|
|
3228
|
+
return item.key === stepKey;
|
|
3229
|
+
});
|
|
3230
|
+
return hasErrorAt({
|
|
3231
|
+
prefix: "".concat(actionMeta, ".").concat(stepKey)
|
|
3232
|
+
}) || !!(step !== null && step !== void 0 && step.required) && !stepValueOf({
|
|
3233
|
+
action: actionItem,
|
|
3234
|
+
step: step
|
|
3235
|
+
});
|
|
3236
|
+
}
|
|
2928
3237
|
case BUILDER_ANCHORS.ACTION_RECIPIENT:
|
|
2929
3238
|
return hasErrorAt({
|
|
2930
3239
|
prefix: "".concat(fieldKeys.actions, ".value.").concat(index, ".name")
|
|
@@ -3001,7 +3310,15 @@ var Canvas = function Canvas(_ref) {
|
|
|
3001
3310
|
});
|
|
3002
3311
|
setDelay(null);
|
|
3003
3312
|
};
|
|
3004
|
-
|
|
3313
|
+
|
|
3314
|
+
// An actor with a single choice is not a choice; leaving it unset only makes
|
|
3315
|
+
// the user open a one-option pane to say the obvious.
|
|
3316
|
+
var actorOptions = schema !== null && schema !== void 0 && (_schema$actor2 = schema.actor) !== null && _schema$actor2 !== void 0 && _schema$actor2.enabled ? schema.actor.options || [] : [];
|
|
3317
|
+
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;
|
|
3318
|
+
var isTriggerSet = isTriggerSatisfied({
|
|
3319
|
+
rule: rule,
|
|
3320
|
+
schema: schema
|
|
3321
|
+
});
|
|
3005
3322
|
var hasAction = rule.actions.some(function (action) {
|
|
3006
3323
|
return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
|
|
3007
3324
|
});
|
|
@@ -3020,11 +3337,16 @@ var Canvas = function Canvas(_ref) {
|
|
|
3020
3337
|
rule: rule
|
|
3021
3338
|
});
|
|
3022
3339
|
var canAddCondition = isNotEmpty(conditionFields);
|
|
3340
|
+
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;
|
|
3023
3341
|
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) || [];
|
|
3024
3342
|
var hasLeadTimeTrigger = rule.triggers.some(function (trigger) {
|
|
3025
3343
|
return leadTimeAppliesTo.includes(trigger.name);
|
|
3026
3344
|
});
|
|
3027
3345
|
var isDelayEnabled = (schema === null || schema === void 0 || (_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.enabled) && !hasLeadTimeTrigger;
|
|
3346
|
+
useEffect(function () {
|
|
3347
|
+
if (soleActorOption && !rule.performer) setPerformer(soleActorOption);
|
|
3348
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3349
|
+
}, [soleActorOption, rule.performer]);
|
|
3028
3350
|
useEffect(function () {
|
|
3029
3351
|
if (hasLeadTimeTrigger && rule.delay) setDelay(null);
|
|
3030
3352
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3041,10 +3363,10 @@ var Canvas = function Canvas(_ref) {
|
|
|
3041
3363
|
});
|
|
3042
3364
|
};
|
|
3043
3365
|
var handleClearTrigger = function handleClearTrigger() {
|
|
3044
|
-
var _schema$
|
|
3366
|
+
var _schema$actor3;
|
|
3045
3367
|
clearTriggers();
|
|
3046
3368
|
// Hosts without an actor pane can never re-set it, and null fails its validation.
|
|
3047
|
-
if ((_schema$
|
|
3369
|
+
if ((_schema$actor3 = schema.actor) !== null && _schema$actor3 !== void 0 && _schema$actor3.enabled) setPerformer(soleActorOption);
|
|
3048
3370
|
clearConditions();
|
|
3049
3371
|
setDelay(null);
|
|
3050
3372
|
clearActions();
|
|
@@ -3072,7 +3394,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3072
3394
|
className: "neeto-rules-builder nrb-atoms",
|
|
3073
3395
|
children: /*#__PURE__*/jsxs("div", {
|
|
3074
3396
|
className: "mb-canvas neeto-rules-main-card",
|
|
3075
|
-
children: [/*#__PURE__*/jsx(WhenBlock, {
|
|
3397
|
+
children: [renderSlot("beforeWhen"), /*#__PURE__*/jsx(WhenBlock, {
|
|
3076
3398
|
isActive: isActive,
|
|
3077
3399
|
isInvalid: isInvalid,
|
|
3078
3400
|
schema: schema,
|
|
@@ -3090,11 +3412,11 @@ var Canvas = function Canvas(_ref) {
|
|
|
3090
3412
|
schema: schema,
|
|
3091
3413
|
key: (_condition$id = condition.id) !== null && _condition$id !== void 0 ? _condition$id : index,
|
|
3092
3414
|
rule: displayRule,
|
|
3093
|
-
onRemove: function onRemove() {
|
|
3094
|
-
return handleRemoveCondition(index);
|
|
3095
|
-
},
|
|
3096
3415
|
onToken: openPane,
|
|
3097
|
-
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition
|
|
3416
|
+
onAddCondition: canAddCondition && index === displayRule.conditions.length - 1 && handleAddCondition,
|
|
3417
|
+
onRemove: canRemoveCondition && function () {
|
|
3418
|
+
return handleRemoveCondition(index);
|
|
3419
|
+
}
|
|
3098
3420
|
});
|
|
3099
3421
|
}), renderSlot("afterConditions"), /*#__PURE__*/jsx(Connector, {
|
|
3100
3422
|
active: isTriggerSet
|
|
@@ -3166,6 +3488,7 @@ var Canvas = function Canvas(_ref) {
|
|
|
3166
3488
|
|
|
3167
3489
|
var ACTION_CONFIG_TYPES = {
|
|
3168
3490
|
emailChannel: "emailChannel",
|
|
3491
|
+
sendToApi: "sendToApi",
|
|
3169
3492
|
multiSelect: "multiSelect",
|
|
3170
3493
|
dropdown: "dropdown",
|
|
3171
3494
|
note: "note",
|
|
@@ -3192,7 +3515,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3192
3515
|
option = _ref.option,
|
|
3193
3516
|
action = _ref.action,
|
|
3194
3517
|
_ref$searchTerm = _ref.searchTerm,
|
|
3195
|
-
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm
|
|
3518
|
+
searchTerm = _ref$searchTerm === void 0 ? "" : _ref$searchTerm,
|
|
3519
|
+
_ref$hasRecipientFiel = _ref.hasRecipientField,
|
|
3520
|
+
hasRecipientField = _ref$hasRecipientFiel === void 0 ? false : _ref$hasRecipientFiel;
|
|
3196
3521
|
var _useTranslation = useTranslation(),
|
|
3197
3522
|
t = _useTranslation.t;
|
|
3198
3523
|
var _useFormikContext = useFormikContext(),
|
|
@@ -3234,19 +3559,42 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3234
3559
|
"data-testid": "pane-no-matches",
|
|
3235
3560
|
children: t("neetoRules.builder.noMatches")
|
|
3236
3561
|
});
|
|
3562
|
+
if (type === ACTION_CONFIG_TYPES.sendToApi) {
|
|
3563
|
+
return /*#__PURE__*/jsx(ApiFields, {
|
|
3564
|
+
name: name,
|
|
3565
|
+
selectedField: option
|
|
3566
|
+
});
|
|
3567
|
+
}
|
|
3237
3568
|
if (type === ACTION_CONFIG_TYPES.emailChannel) {
|
|
3238
|
-
var _getIn, _action$metadata;
|
|
3569
|
+
var _getIn, _getIn2, _action$metadata;
|
|
3239
3570
|
var subjectPath = "".concat(name, ".subject");
|
|
3240
3571
|
var bodyPath = "".concat(name, ".body");
|
|
3572
|
+
// Hosts whose email action picks its recipient from a list keep that
|
|
3573
|
+
// choice in the same pane as the message.
|
|
3574
|
+
var hasRecipientList = isNotEmpty(options) && !hasRecipientField;
|
|
3241
3575
|
return /*#__PURE__*/jsxs("div", {
|
|
3242
3576
|
className: "flex flex-col gap-4",
|
|
3243
|
-
children: [
|
|
3577
|
+
children: [hasRecipientList && /*#__PURE__*/jsx(Select, {
|
|
3578
|
+
options: options,
|
|
3579
|
+
required: true,
|
|
3580
|
+
error: fieldError(valuePath),
|
|
3581
|
+
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3582
|
+
size: "large",
|
|
3583
|
+
value: (_getIn = getIn(values, valuePath)) !== null && _getIn !== void 0 ? _getIn : undefined,
|
|
3584
|
+
label: (option === null || option === void 0 ? void 0 : option.recipientLabel) || t("neetoRules.builder.config.recipient"),
|
|
3585
|
+
onBlur: function onBlur() {
|
|
3586
|
+
return setFieldTouched(valuePath, true);
|
|
3587
|
+
},
|
|
3588
|
+
onChange: function onChange(value) {
|
|
3589
|
+
return setFieldValue(valuePath, value);
|
|
3590
|
+
}
|
|
3591
|
+
}), !(option !== null && option !== void 0 && option.hideSubject) && /*#__PURE__*/jsx(Input, {
|
|
3244
3592
|
required: true,
|
|
3245
3593
|
error: fieldError(subjectPath),
|
|
3246
3594
|
label: t("neetoRules.builder.config.subject"),
|
|
3247
3595
|
placeholder: t("neetoRules.builder.config.subjectPlaceholder"),
|
|
3248
3596
|
size: "large",
|
|
3249
|
-
value: (
|
|
3597
|
+
value: (_getIn2 = getIn(values, subjectPath)) !== null && _getIn2 !== void 0 ? _getIn2 : "",
|
|
3250
3598
|
onBlur: function onBlur() {
|
|
3251
3599
|
return setFieldTouched(subjectPath, true);
|
|
3252
3600
|
},
|
|
@@ -3298,9 +3646,6 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3298
3646
|
error: fieldError(valuePath),
|
|
3299
3647
|
orientation: "vertical",
|
|
3300
3648
|
value: String(_current !== null && _current !== void 0 ? _current : ""),
|
|
3301
|
-
onBlur: function onBlur() {
|
|
3302
|
-
return setFieldTouched(valuePath, true);
|
|
3303
|
-
},
|
|
3304
3649
|
onValueChange: function onValueChange(value) {
|
|
3305
3650
|
var picked = options.find(function (item) {
|
|
3306
3651
|
return String(item.value) === value;
|
|
@@ -3338,14 +3683,14 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3338
3683
|
});
|
|
3339
3684
|
}
|
|
3340
3685
|
if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
|
|
3341
|
-
var
|
|
3686
|
+
var _getIn3, _getIn4;
|
|
3342
3687
|
return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsx(Input, {
|
|
3343
3688
|
required: true,
|
|
3344
3689
|
error: fieldError(valuePath),
|
|
3345
3690
|
label: t("neetoRules.builder.config.value"),
|
|
3346
3691
|
size: "large",
|
|
3347
3692
|
type: "number",
|
|
3348
|
-
value: (
|
|
3693
|
+
value: (_getIn3 = getIn(values, valuePath)) !== null && _getIn3 !== void 0 ? _getIn3 : "",
|
|
3349
3694
|
onBlur: function onBlur() {
|
|
3350
3695
|
return setFieldTouched(valuePath, true);
|
|
3351
3696
|
},
|
|
@@ -3358,7 +3703,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3358
3703
|
label: t("neetoRules.builder.config.message"),
|
|
3359
3704
|
rows: 5,
|
|
3360
3705
|
size: "large",
|
|
3361
|
-
value: (
|
|
3706
|
+
value: (_getIn4 = getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
|
|
3362
3707
|
onBlur: function onBlur() {
|
|
3363
3708
|
return setFieldTouched(valuePath, true);
|
|
3364
3709
|
},
|
|
@@ -3368,7 +3713,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3368
3713
|
});
|
|
3369
3714
|
}
|
|
3370
3715
|
if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
|
|
3371
|
-
var
|
|
3716
|
+
var _getIn5;
|
|
3372
3717
|
return /*#__PURE__*/jsxs("div", {
|
|
3373
3718
|
className: "flex flex-col gap-2",
|
|
3374
3719
|
children: [/*#__PURE__*/jsx(Input, {
|
|
@@ -3377,7 +3722,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
|
|
|
3377
3722
|
label: t("neetoRules.builder.config.value"),
|
|
3378
3723
|
placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
|
|
3379
3724
|
size: "large",
|
|
3380
|
-
value: (
|
|
3725
|
+
value: (_getIn5 = getIn(values, valuePath)) !== null && _getIn5 !== void 0 ? _getIn5 : "",
|
|
3381
3726
|
onBlur: function onBlur() {
|
|
3382
3727
|
return setFieldTouched(valuePath, true);
|
|
3383
3728
|
},
|
|
@@ -3488,7 +3833,7 @@ var usePaneValidation = function usePaneValidation(prefix) {
|
|
|
3488
3833
|
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 }; })(); }
|
|
3489
3834
|
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); }
|
|
3490
3835
|
var ConfigPane = function ConfigPane(_ref) {
|
|
3491
|
-
var _schema$actions, _schema$actions$optio, _schema$actions2, _schema$actions2$opti, _schema$actions3, _schema$
|
|
3836
|
+
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;
|
|
3492
3837
|
var schema = _ref.schema,
|
|
3493
3838
|
index = _ref.index;
|
|
3494
3839
|
var _useTranslation = useTranslation(),
|
|
@@ -3520,17 +3865,28 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3520
3865
|
mediumLabel = _actionParts.mediumLabel,
|
|
3521
3866
|
needsRecipient = _actionParts.needsRecipient,
|
|
3522
3867
|
configTitle = _actionParts.configTitle,
|
|
3523
|
-
configSubtitle = _actionParts.configSubtitle
|
|
3868
|
+
configSubtitle = _actionParts.configSubtitle,
|
|
3869
|
+
steps = _actionParts.steps;
|
|
3524
3870
|
var name = "".concat(base, ".metadata");
|
|
3525
3871
|
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;
|
|
3872
|
+
|
|
3873
|
+
// When the chosen recipient declares its own field, the recipient pane
|
|
3874
|
+
// renders it; showing the same picker here too would just duplicate it.
|
|
3875
|
+
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;
|
|
3876
|
+
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) {
|
|
3877
|
+
return o.recipients || [];
|
|
3878
|
+
})).find(function (item) {
|
|
3879
|
+
var _item$value;
|
|
3880
|
+
return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipientValue;
|
|
3881
|
+
})) !== null && _concat$find !== void 0 && _concat$find.field);
|
|
3526
3882
|
var isSms = SMS_TYPES.includes(flatOption === null || flatOption === void 0 ? void 0 : flatOption.type);
|
|
3527
3883
|
var disabledReason = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.isDisabled) && flatOption.disabledReason;
|
|
3528
|
-
var hostRenderConfig = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.renderConfig) || (flatOption === null || flatOption === void 0 ? void 0 : flatOption.component) || ((_schema$
|
|
3884
|
+
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);
|
|
3529
3885
|
var showSearch = normalizeOptions(flatOption === null || flatOption === void 0 ? void 0 : flatOption.dropdownOptions).length >= PANE_SEARCH_THRESHOLD;
|
|
3530
3886
|
var shouldAdvanceToRecipient = !!needsRecipient;
|
|
3531
3887
|
var _usePaneValidation = usePaneValidation(name),
|
|
3532
3888
|
validate = _usePaneValidation.validate;
|
|
3533
|
-
var channelRepName = (_schema$
|
|
3889
|
+
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;
|
|
3534
3890
|
var unnamedOnOpen = useRef(!action.name);
|
|
3535
3891
|
useEffect(function () {
|
|
3536
3892
|
if (!unnamedOnOpen.current || !channelRepName) return undefined;
|
|
@@ -3564,11 +3920,21 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3564
3920
|
}) || (option === null || option === void 0 ? void 0 : option.label) || t("neetoRules.builder.setUpAction");
|
|
3565
3921
|
var handleContinue = /*#__PURE__*/function () {
|
|
3566
3922
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
3923
|
+
var owned, next;
|
|
3567
3924
|
return _regenerator().w(function (_context) {
|
|
3568
3925
|
while (1) switch (_context.n) {
|
|
3569
3926
|
case 0:
|
|
3927
|
+
// A pane only answers for what it renders: the recipient pane owns its
|
|
3928
|
+
// storage fields and each step owns its key, so neither blocks Continue.
|
|
3929
|
+
owned = [].concat(_toConsumableArray(recipientOwnedFields({
|
|
3930
|
+
schema: schema,
|
|
3931
|
+
action: action,
|
|
3932
|
+
name: name
|
|
3933
|
+
})), _toConsumableArray(steps.map(function (step) {
|
|
3934
|
+
return step.key;
|
|
3935
|
+
})));
|
|
3570
3936
|
_context.n = 1;
|
|
3571
|
-
return validate(
|
|
3937
|
+
return validate(owned);
|
|
3572
3938
|
case 1:
|
|
3573
3939
|
if (_context.v) {
|
|
3574
3940
|
_context.n = 2;
|
|
@@ -3576,17 +3942,18 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3576
3942
|
}
|
|
3577
3943
|
return _context.a(2);
|
|
3578
3944
|
case 2:
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
}
|
|
3945
|
+
next = shouldAdvanceToRecipient ? {
|
|
3946
|
+
type: BUILDER_PANEL_TYPES.RECIPIENT,
|
|
3947
|
+
data: {
|
|
3948
|
+
index: index,
|
|
3949
|
+
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
3950
|
+
}
|
|
3951
|
+
} : stepTargetAfter({
|
|
3952
|
+
schema: schema,
|
|
3953
|
+
rule: rule,
|
|
3954
|
+
index: index
|
|
3955
|
+
});
|
|
3956
|
+
if (next) openType(next);else closePane();
|
|
3590
3957
|
case 3:
|
|
3591
3958
|
return _context.a(2);
|
|
3592
3959
|
}
|
|
@@ -3649,6 +4016,7 @@ var ConfigPane = function ConfigPane(_ref) {
|
|
|
3649
4016
|
searchTerm: searchTerm
|
|
3650
4017
|
})) !== null && _hostRenderConfig !== void 0 ? _hostRenderConfig : /*#__PURE__*/jsx(ActionConfigFields, {
|
|
3651
4018
|
action: action,
|
|
4019
|
+
hasRecipientField: hasRecipientField,
|
|
3652
4020
|
name: name,
|
|
3653
4021
|
searchTerm: searchTerm,
|
|
3654
4022
|
option: flatOption
|
|
@@ -3741,7 +4109,7 @@ var DelayPane = function DelayPane(_ref) {
|
|
|
3741
4109
|
placeholder: t("neetoRules.placeholders.enterDelay"),
|
|
3742
4110
|
size: "large",
|
|
3743
4111
|
type: "number"
|
|
3744
|
-
}), /*#__PURE__*/jsx(Select, {
|
|
4112
|
+
}), /*#__PURE__*/jsx(Select$1, {
|
|
3745
4113
|
dataTestid: "delay-unit",
|
|
3746
4114
|
defaultValue: value === null || value === void 0 ? void 0 : value.unit,
|
|
3747
4115
|
name: "".concat(name, ".value.unit"),
|
|
@@ -3928,7 +4296,7 @@ var LeadTimePane = function LeadTimePane(_ref) {
|
|
|
3928
4296
|
})
|
|
3929
4297
|
}), /*#__PURE__*/jsx("div", {
|
|
3930
4298
|
className: "w-32 shrink-0",
|
|
3931
|
-
children: /*#__PURE__*/jsx(Select
|
|
4299
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
3932
4300
|
dataTestid: "lead-time-unit",
|
|
3933
4301
|
isSearchable: false,
|
|
3934
4302
|
options: LEAD_TIME_UNITS,
|
|
@@ -3986,8 +4354,11 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
3986
4354
|
var schema = _ref.schema,
|
|
3987
4355
|
anchor = _ref.anchor,
|
|
3988
4356
|
index = _ref.index,
|
|
4357
|
+
stepKey = _ref.stepKey,
|
|
3989
4358
|
_ref$belowContent = _ref.belowContent,
|
|
3990
|
-
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent
|
|
4359
|
+
belowContent = _ref$belowContent === void 0 ? null : _ref$belowContent,
|
|
4360
|
+
_ref$configPending = _ref.configPending,
|
|
4361
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
3991
4362
|
var _useTranslation = useTranslation(),
|
|
3992
4363
|
t = _useTranslation.t;
|
|
3993
4364
|
var _useFormikContext = useFormikContext(),
|
|
@@ -4028,9 +4399,10 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4028
4399
|
anchor: anchor,
|
|
4029
4400
|
schema: schema,
|
|
4030
4401
|
rule: rule,
|
|
4031
|
-
index: index
|
|
4402
|
+
index: index,
|
|
4403
|
+
stepKey: stepKey
|
|
4032
4404
|
});
|
|
4033
|
-
}, [anchor, schema, rule, index]),
|
|
4405
|
+
}, [anchor, schema, rule, index, stepKey]),
|
|
4034
4406
|
title = _useMemo.title,
|
|
4035
4407
|
subtitle = _useMemo.subtitle,
|
|
4036
4408
|
multi = _useMemo.multi,
|
|
@@ -4065,6 +4437,7 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4065
4437
|
schema: schema,
|
|
4066
4438
|
rule: rule,
|
|
4067
4439
|
index: index,
|
|
4440
|
+
stepKey: stepKey,
|
|
4068
4441
|
value: value,
|
|
4069
4442
|
helpers: helpers
|
|
4070
4443
|
});
|
|
@@ -4093,7 +4466,9 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4093
4466
|
anchor: anchor,
|
|
4094
4467
|
schema: schema,
|
|
4095
4468
|
rule: rule,
|
|
4096
|
-
index: index
|
|
4469
|
+
index: index,
|
|
4470
|
+
stepKey: stepKey,
|
|
4471
|
+
configPending: configPending
|
|
4097
4472
|
});
|
|
4098
4473
|
if (target) openType({
|
|
4099
4474
|
type: target.type,
|
|
@@ -4107,21 +4482,53 @@ var OptionsPane = function OptionsPane(_ref) {
|
|
|
4107
4482
|
});
|
|
4108
4483
|
var optionLabel = function optionLabel(option) {
|
|
4109
4484
|
var Icon = option.icon;
|
|
4110
|
-
|
|
4485
|
+
// Short text sits inline as a pill; anything needing more room is a
|
|
4486
|
+
// standard popover behind an info icon.
|
|
4487
|
+
var reason = typeof option.disabledReason === "function" ? option.disabledReason() : option.disabledReason;
|
|
4488
|
+
var isTextReason = typeof reason === "string";
|
|
4489
|
+
// Only a node can be rendered as popover content; a host handing back a
|
|
4490
|
+
// plain object would otherwise crash the pane.
|
|
4491
|
+
var isNodeReason = /*#__PURE__*/isValidElement(reason) || Array.isArray(reason);
|
|
4492
|
+
var popover = option.disabledPopover || (isNodeReason ? {
|
|
4493
|
+
description: reason
|
|
4494
|
+
} : null);
|
|
4495
|
+
if (!Icon && !isTextReason && !popover) return option.label;
|
|
4111
4496
|
return /*#__PURE__*/jsxs("span", {
|
|
4112
4497
|
className: "mb-pane-option",
|
|
4113
4498
|
children: [Icon && /*#__PURE__*/jsx(Icon, {
|
|
4114
4499
|
size: 20
|
|
4115
|
-
}), option.label,
|
|
4500
|
+
}), option.label, popover && /*#__PURE__*/jsxs(Popover, {
|
|
4501
|
+
position: "top",
|
|
4502
|
+
trigger: /*#__PURE__*/jsx("span", {
|
|
4503
|
+
className: "mb-pane-info",
|
|
4504
|
+
onClick: function onClick(event) {
|
|
4505
|
+
return event.preventDefault();
|
|
4506
|
+
},
|
|
4507
|
+
children: /*#__PURE__*/jsx(Info, {
|
|
4508
|
+
size: 14
|
|
4509
|
+
})
|
|
4510
|
+
}),
|
|
4511
|
+
children: [popover.title && /*#__PURE__*/jsx(Popover.Title, {
|
|
4512
|
+
children: popover.title
|
|
4513
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
4514
|
+
color: "muted",
|
|
4515
|
+
variant: "body2",
|
|
4516
|
+
children: popover.description
|
|
4517
|
+
}), popover.helpLinkProps && /*#__PURE__*/jsx(Button, _objectSpread$2(_objectSpread$2({}, popover.helpLinkProps), {}, {
|
|
4518
|
+
className: "h-auto self-start p-0",
|
|
4519
|
+
size: "sm",
|
|
4520
|
+
variant: "link"
|
|
4521
|
+
}))]
|
|
4522
|
+
}), !popover && reason && isTextReason && (option.disabledTooltip ? /*#__PURE__*/jsx(Tooltip, {
|
|
4116
4523
|
content: option.disabledTooltip,
|
|
4117
4524
|
position: "top",
|
|
4118
4525
|
children: /*#__PURE__*/jsx("span", {
|
|
4119
4526
|
className: "mb-pane-warn",
|
|
4120
|
-
children:
|
|
4527
|
+
children: reason
|
|
4121
4528
|
})
|
|
4122
4529
|
}) : /*#__PURE__*/jsx("span", {
|
|
4123
4530
|
className: "mb-pane-warn",
|
|
4124
|
-
children:
|
|
4531
|
+
children: reason
|
|
4125
4532
|
}))]
|
|
4126
4533
|
});
|
|
4127
4534
|
};
|
|
@@ -4272,7 +4679,7 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4272
4679
|
var path = "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.value);
|
|
4273
4680
|
var current = getIn(values, path);
|
|
4274
4681
|
var options = normalizeOptions(dropdownOptions);
|
|
4275
|
-
return /*#__PURE__*/jsx(Select
|
|
4682
|
+
return /*#__PURE__*/jsx(Select, {
|
|
4276
4683
|
options: options,
|
|
4277
4684
|
placeholder: placeholder,
|
|
4278
4685
|
required: true,
|
|
@@ -4292,7 +4699,9 @@ var RecipientField = function RecipientField(_ref) {
|
|
|
4292
4699
|
var RecipientPane = function RecipientPane(_ref) {
|
|
4293
4700
|
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;
|
|
4294
4701
|
var schema = _ref.schema,
|
|
4295
|
-
index = _ref.index
|
|
4702
|
+
index = _ref.index,
|
|
4703
|
+
_ref$configPending = _ref.configPending,
|
|
4704
|
+
configPending = _ref$configPending === void 0 ? false : _ref$configPending;
|
|
4296
4705
|
var _useTranslation = useTranslation(),
|
|
4297
4706
|
t = _useTranslation.t;
|
|
4298
4707
|
var _useRuleModel = useRuleModel(schema),
|
|
@@ -4367,6 +4776,7 @@ var RecipientPane = function RecipientPane(_ref) {
|
|
|
4367
4776
|
if (!editor) {
|
|
4368
4777
|
return /*#__PURE__*/jsx(OptionsPane, {
|
|
4369
4778
|
belowContent: belowContent,
|
|
4779
|
+
configPending: configPending,
|
|
4370
4780
|
index: index,
|
|
4371
4781
|
schema: schema,
|
|
4372
4782
|
anchor: BUILDER_ANCHORS.ACTION_RECIPIENT
|
|
@@ -4466,7 +4876,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4466
4876
|
}
|
|
4467
4877
|
if (type === CONDITION_VALUE_TYPES.multiSelectCreate) {
|
|
4468
4878
|
var _current = getIn(values, valuesPath) || [];
|
|
4469
|
-
return /*#__PURE__*/jsx(Select
|
|
4879
|
+
return /*#__PURE__*/jsx(Select, {
|
|
4470
4880
|
autoFocus: true,
|
|
4471
4881
|
isCreatable: true,
|
|
4472
4882
|
isMulti: true,
|
|
@@ -4492,9 +4902,6 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
|
|
|
4492
4902
|
error: fieldError(valuePath),
|
|
4493
4903
|
orientation: "vertical",
|
|
4494
4904
|
value: String(_current2 !== null && _current2 !== void 0 ? _current2 : ""),
|
|
4495
|
-
onBlur: function onBlur() {
|
|
4496
|
-
return setFieldTouched(valuePath, true);
|
|
4497
|
-
},
|
|
4498
4905
|
onValueChange: function onValueChange(value) {
|
|
4499
4906
|
return setFieldValue(valuePath, value);
|
|
4500
4907
|
},
|
|
@@ -4634,9 +5041,11 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
|
|
|
4634
5041
|
component: ValuePane
|
|
4635
5042
|
}), BUILDER_PANEL_TYPES.ACTION_CONFIG, {
|
|
4636
5043
|
component: ConfigPane
|
|
4637
|
-
}), BUILDER_PANEL_TYPES.
|
|
5044
|
+
}), BUILDER_PANEL_TYPES.ACTION_STEP, {
|
|
5045
|
+
component: OptionsPane
|
|
5046
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.DELAY, {
|
|
4638
5047
|
component: DelayPane
|
|
4639
|
-
}),
|
|
5048
|
+
}), BUILDER_PANEL_TYPES.LEAD_TIME, {
|
|
4640
5049
|
component: LeadTimePane
|
|
4641
5050
|
}), BUILDER_PANEL_TYPES.NAME, {
|
|
4642
5051
|
component: NamePane
|
|
@@ -4719,7 +5128,10 @@ var Form = function Form(_ref) {
|
|
|
4719
5128
|
values: values,
|
|
4720
5129
|
schema: schema
|
|
4721
5130
|
});
|
|
4722
|
-
if (!isRuleComplete(
|
|
5131
|
+
if (!isRuleComplete({
|
|
5132
|
+
rule: rule,
|
|
5133
|
+
schema: schema
|
|
5134
|
+
}) || invalidScopeIndexes({
|
|
4723
5135
|
rule: rule,
|
|
4724
5136
|
schema: schema
|
|
4725
5137
|
}).length || invalidScopePhoneFieldIndexes({
|