@bigbinary/neeto-rules-frontend 0.4.6 → 0.4.7
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/README.md +20 -0
- package/app/javascript/src/translations/en.json +4 -2
- package/dist/index.cjs.js +79 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +82 -40
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -560,6 +560,26 @@ neetoRulesFrontend allows to pass custom action components from host application
|
|
|
560
560
|
},
|
|
561
561
|
```
|
|
562
562
|
|
|
563
|
+
#### 2.10 Custom email templates
|
|
564
|
+
|
|
565
|
+
neetoRulesFrontend allows to pass predefined email templates from host application. This enables to use templates created using neeto-message-templates-nano. Below is an example for custom email templates which is being sent by neeto-form in action options.
|
|
566
|
+
|
|
567
|
+
```jsx
|
|
568
|
+
{
|
|
569
|
+
"label": "Email to responder",
|
|
570
|
+
"value": "email_to_responder",
|
|
571
|
+
"type": "emailTo",
|
|
572
|
+
"templates": [
|
|
573
|
+
{
|
|
574
|
+
"id": "caca1cc9-f9db-480a-a64f-6ea0c72d4b05",
|
|
575
|
+
"name": "Send emails to rejected candidates",
|
|
576
|
+
"subject": "Application Status - Screening Round Unsuccessful",
|
|
577
|
+
"body": "<p>Dear {{full-name}},</p><p>Thank you for your interest. Unfortunately, we regret to inform you that you did not pass the screener round.</p><p>Best regards, </p><p>Spinkart</p>"
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
563
583
|
#### 3. `RulePreview`
|
|
564
584
|
|
|
565
585
|
The `RulePreview` component is used to preview the automation rule.
|
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
"checked": "Checked",
|
|
131
131
|
"unchecked": "Unchecked",
|
|
132
132
|
"text": "Text",
|
|
133
|
-
"ruleSummary": "Automation rule summary"
|
|
133
|
+
"ruleSummary": "Automation rule summary",
|
|
134
|
+
"template": "Template"
|
|
134
135
|
},
|
|
135
136
|
"placeholders": {
|
|
136
137
|
"if": "If",
|
|
@@ -139,7 +140,8 @@
|
|
|
139
140
|
"emailField": "Type email and press enter",
|
|
140
141
|
"selectTags": "Select Tags",
|
|
141
142
|
"selectOption": "Select option",
|
|
142
|
-
"value": "Value"
|
|
143
|
+
"value": "Value",
|
|
144
|
+
"selectTemplate": "Select a template"
|
|
143
145
|
},
|
|
144
146
|
"buttons": {
|
|
145
147
|
"save": "Save",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1530,7 +1530,9 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
1530
1530
|
value = _ref$value === void 0 ? "" : _ref$value,
|
|
1531
1531
|
label = _ref.label,
|
|
1532
1532
|
_ref$variables = _ref.variables,
|
|
1533
|
-
variables = _ref$variables === void 0 ? [] : _ref$variables
|
|
1533
|
+
variables = _ref$variables === void 0 ? [] : _ref$variables,
|
|
1534
|
+
_ref$editorRef = _ref.editorRef,
|
|
1535
|
+
editorRef = _ref$editorRef === void 0 ? null : _ref$editorRef;
|
|
1534
1536
|
var _useFormikContext = formik.useFormikContext(),
|
|
1535
1537
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
1536
1538
|
var _useState = React.useState(value),
|
|
@@ -1550,9 +1552,8 @@ var EditorAction = function EditorAction(_ref) {
|
|
|
1550
1552
|
addons: EDITOR_ADDONS,
|
|
1551
1553
|
className: "w-full",
|
|
1552
1554
|
"data-cy": "neeto-editor",
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1555
|
+
ref: editorRef,
|
|
1556
|
+
onChange: setEditorData
|
|
1556
1557
|
});
|
|
1557
1558
|
};
|
|
1558
1559
|
|
|
@@ -1596,19 +1597,6 @@ function _extends() {
|
|
|
1596
1597
|
return _extends.apply(this, arguments);
|
|
1597
1598
|
}
|
|
1598
1599
|
|
|
1599
|
-
var useDebouncedUpdate = function useDebouncedUpdate(value, setValue) {
|
|
1600
|
-
var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
|
|
1601
|
-
var _useState = React.useState(value),
|
|
1602
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1603
|
-
text = _useState2[0],
|
|
1604
|
-
setText = _useState2[1];
|
|
1605
|
-
var debouncedValue = reactUtils.useDebounce(text, duration);
|
|
1606
|
-
React.useEffect(function () {
|
|
1607
|
-
setValue(text);
|
|
1608
|
-
}, [debouncedValue]);
|
|
1609
|
-
return [text, setText];
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
1600
|
var _excluded$8 = ["initialFocusRef", "name", "label"];
|
|
1613
1601
|
var InputField$2 = function InputField(_ref) {
|
|
1614
1602
|
var initialFocusRef = _ref.initialFocusRef,
|
|
@@ -1616,24 +1604,15 @@ var InputField$2 = function InputField(_ref) {
|
|
|
1616
1604
|
label = _ref.label,
|
|
1617
1605
|
otherProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
1618
1606
|
var _useField = formik.useField(name),
|
|
1619
|
-
_useField2 = _slicedToArray(_useField,
|
|
1607
|
+
_useField2 = _slicedToArray(_useField, 2),
|
|
1620
1608
|
field = _useField2[0],
|
|
1621
|
-
meta = _useField2[1]
|
|
1622
|
-
setValue = _useField2[2].setValue;
|
|
1623
|
-
var _useDebouncedUpdate = useDebouncedUpdate(field.value, setValue),
|
|
1624
|
-
_useDebouncedUpdate2 = _slicedToArray(_useDebouncedUpdate, 2),
|
|
1625
|
-
text = _useDebouncedUpdate2[0],
|
|
1626
|
-
setText = _useDebouncedUpdate2[1];
|
|
1609
|
+
meta = _useField2[1];
|
|
1627
1610
|
return /*#__PURE__*/React__default["default"].createElement(neetoui.Input, _extends({
|
|
1628
1611
|
label: label,
|
|
1629
1612
|
type: "text"
|
|
1630
1613
|
}, field, {
|
|
1631
1614
|
error: meta.touched ? meta.error : "",
|
|
1632
|
-
ref: initialFocusRef
|
|
1633
|
-
value: text,
|
|
1634
|
-
onChange: function onChange(e) {
|
|
1635
|
-
return setText(e.target.value);
|
|
1636
|
-
}
|
|
1615
|
+
ref: initialFocusRef
|
|
1637
1616
|
}, otherProps));
|
|
1638
1617
|
};
|
|
1639
1618
|
|
|
@@ -1649,12 +1628,18 @@ var EmailFields = function EmailFields(_ref) {
|
|
|
1649
1628
|
index = _ref.index;
|
|
1650
1629
|
var _useFormikContext = formik.useFormikContext(),
|
|
1651
1630
|
errors = _useFormikContext.errors,
|
|
1652
|
-
touched = _useFormikContext.touched
|
|
1631
|
+
touched = _useFormikContext.touched,
|
|
1632
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
1653
1633
|
var _useState = React.useState(false),
|
|
1654
1634
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1655
1635
|
showPane = _useState2[0],
|
|
1656
1636
|
setShowPane = _useState2[1];
|
|
1637
|
+
var _useStateWithDependen = reactUtils.useStateWithDependency(null, [selectedField]),
|
|
1638
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
1639
|
+
selectedTemplate = _useStateWithDependen2[0],
|
|
1640
|
+
setSelectedTemplate = _useStateWithDependen2[1];
|
|
1657
1641
|
var initialFocusRef = React.useRef(null);
|
|
1642
|
+
var editorRef = React.useRef(null);
|
|
1658
1643
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1659
1644
|
t = _useTranslation.t;
|
|
1660
1645
|
useOnButtonPressed(initialFocusRef, function () {
|
|
@@ -1663,6 +1648,36 @@ var EmailFields = function EmailFields(_ref) {
|
|
|
1663
1648
|
var isValid = errors.actions && ramda.isNotNil((_errors$actions = errors.actions) === null || _errors$actions === void 0 || (_errors$actions = _errors$actions.value) === null || _errors$actions === void 0 ? void 0 : _errors$actions[index]) && ramda.isNotNil((_touched$actions = touched.actions) === null || _touched$actions === void 0 || (_touched$actions = _touched$actions.value) === null || _touched$actions === void 0 ? void 0 : _touched$actions[index]);
|
|
1664
1649
|
var separator = (selectedField === null || selectedField === void 0 || (_selectedField$separa = selectedField.separator) === null || _selectedField$separa === void 0 ? void 0 : _selectedField$separa.toLowerCase()) || t("neetoRules.common.as");
|
|
1665
1650
|
var defaultLabel = (selectedField === null || selectedField === void 0 ? void 0 : selectedField.emailPlaceholder) || t("neetoRules.common.email");
|
|
1651
|
+
var templates = selectedField === null || selectedField === void 0 ? void 0 : selectedField.templates;
|
|
1652
|
+
var isTemplateSelectionEnabled = neetoCist.isPresent(templates);
|
|
1653
|
+
var setEmailContent = function setEmailContent(ref, content) {
|
|
1654
|
+
if (!ref.current) return;
|
|
1655
|
+
ref.current.editor.commands.setContent(content);
|
|
1656
|
+
};
|
|
1657
|
+
var handleTemplateChange = function handleTemplateChange(option) {
|
|
1658
|
+
setSelectedTemplate(option);
|
|
1659
|
+
if (!option) return;
|
|
1660
|
+
var template = neetoCist.findBy({
|
|
1661
|
+
id: option.value
|
|
1662
|
+
}, templates);
|
|
1663
|
+
setFieldValue("".concat(name, ".body"), template.body);
|
|
1664
|
+
setEmailContent(editorRef, template.body);
|
|
1665
|
+
if (selectedField.hideSubject) return;
|
|
1666
|
+
setFieldValue("".concat(name, ".subject"), template.subject);
|
|
1667
|
+
};
|
|
1668
|
+
var isFirstFieldInForm = function isFirstFieldInForm(field) {
|
|
1669
|
+
if (isTemplateSelectionEnabled) {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
switch (field) {
|
|
1673
|
+
case "emails":
|
|
1674
|
+
return true;
|
|
1675
|
+
case "subject":
|
|
1676
|
+
return !isEmailIdField;
|
|
1677
|
+
default:
|
|
1678
|
+
return !isEmailIdField && selectedField.hideSubject;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1666
1681
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
1667
1682
|
className: "neeto-ui-text-gray-700 mt-1",
|
|
1668
1683
|
"data-cy": "action-email-seperator-text",
|
|
@@ -1695,18 +1710,32 @@ var EmailFields = function EmailFields(_ref) {
|
|
|
1695
1710
|
weight: "semibold"
|
|
1696
1711
|
}, defaultLabel)), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1697
1712
|
className: "w-full"
|
|
1698
|
-
},
|
|
1713
|
+
}, isTemplateSelectionEnabled && /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
|
|
1714
|
+
isClearable: true,
|
|
1715
|
+
isSearchable: true,
|
|
1716
|
+
className: "mb-4",
|
|
1717
|
+
innerRef: initialFocusRef,
|
|
1718
|
+
label: t("neetoRules.labels.template"),
|
|
1719
|
+
options: neetoCist.renameKeys({
|
|
1720
|
+
name: "label",
|
|
1721
|
+
id: "value"
|
|
1722
|
+
}, templates),
|
|
1723
|
+
placeholder: t("neetoRules.placeholders.selectTemplate"),
|
|
1724
|
+
value: selectedTemplate,
|
|
1725
|
+
onChange: handleTemplateChange
|
|
1726
|
+
}), isEmailIdField && /*#__PURE__*/React__default["default"].createElement(EmailIdFields, {
|
|
1699
1727
|
emails: emails,
|
|
1700
|
-
|
|
1701
|
-
|
|
1728
|
+
name: "".concat(name, ".emails"),
|
|
1729
|
+
initialFocusRef: isFirstFieldInForm("emails") ? initialFocusRef : null
|
|
1702
1730
|
}), !selectedField.hideSubject && /*#__PURE__*/React__default["default"].createElement(InputField$2, {
|
|
1703
1731
|
className: "mb-4",
|
|
1704
1732
|
"data-cy": "email-action-subject-text-field",
|
|
1705
|
-
initialFocusRef: isEmailIdField ? null : initialFocusRef,
|
|
1706
1733
|
label: t("neetoRules.labels.subject"),
|
|
1707
|
-
name: "".concat(name, ".subject")
|
|
1734
|
+
name: "".concat(name, ".subject"),
|
|
1735
|
+
initialFocusRef: isFirstFieldInForm("subject") ? initialFocusRef : null
|
|
1708
1736
|
}), /*#__PURE__*/React__default["default"].createElement(EditorAction, {
|
|
1709
|
-
|
|
1737
|
+
editorRef: editorRef,
|
|
1738
|
+
autoFocus: isFirstFieldInForm("body"),
|
|
1710
1739
|
label: t("neetoRules.labels.body"),
|
|
1711
1740
|
name: "".concat(name, ".body"),
|
|
1712
1741
|
value: (_action$metadata = action.metadata) === null || _action$metadata === void 0 ? void 0 : _action$metadata.body,
|
|
@@ -2387,7 +2416,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2387
2416
|
}) : t("neetoRules.common.then");
|
|
2388
2417
|
var actionOptions = React.useMemo(function () {
|
|
2389
2418
|
return getActionOptions(action, actions, optionList);
|
|
2390
|
-
}, [action, actions]);
|
|
2419
|
+
}, [action, actions, optionList]);
|
|
2391
2420
|
var selectedField = React.useMemo(function () {
|
|
2392
2421
|
return getFieldDetails$1(action.name, actionOptions);
|
|
2393
2422
|
}, [action, actionOptions]);
|
|
@@ -4603,6 +4632,19 @@ var Events = function Events(_ref) {
|
|
|
4603
4632
|
}));
|
|
4604
4633
|
};
|
|
4605
4634
|
|
|
4635
|
+
var useDebouncedUpdate = function useDebouncedUpdate(value, setValue) {
|
|
4636
|
+
var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
|
|
4637
|
+
var _useState = React.useState(value),
|
|
4638
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
4639
|
+
text = _useState2[0],
|
|
4640
|
+
setText = _useState2[1];
|
|
4641
|
+
var debouncedValue = reactUtils.useDebounce(text, duration);
|
|
4642
|
+
React.useEffect(function () {
|
|
4643
|
+
setValue(text);
|
|
4644
|
+
}, [debouncedValue]);
|
|
4645
|
+
return [text, setText];
|
|
4646
|
+
};
|
|
4647
|
+
|
|
4606
4648
|
var _excluded$4 = ["data", "name", "label"];
|
|
4607
4649
|
var InputField = function InputField(_ref) {
|
|
4608
4650
|
var data = _ref.data,
|