@bigbinary/neeto-rules-frontend 0.4.1 → 0.4.2
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/dist/index.cjs.js +34 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1097,7 +1097,7 @@ var useOnButtonPressed = function useOnButtonPressed(ref, handler) {
|
|
|
1097
1097
|
var buttonPressed = function buttonPressed() {
|
|
1098
1098
|
var keysPressed = {};
|
|
1099
1099
|
var listener = function listener(event) {
|
|
1100
|
-
if (
|
|
1100
|
+
if (ramda.isNil(event.key)) return;
|
|
1101
1101
|
keysPressed[event.key] = true;
|
|
1102
1102
|
if ((keysPressed["Meta"] || keysPressed["Control"]) && event.key === "Enter") {
|
|
1103
1103
|
handler();
|
|
@@ -2355,8 +2355,10 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2355
2355
|
elementProps = _ref.elementProps,
|
|
2356
2356
|
onSelectAction = _ref.onSelectAction,
|
|
2357
2357
|
selectedActionOptions = _ref.selectedActionOptions;
|
|
2358
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
2359
|
+
t = _useTranslation.t;
|
|
2358
2360
|
var _useState = React.useState({
|
|
2359
|
-
label:
|
|
2361
|
+
label: t("neetoRules.form.doThis")
|
|
2360
2362
|
}),
|
|
2361
2363
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2362
2364
|
selectedOption = _useState2[0],
|
|
@@ -2376,9 +2378,9 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2376
2378
|
touched = _useFormikContext.touched;
|
|
2377
2379
|
var optionList = elementProps.actionOptions;
|
|
2378
2380
|
var actions = values[parentName].value || [];
|
|
2379
|
-
var label = index ?
|
|
2380
|
-
what:
|
|
2381
|
-
}) :
|
|
2381
|
+
var label = index ? t("neetoRules.common.and", {
|
|
2382
|
+
what: t("neetoRules.common.then")
|
|
2383
|
+
}) : t("neetoRules.common.then");
|
|
2382
2384
|
var actionOptions = React.useMemo(function () {
|
|
2383
2385
|
return getActionOptions(action, actions, optionList);
|
|
2384
2386
|
}, [action, actions]);
|
|
@@ -2386,7 +2388,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2386
2388
|
return getFieldDetails$1(action.name, actionOptions);
|
|
2387
2389
|
}, [action, actionOptions]);
|
|
2388
2390
|
var searchedOptions = getSearchedOptions$3(actionOptions, searchTerm);
|
|
2389
|
-
var isActionSelected = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) ===
|
|
2391
|
+
var isActionSelected = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) === t("neetoRules.form.doThis") && errors.actions && touched.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]);
|
|
2390
2392
|
var handleSelectOption = function handleSelectOption(option) {
|
|
2391
2393
|
setFieldValue("".concat(name, ".name"), option.value);
|
|
2392
2394
|
setFieldValue("".concat(name, ".metadata"), {});
|
|
@@ -2406,7 +2408,8 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2406
2408
|
}
|
|
2407
2409
|
return [];
|
|
2408
2410
|
};
|
|
2409
|
-
var
|
|
2411
|
+
var isMessageToSlackAction = (action === null || action === void 0 ? void 0 : action.name) === "message_to_slack";
|
|
2412
|
+
var _ref2 = isMessageToSlackAction && getSlackChannelErrors(getSelectedFieldOptions(), action),
|
|
2410
2413
|
selectDropDownHasError = _ref2.error,
|
|
2411
2414
|
selectDropDownErrorMessage = _ref2.message;
|
|
2412
2415
|
var findSelectedOption = function findSelectedOption() {
|
|
@@ -2414,18 +2417,35 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2414
2417
|
value: selectedField === null || selectedField === void 0 ? void 0 : selectedField.value,
|
|
2415
2418
|
label: selectedField === null || selectedField === void 0 ? void 0 : selectedField.label
|
|
2416
2419
|
}) : setSelectedOption({
|
|
2417
|
-
label:
|
|
2420
|
+
label: t("neetoRules.form.doThis")
|
|
2418
2421
|
});
|
|
2419
2422
|
};
|
|
2423
|
+
var _ref3 = selectedField || {},
|
|
2424
|
+
_ref3$isDisabled = _ref3.isDisabled,
|
|
2425
|
+
isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled,
|
|
2426
|
+
_ref3$disabledReason = _ref3.disabledReason,
|
|
2427
|
+
disabledReason = _ref3$disabledReason === void 0 ? "" : _ref3$disabledReason;
|
|
2428
|
+
var renderErrorCallout = function renderErrorCallout(message) {
|
|
2429
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
2430
|
+
className: "neeto-ui-text-white neeto-ui-bg-error-500 neeto-ui-rounded-sm -mx-4 w-full p-3",
|
|
2431
|
+
style: "h5"
|
|
2432
|
+
}, message);
|
|
2433
|
+
};
|
|
2434
|
+
var renderDisabledReason = function renderDisabledReason() {
|
|
2435
|
+
if (typeof disabledReason === "function") {
|
|
2436
|
+
return disabledReason(selectedField);
|
|
2437
|
+
}
|
|
2438
|
+
if (typeof disabledReason === "string" && neetoCist.isPresent(disabledReason)) {
|
|
2439
|
+
return renderErrorCallout(disabledReason);
|
|
2440
|
+
}
|
|
2441
|
+
return null;
|
|
2442
|
+
};
|
|
2420
2443
|
React.useEffect(function () {
|
|
2421
2444
|
findSelectedOption();
|
|
2422
2445
|
}, [selectedField]);
|
|
2423
2446
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2424
2447
|
className: "mb-1 flex max-w-2xl flex-wrap gap-x-1 gap-y-2"
|
|
2425
|
-
}, selectDropDownHasError && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
2426
|
-
className: "neeto-ui-text-white neeto-ui-bg-error-500 neeto-ui-rounded-sm -mx-4 w-full p-3",
|
|
2427
|
-
style: "h5"
|
|
2428
|
-
}, selectDropDownErrorMessage), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
2448
|
+
}, selectDropDownHasError && renderErrorCallout(selectDropDownErrorMessage), !isMessageToSlackAction && isDisabled && renderDisabledReason(), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
2429
2449
|
className: "neeto-ui-text-gray-700 mt-1",
|
|
2430
2450
|
style: "h5",
|
|
2431
2451
|
weight: "normal"
|
|
@@ -2454,7 +2474,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2454
2474
|
autoFocus: true,
|
|
2455
2475
|
className: "mb-1",
|
|
2456
2476
|
"data-cy": "search-text-field",
|
|
2457
|
-
placeholder:
|
|
2477
|
+
placeholder: t("neetoRules.common.search"),
|
|
2458
2478
|
prefix: /*#__PURE__*/React__default["default"].createElement(neetoIcons.Search, null),
|
|
2459
2479
|
value: searchTerm,
|
|
2460
2480
|
onChange: function onChange(e) {
|
|
@@ -2478,7 +2498,7 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
2478
2498
|
}, option.label);
|
|
2479
2499
|
})), ramda.isEmpty(actionOptions) && /*#__PURE__*/React__default["default"].createElement(MenuItem$7.Button, {
|
|
2480
2500
|
"data-cy": "no-options-menu-item"
|
|
2481
|
-
},
|
|
2501
|
+
}, t("neetoRules.common.noOptions")))), /*#__PURE__*/React__default["default"].createElement(ActionSubItem, {
|
|
2482
2502
|
action: action,
|
|
2483
2503
|
index: index,
|
|
2484
2504
|
selectedField: selectedField,
|