@bigbinary/neeto-rules-frontend 2.7.4 → 2.7.5

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.
@@ -201,6 +201,11 @@ var CONFIG_FOCUSABLE_SELECTOR = 'input:not([type="radio"]):not([type="checkbox"]
201
201
  var SMS_TYPES = ["sms", "smsToNumbers"];
202
202
  var RECIPIENT_FOCUSABLE_SELECTOR = 'input, textarea, [contenteditable="true"]';
203
203
  var SMS_TO_NUMBERS = "smsToNumbers";
204
+ var RECIPIENT_STORAGE_FIELDS = {
205
+ emails: "emails",
206
+ value: "value",
207
+ phoneNumbers: "phoneNumbers"
208
+ };
204
209
  var SWAP_CHANNEL_ORDER = ["email", "sms", "slack", "webhook", "calendar_invite"];
205
210
  var DEFAULT_DELAY_UNITS = TIME_UNITS;
206
211
 
@@ -582,6 +587,9 @@ var normalizeSchema = function normalizeSchema() {
582
587
  var joinTypeFor = function joinTypeFor(mode) {
583
588
  return mode === CONDITION_MODE.OR ? JOIN_TYPE.or : JOIN_TYPE.and;
584
589
  };
590
+ var recipientStorageField = function recipientStorageField(field) {
591
+ return field === RECIPIENT_STORAGE_FIELDS.emails ? RECIPIENT_STORAGE_FIELDS.emails : RECIPIENT_STORAGE_FIELDS.value;
592
+ };
585
593
  var modeFromJoinType = function modeFromJoinType(joinType) {
586
594
  return joinType === JOIN_TYPE.or ? CONDITION_MODE.OR : CONDITION_MODE.AND;
587
595
  };
@@ -2759,7 +2767,7 @@ var Canvas = function Canvas(_ref) {
2759
2767
  });
2760
2768
  };
2761
2769
  var isInvalid = function isInvalid(_ref4) {
2762
- 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;
2770
+ 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;
2763
2771
  var type = _ref4.type,
2764
2772
  index = _ref4.index;
2765
2773
  if (!flashing) return false;
@@ -2780,7 +2788,13 @@ var Canvas = function Canvas(_ref) {
2780
2788
  action: actionItem
2781
2789
  }));
2782
2790
  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));
2783
- var recipientFields = [].concat(_toConsumableArray(hasRecipientEditor || hasRecipientField ? ["emails"] : []), _toConsumableArray((flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === "smsToNumbers" ? ["phoneNumbers"] : []));
2791
+ var recipientConfig = [].concat(_toConsumableArray((((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
2792
+ return option.recipients || [];
2793
+ })), _toConsumableArray(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [])).find(function (item) {
2794
+ var _item$value;
2795
+ return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === actionItem.recipient;
2796
+ });
2797
+ var recipientFields = [].concat(_toConsumableArray(hasRecipientEditor || hasRecipientField ? [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] : []));
2784
2798
  switch (type) {
2785
2799
  case BUILDER_ANCHORS.TRIGGER_ACTOR:
2786
2800
  {
@@ -2810,7 +2824,9 @@ var Canvas = function Canvas(_ref) {
2810
2824
  exclude: recipientFields
2811
2825
  });
2812
2826
  case BUILDER_ANCHORS.ACTION_RECIPIENT:
2813
- return recipientFields.some(function (field) {
2827
+ return hasErrorAt({
2828
+ prefix: "".concat(fieldKeys.actions, ".value.").concat(index, ".name")
2829
+ }) || recipientFields.some(function (field) {
2814
2830
  return hasErrorAt({
2815
2831
  prefix: "".concat(actionMeta, ".").concat(field)
2816
2832
  });
@@ -3112,7 +3128,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
3112
3128
  var bodyPath = "".concat(name, ".body");
3113
3129
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3114
3130
  className: "flex flex-col gap-4",
3115
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
3131
+ children: [!(option !== null && option !== void 0 && option.hideSubject) && /*#__PURE__*/jsxRuntime.jsx(Input, {
3116
3132
  required: true,
3117
3133
  error: fieldError(subjectPath),
3118
3134
  label: t("neetoRules.builder.config.subject"),
@@ -3431,7 +3447,7 @@ var ConfigPane = function ConfigPane(_ref) {
3431
3447
  while (1) switch (_context.n) {
3432
3448
  case 0:
3433
3449
  _context.n = 1;
3434
- return validate(["emails"]);
3450
+ return validate([RECIPIENT_STORAGE_FIELDS.emails]);
3435
3451
  case 1:
3436
3452
  if (_context.v) {
3437
3453
  _context.n = 2;
@@ -4064,8 +4080,8 @@ var RecipientField = function RecipientField(_ref) {
4064
4080
  var fieldError = function fieldError(path) {
4065
4081
  return formik.getIn(touched, path) && formik.getIn(errors, path);
4066
4082
  };
4067
- if (field === "emails") {
4068
- var _path = "".concat(name, ".emails");
4083
+ if (field === RECIPIENT_STORAGE_FIELDS.emails) {
4084
+ var _path = "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.emails);
4069
4085
  var _current = formik.getIn(values, _path) || [];
4070
4086
  return /*#__PURE__*/jsxRuntime.jsx(MultiEmailInput, {
4071
4087
  required: true,
@@ -4088,7 +4104,7 @@ var RecipientField = function RecipientField(_ref) {
4088
4104
  }
4089
4105
  });
4090
4106
  }
4091
- var path = "".concat(name, ".value");
4107
+ var path = "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.value);
4092
4108
  var current = formik.getIn(values, path);
4093
4109
  var options = normalizeOptions(dropdownOptions);
4094
4110
  return /*#__PURE__*/jsxRuntime.jsx(Select$1, {
@@ -4134,7 +4150,7 @@ var RecipientPane = function RecipientPane(_ref) {
4134
4150
  });
4135
4151
  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, action.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));
4136
4152
  var isSmsToNumbers = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === SMS_TO_NUMBERS;
4137
- var recipientFieldPath = isSmsToNumbers ? "".concat(name, ".phoneNumbers") : "".concat(name, ".emails");
4153
+ var recipientFieldPath = isSmsToNumbers ? "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.phoneNumbers) : "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.emails);
4138
4154
  usePaneValidation(recipientFieldPath);
4139
4155
  react.useEffect(function () {
4140
4156
  var _bodyRef$current;
@@ -4165,7 +4181,7 @@ var RecipientPane = function RecipientPane(_ref) {
4165
4181
  action: action
4166
4182
  })) !== null && _schema$actions$rende !== void 0 ? _schema$actions$rende : builtInRecipientField;
4167
4183
  var phoneField = isSmsToNumbers ? /*#__PURE__*/jsxRuntime.jsx(index.PhoneNumberField, {
4168
- name: "".concat(name, ".phoneNumbers"),
4184
+ name: "".concat(name, ".").concat(RECIPIENT_STORAGE_FIELDS.phoneNumbers),
4169
4185
  phoneNumbers: (_action$metadata = action.metadata) === null || _action$metadata === void 0 ? void 0 : _action$metadata.phoneNumbers
4170
4186
  }) : null;
4171
4187
  var belowField = phoneField || recipientField;