@bigbinary/neeto-rules-frontend 0.4.1 → 0.4.3
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 +574 -11
- package/app/javascript/src/translations/en.json +1 -0
- package/dist/index.cjs.js +46 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +49 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { BrowserRouter } from 'react-router-dom';
|
|
|
3
3
|
import { shallow } from 'zustand/shallow';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { useFormikContext, Formik, Form, useField, FieldArray, ErrorMessage } from 'formik';
|
|
6
|
-
import { findBy, noop, isNotEmpty, toLabelAndValue, removeBy } from '@bigbinary/neeto-cist';
|
|
6
|
+
import { findBy, noop, isNotEmpty, isPresent, toLabelAndValue, removeBy } from '@bigbinary/neeto-cist';
|
|
7
7
|
import { ActionBlock, Textarea, MultiEmailInput, Input as Input$2, Select as Select$1, Radio } from '@bigbinary/neetoui/formik';
|
|
8
8
|
import { t as t$1 } from 'i18next';
|
|
9
9
|
import * as yup from 'yup';
|
|
@@ -11,10 +11,10 @@ import { isEditorEmpty, FormikEditor } from '@bigbinary/neeto-editor';
|
|
|
11
11
|
import { withImmutableActions, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
12
12
|
import { create } from 'zustand';
|
|
13
13
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
14
|
-
import { Typography, Button, Pane, DatePicker, Dropdown as Dropdown$1, Input as Input$1, Checkbox, Select, Label } from '@bigbinary/neetoui';
|
|
14
|
+
import { Typography, Button, Pane, DatePicker, Dropdown as Dropdown$1, Input as Input$1, Checkbox, Select, Tooltip, Label } from '@bigbinary/neetoui';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { Down, Up, Check, Search, Close, Delete, Plus, Refresh, Eye } from '@bigbinary/neeto-icons';
|
|
17
|
-
import { pluck, isNotNil, assocPath, toLower, isEmpty,
|
|
17
|
+
import { pluck, isNil, isNotNil, assocPath, toLower, isEmpty, without, append, pipe, partition } from 'ramda';
|
|
18
18
|
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
19
19
|
import useHotkeys from '@bigbinary/neeto-hotkeys';
|
|
20
20
|
|
|
@@ -1067,7 +1067,7 @@ var useOnButtonPressed = function useOnButtonPressed(ref, handler) {
|
|
|
1067
1067
|
var buttonPressed = function buttonPressed() {
|
|
1068
1068
|
var keysPressed = {};
|
|
1069
1069
|
var listener = function listener(event) {
|
|
1070
|
-
if (
|
|
1070
|
+
if (isNil(event.key)) return;
|
|
1071
1071
|
keysPressed[event.key] = true;
|
|
1072
1072
|
if ((keysPressed["Meta"] || keysPressed["Control"]) && event.key === "Enter") {
|
|
1073
1073
|
handler();
|
|
@@ -2325,8 +2325,10 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2325
2325
|
elementProps = _ref.elementProps,
|
|
2326
2326
|
onSelectAction = _ref.onSelectAction,
|
|
2327
2327
|
selectedActionOptions = _ref.selectedActionOptions;
|
|
2328
|
+
var _useTranslation = useTranslation(),
|
|
2329
|
+
t = _useTranslation.t;
|
|
2328
2330
|
var _useState = useState({
|
|
2329
|
-
label: t
|
|
2331
|
+
label: t("neetoRules.form.doThis")
|
|
2330
2332
|
}),
|
|
2331
2333
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2332
2334
|
selectedOption = _useState2[0],
|
|
@@ -2346,9 +2348,9 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2346
2348
|
touched = _useFormikContext.touched;
|
|
2347
2349
|
var optionList = elementProps.actionOptions;
|
|
2348
2350
|
var actions = values[parentName].value || [];
|
|
2349
|
-
var label = index ? t
|
|
2350
|
-
what: t
|
|
2351
|
-
}) : t
|
|
2351
|
+
var label = index ? t("neetoRules.common.and", {
|
|
2352
|
+
what: t("neetoRules.common.then")
|
|
2353
|
+
}) : t("neetoRules.common.then");
|
|
2352
2354
|
var actionOptions = useMemo(function () {
|
|
2353
2355
|
return getActionOptions(action, actions, optionList);
|
|
2354
2356
|
}, [action, actions]);
|
|
@@ -2356,7 +2358,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2356
2358
|
return getFieldDetails$1(action.name, actionOptions);
|
|
2357
2359
|
}, [action, actionOptions]);
|
|
2358
2360
|
var searchedOptions = getSearchedOptions$3(actionOptions, searchTerm);
|
|
2359
|
-
var isActionSelected = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) === t
|
|
2361
|
+
var isActionSelected = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) === t("neetoRules.form.doThis") && errors.actions && touched.actions && 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]) && 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]);
|
|
2360
2362
|
var handleSelectOption = function handleSelectOption(option) {
|
|
2361
2363
|
setFieldValue("".concat(name, ".name"), option.value);
|
|
2362
2364
|
setFieldValue("".concat(name, ".metadata"), {});
|
|
@@ -2376,7 +2378,8 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2376
2378
|
}
|
|
2377
2379
|
return [];
|
|
2378
2380
|
};
|
|
2379
|
-
var
|
|
2381
|
+
var isMessageToSlackAction = (action === null || action === void 0 ? void 0 : action.name) === "message_to_slack";
|
|
2382
|
+
var _ref2 = isMessageToSlackAction && getSlackChannelErrors(getSelectedFieldOptions(), action),
|
|
2380
2383
|
selectDropDownHasError = _ref2.error,
|
|
2381
2384
|
selectDropDownErrorMessage = _ref2.message;
|
|
2382
2385
|
var findSelectedOption = function findSelectedOption() {
|
|
@@ -2384,18 +2387,35 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2384
2387
|
value: selectedField === null || selectedField === void 0 ? void 0 : selectedField.value,
|
|
2385
2388
|
label: selectedField === null || selectedField === void 0 ? void 0 : selectedField.label
|
|
2386
2389
|
}) : setSelectedOption({
|
|
2387
|
-
label: t
|
|
2390
|
+
label: t("neetoRules.form.doThis")
|
|
2388
2391
|
});
|
|
2389
2392
|
};
|
|
2393
|
+
var _ref3 = selectedField || {},
|
|
2394
|
+
_ref3$isDisabled = _ref3.isDisabled,
|
|
2395
|
+
isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled,
|
|
2396
|
+
_ref3$disabledReason = _ref3.disabledReason,
|
|
2397
|
+
disabledReason = _ref3$disabledReason === void 0 ? "" : _ref3$disabledReason;
|
|
2398
|
+
var renderErrorCallout = function renderErrorCallout(message) {
|
|
2399
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
2400
|
+
className: "neeto-ui-text-white neeto-ui-bg-error-500 neeto-ui-rounded-sm -mx-4 w-full p-3",
|
|
2401
|
+
style: "h5"
|
|
2402
|
+
}, message);
|
|
2403
|
+
};
|
|
2404
|
+
var renderDisabledReason = function renderDisabledReason() {
|
|
2405
|
+
if (typeof disabledReason === "function") {
|
|
2406
|
+
return disabledReason(selectedField);
|
|
2407
|
+
}
|
|
2408
|
+
if (typeof disabledReason === "string" && isPresent(disabledReason)) {
|
|
2409
|
+
return renderErrorCallout(disabledReason);
|
|
2410
|
+
}
|
|
2411
|
+
return null;
|
|
2412
|
+
};
|
|
2390
2413
|
useEffect(function () {
|
|
2391
2414
|
findSelectedOption();
|
|
2392
2415
|
}, [selectedField]);
|
|
2393
2416
|
return /*#__PURE__*/React.createElement("div", {
|
|
2394
2417
|
className: "mb-1 flex max-w-2xl flex-wrap gap-x-1 gap-y-2"
|
|
2395
|
-
}, selectDropDownHasError && /*#__PURE__*/React.createElement(Typography, {
|
|
2396
|
-
className: "neeto-ui-text-white neeto-ui-bg-error-500 neeto-ui-rounded-sm -mx-4 w-full p-3",
|
|
2397
|
-
style: "h5"
|
|
2398
|
-
}, selectDropDownErrorMessage), /*#__PURE__*/React.createElement(Typography, {
|
|
2418
|
+
}, selectDropDownHasError && renderErrorCallout(selectDropDownErrorMessage), !isMessageToSlackAction && isDisabled && renderDisabledReason(), /*#__PURE__*/React.createElement(Typography, {
|
|
2399
2419
|
className: "neeto-ui-text-gray-700 mt-1",
|
|
2400
2420
|
style: "h5",
|
|
2401
2421
|
weight: "normal"
|
|
@@ -2424,7 +2444,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2424
2444
|
autoFocus: true,
|
|
2425
2445
|
className: "mb-1",
|
|
2426
2446
|
"data-cy": "search-text-field",
|
|
2427
|
-
placeholder: t
|
|
2447
|
+
placeholder: t("neetoRules.common.search"),
|
|
2428
2448
|
prefix: /*#__PURE__*/React.createElement(Search, null),
|
|
2429
2449
|
value: searchTerm,
|
|
2430
2450
|
onChange: function onChange(e) {
|
|
@@ -2448,7 +2468,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2448
2468
|
}, option.label);
|
|
2449
2469
|
})), isEmpty(actionOptions) && /*#__PURE__*/React.createElement(MenuItem$7.Button, {
|
|
2450
2470
|
"data-cy": "no-options-menu-item"
|
|
2451
|
-
}, t
|
|
2471
|
+
}, t("neetoRules.common.noOptions")))), /*#__PURE__*/React.createElement(ActionSubItem, {
|
|
2452
2472
|
action: action,
|
|
2453
2473
|
index: index,
|
|
2454
2474
|
selectedField: selectedField,
|
|
@@ -4116,9 +4136,10 @@ var Events$1 = function Events(_ref) {
|
|
|
4116
4136
|
}));
|
|
4117
4137
|
};
|
|
4118
4138
|
|
|
4119
|
-
var _excluded$5 = ["data", "label", "name", "performerName", "conditionsName", "onSelectEvent"];
|
|
4139
|
+
var _excluded$5 = ["addButtonTooltipProps", "data", "label", "name", "performerName", "conditionsName", "onSelectEvent"];
|
|
4120
4140
|
var EventConditions = function EventConditions(_ref) {
|
|
4121
|
-
var
|
|
4141
|
+
var addButtonTooltipProps = _ref.addButtonTooltipProps,
|
|
4142
|
+
data = _ref.data,
|
|
4122
4143
|
label = _ref.label,
|
|
4123
4144
|
name = _ref.name,
|
|
4124
4145
|
performerName = _ref.performerName,
|
|
@@ -4128,6 +4149,8 @@ var EventConditions = function EventConditions(_ref) {
|
|
|
4128
4149
|
var _useFormikContext = useFormikContext(),
|
|
4129
4150
|
values = _useFormikContext.values,
|
|
4130
4151
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
4152
|
+
var _useTranslation = useTranslation(),
|
|
4153
|
+
t = _useTranslation.t;
|
|
4131
4154
|
var elementProps = data[name] || {};
|
|
4132
4155
|
var conditionProps = data[conditionsName] || {};
|
|
4133
4156
|
var conditions = values[conditionsName].value || [];
|
|
@@ -4154,18 +4177,21 @@ var EventConditions = function EventConditions(_ref) {
|
|
|
4154
4177
|
name: name,
|
|
4155
4178
|
onSelectEvent: onSelectEvent,
|
|
4156
4179
|
performerName: performerName
|
|
4157
|
-
})), showAddButton && /*#__PURE__*/React.createElement(
|
|
4180
|
+
})), showAddButton && /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
4181
|
+
content: t("neetoRules.form.noTicketFields")
|
|
4182
|
+
}, addButtonTooltipProps), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
4158
4183
|
"data-cy": "add-condition-button",
|
|
4159
4184
|
"data-test-id": "automation-rules-add-events-button",
|
|
4185
|
+
disabled: isEmpty(conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.conditionOptions),
|
|
4160
4186
|
icon: Plus,
|
|
4161
4187
|
size: 32,
|
|
4162
|
-
style: "
|
|
4188
|
+
style: "text",
|
|
4163
4189
|
tooltipProps: {
|
|
4164
|
-
content: t
|
|
4190
|
+
content: t("neetoRules.form.addCondition"),
|
|
4165
4191
|
position: "top"
|
|
4166
4192
|
},
|
|
4167
4193
|
onClick: handleAddCondition
|
|
4168
|
-
})), !showAddButton && /*#__PURE__*/React.createElement("div", {
|
|
4194
|
+
})))), !showAddButton && /*#__PURE__*/React.createElement("div", {
|
|
4169
4195
|
className: "mt-3"
|
|
4170
4196
|
}, /*#__PURE__*/React.createElement(Conditions, _extends({
|
|
4171
4197
|
data: data,
|