@bigbinary/neeto-message-templates-frontend 0.8.0-beta1 → 1.0.0

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useState, useRef, useEffect } from 'react';
2
- import { hyphenate, noop, isNotEmpty, renameKeys, findBy, capitalize, nullSafe } from '@bigbinary/neeto-cist';
2
+ import { hyphenate, noop, isNotEmpty, renameKeys, findBy, capitalize, nullSafe, isPresent } from '@bigbinary/neeto-cist';
3
3
  import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
4
4
  import Container from '@bigbinary/neeto-molecules/Container';
5
5
  import NeetoHeader from '@bigbinary/neeto-molecules/Header';
@@ -19,7 +19,7 @@ import require$$0 from 'util';
19
19
  import { create } from 'zustand';
20
20
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
21
21
  import Pane from '@bigbinary/neetoui/Pane';
22
- import { FormikEditor } from '@bigbinary/neeto-editor';
22
+ import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
23
23
  import NeetoUIForm from '@bigbinary/neetoui/formik/Form';
24
24
  import Input from '@bigbinary/neetoui/formik/Input';
25
25
  import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
@@ -35,7 +35,7 @@ import Spinner from '@bigbinary/neetoui/Spinner';
35
35
  import Select from '@bigbinary/neetoui/Select';
36
36
  import Textarea$1 from '@bigbinary/neetoui/Textarea';
37
37
  import Select$1 from '@bigbinary/neetoui/formik/Select';
38
- import { Delete } from '@bigbinary/neeto-icons';
38
+ import Delete from '@bigbinary/neeto-icons/Delete';
39
39
  import Label from '@bigbinary/neetoui/Label';
40
40
 
41
41
  function _typeof$1(o) {
@@ -2303,7 +2303,7 @@ var useCreateTemplate = function useCreateTemplate(ownerId, options) {
2303
2303
  ownerId: ownerIdValue(ownerId)
2304
2304
  });
2305
2305
  }, _objectSpread$d({
2306
- keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
2306
+ keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2307
2307
  }, options));
2308
2308
  };
2309
2309
  var useUpdateTemplate = function useUpdateTemplate(ownerId) {
@@ -2316,7 +2316,7 @@ var useUpdateTemplate = function useUpdateTemplate(ownerId) {
2316
2316
  ownerId: ownerIdValue(ownerId)
2317
2317
  });
2318
2318
  }, {
2319
- keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
2319
+ keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2320
2320
  });
2321
2321
  };
2322
2322
  var useDeleteTemplate = function useDeleteTemplate(ownerId) {
@@ -2326,7 +2326,7 @@ var useDeleteTemplate = function useDeleteTemplate(ownerId) {
2326
2326
  ownerId: ownerIdValue(ownerId)
2327
2327
  });
2328
2328
  }, {
2329
- keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
2329
+ keysToInvalidate: [[QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]]
2330
2330
  });
2331
2331
  };
2332
2332
 
@@ -3650,13 +3650,14 @@ var EmailAndSms = function EmailAndSms(_ref) {
3650
3650
  var setValues = _ref4.setValues,
3651
3651
  values = _ref4.values;
3652
3652
  var handleTemplateChange = function handleTemplateChange(value) {
3653
+ var _editorRef$current;
3653
3654
  if (!value) return;
3654
3655
  var customFieldValues = omit(initialValueKeys, values);
3655
3656
  var template = findBy({
3656
3657
  id: value === null || value === void 0 ? void 0 : value.value
3657
3658
  }, templates);
3658
3659
  setValues(_objectSpread$5(_objectSpread$5({}, template), customFieldValues));
3659
- editorRef.current.editor.commands.setContent(template.body);
3660
+ (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.editor) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.commands) === null || _editorRef$current === void 0 || _editorRef$current.setContent(template.body);
3660
3661
  };
3661
3662
  return /*#__PURE__*/jsxs(Fragment, {
3662
3663
  children: [/*#__PURE__*/jsx(Select, {
@@ -4015,13 +4016,16 @@ var KeyValuePairs = withT(function (_ref) {
4015
4016
  className: "flex h-8 space-x-3",
4016
4017
  children: [/*#__PURE__*/jsx(Input, {
4017
4018
  className: "w-2/5",
4019
+ "data-cy": "key-input-".concat(index),
4018
4020
  name: "".concat(name, ".").concat(index, ".key"),
4019
4021
  placeholder: t("neetoMessageTemplate.api.key")
4020
4022
  }), /*#__PURE__*/jsx(Input, {
4021
4023
  className: "w-3/5",
4024
+ "data-cy": "value-input-".concat(index),
4022
4025
  name: "".concat(name, ".").concat(index, ".value"),
4023
4026
  placeholder: t("neetoMessageTemplate.api.value"),
4024
4027
  suffix: showDeleteButton && /*#__PURE__*/jsx(Button, {
4028
+ "data-cy": "delete-key-value-pair-".concat(index),
4025
4029
  icon: Delete,
4026
4030
  size: "small",
4027
4031
  style: "text",
@@ -4037,6 +4041,7 @@ var KeyValuePairs = withT(function (_ref) {
4037
4041
  }, index);
4038
4042
  }), /*#__PURE__*/jsx(Button, {
4039
4043
  className: "w-full justify-center",
4044
+ "data-cy": "add-key-value-pair-button",
4040
4045
  label: t("neetoMessageTemplate.api.addKeyValuePair"),
4041
4046
  style: "secondary",
4042
4047
  onClick: function onClick() {
@@ -4077,30 +4082,37 @@ var buildTableColumnData = function buildTableColumnData(_ref) {
4077
4082
  return /*#__PURE__*/jsxs("div", {
4078
4083
  className: "flex items-center justify-between gap-x-3",
4079
4084
  children: [/*#__PURE__*/jsx(Button, {
4085
+ "data-cy": "api-template-name-link",
4080
4086
  label: name,
4081
4087
  style: "link",
4082
4088
  onClick: function onClick() {
4083
4089
  return handleOpenEditPane(apiTemplate);
4084
4090
  }
4085
4091
  }), /*#__PURE__*/jsx(MoreDropdown, {
4092
+ dropdownButtonProps: {
4093
+ "data-cy": "api-template-dropdown"
4094
+ },
4086
4095
  dropdownProps: {
4087
4096
  strategy: "fixed"
4088
4097
  },
4089
4098
  menuItems: [{
4090
4099
  key: "edit",
4091
4100
  label: t$1("neetoMessageTemplate.template.edit"),
4101
+ "data-cy": "api-template-button-edit-button",
4092
4102
  onClick: function onClick() {
4093
4103
  return handleOpenEditPane(apiTemplate);
4094
4104
  }
4095
4105
  }, {
4096
4106
  key: "status",
4097
4107
  label: equals(apiTemplate.status, TEMPLATE_STATUS.ACTIVE) ? t$1("neetoMessageTemplate.template.markAsInactive") : t$1("neetoMessageTemplate.template.markAsActive"),
4108
+ "data-cy": "api-template-button-status-button",
4098
4109
  onClick: function onClick() {
4099
4110
  return handleMarkAsActiveOrInactive(apiTemplate);
4100
4111
  }
4101
4112
  }, {
4102
4113
  key: "delete",
4103
4114
  label: t$1("neetoMessageTemplate.template.delete"),
4115
+ "data-cy": "api-template-button-delete-button",
4104
4116
  onClick: function onClick() {
4105
4117
  return handleOpenDeleteAlert(apiTemplate);
4106
4118
  }
@@ -4344,13 +4356,15 @@ var ApiTemplates = function ApiTemplates(_ref) {
4344
4356
  breadcrumbs: breadcrumbs,
4345
4357
  size: "small",
4346
4358
  actionBlock: /*#__PURE__*/jsx(Button, {
4359
+ "data-cy": "add-api-templates-button",
4347
4360
  label: t("neetoMessageTemplate.api.addApiTemplate"),
4348
4361
  onClick: function onClick() {
4349
4362
  return setIsFormPaneOpen(true);
4350
4363
  }
4351
4364
  }),
4352
4365
  searchProps: {
4353
- placeholder: t("neetoMessageTemplate.template.searchApiTemplates")
4366
+ placeholder: t("neetoMessageTemplate.template.searchApiTemplates"),
4367
+ "data-cy": "api-templates-search-input"
4354
4368
  },
4355
4369
  title: /*#__PURE__*/jsxs("span", {
4356
4370
  className: "flex",
@@ -4456,6 +4470,10 @@ var SEND_TO_API_FORM_VALIDATION_SCHEMA = yup.object({
4456
4470
  }))
4457
4471
  });
4458
4472
 
4473
+ var formatAdditionalData = function formatAdditionalData(additionalData) {
4474
+ return isPresent(additionalData) ? additionalData : [ADDITIONAL_DATA_INITIAL_VALUE];
4475
+ };
4476
+
4459
4477
  function ownKeys(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; }
4460
4478
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4461
4479
  var SendToApiPane = function SendToApiPane(props) {
@@ -4492,7 +4510,7 @@ var SendToApiForm = function SendToApiForm(_ref) {
4492
4510
  isLoadingTemplates = _useFetchTemplates.isLoading;
4493
4511
  var handleTemplateChange = function handleTemplateChange(setFieldValue, template) {
4494
4512
  setFieldValue("endpoint", template.endpoint);
4495
- setFieldValue("additionalData", template.additionalData);
4513
+ setFieldValue("additionalData", formatAdditionalData(template.additionalData));
4496
4514
  };
4497
4515
  var handleSubmit = function handleSubmit(formValues) {
4498
4516
  var additionalDataModifiedFormValues = modify("additionalData", rejectEmptyKeyValuePairs, formValues);
@@ -4549,10 +4567,12 @@ var SendToApiForm = function SendToApiForm(_ref) {
4549
4567
  children: /*#__PURE__*/jsx(ActionBlock, {
4550
4568
  isSubmitting: isSubmitting,
4551
4569
  cancelButtonProps: {
4552
- onClick: onClose
4570
+ onClick: onClose,
4571
+ "data-cy": "api-template-cancel-button"
4553
4572
  },
4554
4573
  submitButtonProps: {
4555
- label: t("neetoMessageTemplate.template.send")
4574
+ label: t("neetoMessageTemplate.template.send"),
4575
+ "data-cy": "api-template-send-button"
4556
4576
  }
4557
4577
  })
4558
4578
  })]